blob: 6974dba9d956a48c98132eedc25691b3d03cc359 [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 Zhang93826e692020-07-14 04:39:0219class SharesheetBubbleView;
Melissa Zhangdb4dffa2020-07-01 04:03:1120
21namespace views {
22class View;
23}
24
Melissa Zhanga8a835f2020-11-05 05:02:4625namespace gfx {
26struct VectorIcon;
27}
28
Melissa Zhangdb4dffa2020-07-01 04:03:1129namespace sharesheet {
30
31class SharesheetService;
32
Melissa Zhang93826e692020-07-14 04:39:0233// The SharesheetServiceDelegate is the middle point between the UI and the
34// business logic in the sharesheet.
35class SharesheetServiceDelegate : public SharesheetController {
Melissa Zhangdb4dffa2020-07-01 04:03:1136 public:
Melissa Zhang26c16932020-12-11 05:15:2337 SharesheetServiceDelegate(gfx::NativeWindow native_window,
Maggie Cai69305332020-08-04 23:28:2638 SharesheetService* sharesheet_service);
Melissa Zhang93826e692020-07-14 04:39:0239 ~SharesheetServiceDelegate() override;
Melissa Zhangdb4dffa2020-07-01 04:03:1140 SharesheetServiceDelegate(const SharesheetServiceDelegate&) = delete;
41 SharesheetServiceDelegate& operator=(const SharesheetServiceDelegate&) =
42 delete;
43
Melissa Zhang59ca374f2020-07-22 05:55:5144 void ShowBubble(std::vector<TargetInfo> targets,
Melissa Zhang12f6a072020-09-30 21:16:0745 apps::mojom::IntentPtr intent,
46 sharesheet::CloseCallback close_callback);
Jan Wilken Dörriedec99122021-03-11 18:02:3047 void OnBubbleClosed(const std::u16string& active_action);
48 void OnTargetSelected(const std::u16string& target_name,
Melissa Zhangf55c7502020-07-21 12:36:0549 const TargetType type,
Melissa Zhang59ca374f2020-07-22 05:55:5150 apps::mojom::IntentPtr intent,
Melissa Zhangf55c7502020-07-21 12:36:0551 views::View* share_action_view);
Melissa Zhangc6105cc2021-03-16 05:19:4352 bool OnAcceleratorPressed(const ui::Accelerator& accelerator,
53 const std::u16string& active_action);
Melissa Zhangf55c7502020-07-21 12:36:0554 void OnActionLaunched();
Jan Wilken Dörriedec99122021-03-11 18:02:3055 const gfx::VectorIcon* GetVectorIcon(const std::u16string& display_name);
Melissa Zhang26c16932020-12-11 05:15:2356 gfx::NativeWindow GetNativeWindow();
Melissa Zhang93826e692020-07-14 04:39:0257
58 // SharesheetController overrides
Melissa Zhang575490a2020-08-31 07:14:4059 Profile* GetProfile() override;
Melissa Zhang0f75f3b2020-08-19 05:24:2660 void SetSharesheetSize(const int& width, const int& height) override;
Melissa Zhangd1a8ba92020-08-07 00:32:4961 void CloseSharesheet() override;
Melissa Zhangdb4dffa2020-07-01 04:03:1162
63 private:
Melissa Zhang26c16932020-12-11 05:15:2364 bool is_bubble_open_ = false;
65
66 // Only used for ID purposes. NativeWindow will always outlive the
67 // SharesheetServiceDelegate.
68 gfx::NativeWindow native_window_;
69
Jan Wilken Dörriedec99122021-03-11 18:02:3070 std::u16string active_action_;
Melissa Zhangdb4dffa2020-07-01 04:03:1171 std::unique_ptr<SharesheetBubbleView> sharesheet_bubble_view_;
Melissa Zhang93826e692020-07-14 04:39:0272 SharesheetService* sharesheet_service_;
Melissa Zhangdb4dffa2020-07-01 04:03:1173};
74
75} // namespace sharesheet
76
77#endif // CHROME_BROWSER_SHARESHEET_SHARESHEET_SERVICE_DELEGATE_H_