1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73

ash / webui / scanning / scanning_app_delegate.h [blame]

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_WEBUI_SCANNING_SCANNING_APP_DELEGATE_H_
#define ASH_WEBUI_SCANNING_SCANNING_APP_DELEGATE_H_

#include <memory>
#include <string>
#include <vector>

#include "ash/webui/scanning/mojom/scanning.mojom-forward.h"
#include "base/files/file_path.h"
#include "base/functional/callback_forward.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"

namespace ui {
class SelectFilePolicy;
}  // namespace ui

namespace content {
class WebUI;
}  // namespace content

namespace ash {

// A delegate which exposes browser functionality from //chrome to the Scan app
// UI.
class ScanningAppDelegate {
 public:
  using BindScanServiceCallback = base::RepeatingCallback<void(
      mojo::PendingReceiver<scanning::mojom::ScanService>)>;

  virtual ~ScanningAppDelegate() = default;

  // Returns a ChromeSelectFilePolicy used to open a select dialog.
  virtual std::unique_ptr<ui::SelectFilePolicy>
  CreateChromeSelectFilePolicy() = 0;

  // Gets the display name from |path| to show in the Scan To dropdown. Handles
  // the special case of converting the Google Drive root and MyFiles directory
  // to the desired display names "Google Drive" and "My Files" respectively.
  virtual std::string GetBaseNameFromPath(const base::FilePath& path) = 0;

  // Gets the MyFiles path for the current user.
  virtual base::FilePath GetMyFilesPath() = 0;

  // Gets scan settings from Pref service.
  virtual std::string GetScanSettingsFromPrefs() = 0;

  // Determines if |path_to_file| is a supported file path for the Files app.
  virtual bool IsFilePathSupported(const base::FilePath& path_to_file) = 0;

  // Opens the Media app with the files specified in |file_paths|.
  virtual void OpenFilesInMediaApp(
      const std::vector<base::FilePath>& file_paths) = 0;

  // Saves scan settings to Pref service.
  virtual void SaveScanSettingsToPrefs(const std::string& scan_settings) = 0;

  // Opens the Files app with |path_to_file| highlighted. Returns false if
  // |path_to_file| is not found in the filesystem.
  virtual void ShowFileInFilesApp(
      const base::FilePath& path_to_file,
      base::OnceCallback<void(const bool)> callback) = 0;

  virtual BindScanServiceCallback GetBindScanServiceCallback(
      content::WebUI* web_ui) = 0;
};

}  // namespace ash

#endif  // ASH_WEBUI_SCANNING_SCANNING_APP_DELEGATE_H_