blob: 276030fbc989558da6f924f511b0bda2c84e3a1d [file] [log] [blame]
Melissa Zhangdb4dffa2020-07-01 04:03:111// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_SHARESHEET_SHARESHEET_SERVICE_DELEGATE_H_
6#define CHROME_BROWSER_SHARESHEET_SHARESHEET_SERVICE_DELEGATE_H_
7
8#include <memory>
Jan Wilken Dörriead587c32021-03-11 14:09:279#include <string>
Melissa Zhangdb4dffa2020-07-01 04:03:1110
Melissa Zhang12f6a072020-09-30 21:16:0711#include "base/callback.h"
Melissa Zhang93826e692020-07-14 04:39:0212#include "chrome/browser/sharesheet/sharesheet_controller.h"
Melissa Zhangb330e5ab82020-07-21 05:51:3613#include "chrome/browser/sharesheet/sharesheet_types.h"
Melissa Zhang59ca374f2020-07-22 05:55:5114#include "components/services/app_service/public/mojom/types.mojom.h"
Melissa Zhangc6105cc2021-03-16 05:19:4315#include "ui/base/accelerators/accelerator.h"
Melissa Zhang26c16932020-12-11 05:15:2316#include "ui/gfx/native_widget_types.h"
Melissa Zhangdb4dffa2020-07-01 04:03:1117
Melissa Zhang575490a2020-08-31 07:14:4018class Profile;
Melissa Zhang4fd3f9e2021-04-15 01:13:0819
20namespace ash {
21namespace sharesheet {
Melissa Zhang93826e692020-07-14 04:39:0222class SharesheetBubbleView;
Melissa Zhang4fd3f9e2021-04-15 01:13:0823} // namespace sharesheet
24} // namespace ash
Melissa Zhangdb4dffa2020-07-01 04:03:1125
26namespace views {
27class View;
Melissa Zhang4fd3f9e2021-04-15 01:13:0828} // namespace views
Melissa Zhangdb4dffa2020-07-01 04:03:1129
Melissa Zhanga8a835f2020-11-05 05:02:4630namespace gfx {
31struct VectorIcon;
Melissa Zhang4fd3f9e2021-04-15 01:13:0832} // namespace gfx
Melissa Zhanga8a835f2020-11-05 05:02:4633
Melissa Zhangdb4dffa2020-07-01 04:03:1134namespace sharesheet {
35
36class SharesheetService;
37
Melissa Zhang93826e692020-07-14 04:39:0238// The SharesheetServiceDelegate is the middle point between the UI and the
39// business logic in the sharesheet.
40class SharesheetServiceDelegate : public SharesheetController {
Melissa Zhangdb4dffa2020-07-01 04:03:1141 public:
Melissa Zhang26c16932020-12-11 05:15:2342 SharesheetServiceDelegate(gfx::NativeWindow native_window,
Maggie Cai69305332020-08-04 23:28:2643 SharesheetService* sharesheet_service);
Melissa Zhang93826e692020-07-14 04:39:0244 ~SharesheetServiceDelegate() override;
Melissa Zhangdb4dffa2020-07-01 04:03:1145 SharesheetServiceDelegate(const SharesheetServiceDelegate&) = delete;
46 SharesheetServiceDelegate& operator=(const SharesheetServiceDelegate&) =
47 delete;
48
Melissa Zhang59ca374f2020-07-22 05:55:5149 void ShowBubble(std::vector<TargetInfo> targets,
Melissa Zhang12f6a072020-09-30 21:16:0750 apps::mojom::IntentPtr intent,
Melissa Zhang822bfa322021-04-07 00:42:3151 sharesheet::DeliveredCallback delivered_callback);
52#if BUILDFLAG(IS_CHROMEOS_ASH)
Melissa Zhang0b02a3b02021-03-25 04:23:4553 void ShowNearbyShareBubble(apps::mojom::IntentPtr intent,
Melissa Zhang822bfa322021-04-07 00:42:3154 sharesheet::DeliveredCallback delivered_callback);
55#endif // BUILDFLAG(IS_CHROMEOS_ASH)
Jan Wilken Dörriedec99122021-03-11 18:02:3056 void OnBubbleClosed(const std::u16string& active_action);
57 void OnTargetSelected(const std::u16string& target_name,
Melissa Zhangf55c7502020-07-21 12:36:0558 const TargetType type,
Melissa Zhang59ca374f2020-07-22 05:55:5159 apps::mojom::IntentPtr intent,
Melissa Zhangf55c7502020-07-21 12:36:0560 views::View* share_action_view);
Melissa Zhangc6105cc2021-03-16 05:19:4361 bool OnAcceleratorPressed(const ui::Accelerator& accelerator,
62 const std::u16string& active_action);
Melissa Zhangf55c7502020-07-21 12:36:0563 void OnActionLaunched();
Jan Wilken Dörriedec99122021-03-11 18:02:3064 const gfx::VectorIcon* GetVectorIcon(const std::u16string& display_name);
Melissa Zhang26c16932020-12-11 05:15:2365 gfx::NativeWindow GetNativeWindow();
Melissa Zhang93826e692020-07-14 04:39:0266
67 // SharesheetController overrides
Melissa Zhang575490a2020-08-31 07:14:4068 Profile* GetProfile() override;
Melissa Zhang0f75f3b2020-08-19 05:24:2669 void SetSharesheetSize(const int& width, const int& height) override;
Melissa Zhangd1a8ba92020-08-07 00:32:4970 void CloseSharesheet() override;
Melissa Zhangdb4dffa2020-07-01 04:03:1171
72 private:
Melissa Zhang26c16932020-12-11 05:15:2373 bool is_bubble_open_ = false;
74
75 // Only used for ID purposes. NativeWindow will always outlive the
76 // SharesheetServiceDelegate.
77 gfx::NativeWindow native_window_;
78
Jan Wilken Dörriedec99122021-03-11 18:02:3079 std::u16string active_action_;
Melissa Zhang4fd3f9e2021-04-15 01:13:0880 std::unique_ptr<ash::sharesheet::SharesheetBubbleView>
81 sharesheet_bubble_view_;
Melissa Zhang93826e692020-07-14 04:39:0282 SharesheetService* sharesheet_service_;
Melissa Zhangdb4dffa2020-07-01 04:03:1183};
84
85} // namespace sharesheet
86
87#endif // CHROME_BROWSER_SHARESHEET_SHARESHEET_SERVICE_DELEGATE_H_