blob: cba3392d1057c49f8d219f0a46d4a42bfd0ea377 [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,
Melissa Zhang822bfa322021-04-07 00:42:3146 sharesheet::DeliveredCallback delivered_callback);
47#if BUILDFLAG(IS_CHROMEOS_ASH)
Melissa Zhang0b02a3b02021-03-25 04:23:4548 void ShowNearbyShareBubble(apps::mojom::IntentPtr intent,
Melissa Zhang822bfa322021-04-07 00:42:3149 sharesheet::DeliveredCallback delivered_callback);
50#endif // BUILDFLAG(IS_CHROMEOS_ASH)
Jan Wilken Dörriedec99122021-03-11 18:02:3051 void OnBubbleClosed(const std::u16string& active_action);
52 void OnTargetSelected(const std::u16string& target_name,
Melissa Zhangf55c7502020-07-21 12:36:0553 const TargetType type,
Melissa Zhang59ca374f2020-07-22 05:55:5154 apps::mojom::IntentPtr intent,
Melissa Zhangf55c7502020-07-21 12:36:0555 views::View* share_action_view);
Melissa Zhangc6105cc2021-03-16 05:19:4356 bool OnAcceleratorPressed(const ui::Accelerator& accelerator,
57 const std::u16string& active_action);
Melissa Zhangf55c7502020-07-21 12:36:0558 void OnActionLaunched();
Jan Wilken Dörriedec99122021-03-11 18:02:3059 const gfx::VectorIcon* GetVectorIcon(const std::u16string& display_name);
Melissa Zhang26c16932020-12-11 05:15:2360 gfx::NativeWindow GetNativeWindow();
Melissa Zhang93826e692020-07-14 04:39:0261
62 // SharesheetController overrides
Melissa Zhang575490a2020-08-31 07:14:4063 Profile* GetProfile() override;
Melissa Zhang0f75f3b2020-08-19 05:24:2664 void SetSharesheetSize(const int& width, const int& height) override;
Melissa Zhangd1a8ba92020-08-07 00:32:4965 void CloseSharesheet() override;
Melissa Zhangdb4dffa2020-07-01 04:03:1166
67 private:
Melissa Zhang26c16932020-12-11 05:15:2368 bool is_bubble_open_ = false;
69
70 // Only used for ID purposes. NativeWindow will always outlive the
71 // SharesheetServiceDelegate.
72 gfx::NativeWindow native_window_;
73
Jan Wilken Dörriedec99122021-03-11 18:02:3074 std::u16string active_action_;
Melissa Zhangdb4dffa2020-07-01 04:03:1175 std::unique_ptr<SharesheetBubbleView> sharesheet_bubble_view_;
Melissa Zhang93826e692020-07-14 04:39:0276 SharesheetService* sharesheet_service_;
Melissa Zhangdb4dffa2020-07-01 04:03:1177};
78
79} // namespace sharesheet
80
81#endif // CHROME_BROWSER_SHARESHEET_SHARESHEET_SERVICE_DELEGATE_H_