Melissa Zhang | db4dffa | 2020-07-01 04:03:11 | [diff] [blame] | 1 | // 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> |
| 9 | |
Melissa Zhang | 12f6a07 | 2020-09-30 21:16:07 | [diff] [blame] | 10 | #include "base/callback.h" |
Melissa Zhang | f55c750 | 2020-07-21 12:36:05 | [diff] [blame] | 11 | #include "base/strings/string16.h" |
Melissa Zhang | 93826e69 | 2020-07-14 04:39:02 | [diff] [blame] | 12 | #include "chrome/browser/sharesheet/sharesheet_controller.h" |
Melissa Zhang | b330e5ab8 | 2020-07-21 05:51:36 | [diff] [blame] | 13 | #include "chrome/browser/sharesheet/sharesheet_types.h" |
Melissa Zhang | 59ca374f | 2020-07-22 05:55:51 | [diff] [blame] | 14 | #include "components/services/app_service/public/mojom/types.mojom.h" |
Melissa Zhang | db4dffa | 2020-07-01 04:03:11 | [diff] [blame] | 15 | |
Melissa Zhang | 575490a | 2020-08-31 07:14:40 | [diff] [blame] | 16 | class Profile; |
Melissa Zhang | 93826e69 | 2020-07-14 04:39:02 | [diff] [blame] | 17 | class SharesheetBubbleView; |
Melissa Zhang | db4dffa | 2020-07-01 04:03:11 | [diff] [blame] | 18 | |
| 19 | namespace views { |
| 20 | class View; |
| 21 | } |
| 22 | |
Maggie Cai | 6930533 | 2020-08-04 23:28:26 | [diff] [blame] | 23 | namespace content { |
| 24 | class WebContents; |
| 25 | } |
| 26 | |
Melissa Zhang | a8a835f | 2020-11-05 05:02:46 | [diff] [blame^] | 27 | namespace gfx { |
| 28 | struct VectorIcon; |
| 29 | } |
| 30 | |
Melissa Zhang | db4dffa | 2020-07-01 04:03:11 | [diff] [blame] | 31 | namespace sharesheet { |
| 32 | |
| 33 | class SharesheetService; |
| 34 | |
Melissa Zhang | 93826e69 | 2020-07-14 04:39:02 | [diff] [blame] | 35 | // The SharesheetServiceDelegate is the middle point between the UI and the |
| 36 | // business logic in the sharesheet. |
| 37 | class SharesheetServiceDelegate : public SharesheetController { |
Melissa Zhang | db4dffa | 2020-07-01 04:03:11 | [diff] [blame] | 38 | public: |
Maggie Cai | 6930533 | 2020-08-04 23:28:26 | [diff] [blame] | 39 | SharesheetServiceDelegate(uint32_t id, |
Maggie Cai | 6930533 | 2020-08-04 23:28:26 | [diff] [blame] | 40 | content::WebContents* web_contents, |
| 41 | SharesheetService* sharesheet_service); |
Melissa Zhang | 93826e69 | 2020-07-14 04:39:02 | [diff] [blame] | 42 | ~SharesheetServiceDelegate() override; |
Melissa Zhang | db4dffa | 2020-07-01 04:03:11 | [diff] [blame] | 43 | SharesheetServiceDelegate(const SharesheetServiceDelegate&) = delete; |
| 44 | SharesheetServiceDelegate& operator=(const SharesheetServiceDelegate&) = |
| 45 | delete; |
| 46 | |
Melissa Zhang | 59ca374f | 2020-07-22 05:55:51 | [diff] [blame] | 47 | void ShowBubble(std::vector<TargetInfo> targets, |
Melissa Zhang | 12f6a07 | 2020-09-30 21:16:07 | [diff] [blame] | 48 | apps::mojom::IntentPtr intent, |
| 49 | sharesheet::CloseCallback close_callback); |
Melissa Zhang | f55c750 | 2020-07-21 12:36:05 | [diff] [blame] | 50 | void OnBubbleClosed(const base::string16& active_action); |
| 51 | void OnTargetSelected(const base::string16& target_name, |
| 52 | const TargetType type, |
Melissa Zhang | 59ca374f | 2020-07-22 05:55:51 | [diff] [blame] | 53 | apps::mojom::IntentPtr intent, |
Melissa Zhang | f55c750 | 2020-07-21 12:36:05 | [diff] [blame] | 54 | views::View* share_action_view); |
| 55 | void OnActionLaunched(); |
Melissa Zhang | a8a835f | 2020-11-05 05:02:46 | [diff] [blame^] | 56 | const gfx::VectorIcon* GetVectorIcon(const base::string16& display_name); |
Melissa Zhang | 93826e69 | 2020-07-14 04:39:02 | [diff] [blame] | 57 | |
| 58 | // SharesheetController overrides |
Melissa Zhang | b330e5ab8 | 2020-07-21 05:51:36 | [diff] [blame] | 59 | uint32_t GetId() override; |
Melissa Zhang | 575490a | 2020-08-31 07:14:40 | [diff] [blame] | 60 | Profile* GetProfile() override; |
Melissa Zhang | 0f75f3b | 2020-08-19 05:24:26 | [diff] [blame] | 61 | void SetSharesheetSize(const int& width, const int& height) override; |
Melissa Zhang | d1a8ba9 | 2020-08-07 00:32:49 | [diff] [blame] | 62 | void CloseSharesheet() override; |
Melissa Zhang | db4dffa | 2020-07-01 04:03:11 | [diff] [blame] | 63 | |
| 64 | private: |
Melissa Zhang | b330e5ab8 | 2020-07-21 05:51:36 | [diff] [blame] | 65 | const uint32_t id_; |
Melissa Zhang | f55c750 | 2020-07-21 12:36:05 | [diff] [blame] | 66 | base::string16 active_action_; |
Melissa Zhang | db4dffa | 2020-07-01 04:03:11 | [diff] [blame] | 67 | std::unique_ptr<SharesheetBubbleView> sharesheet_bubble_view_; |
Melissa Zhang | 93826e69 | 2020-07-14 04:39:02 | [diff] [blame] | 68 | SharesheetService* sharesheet_service_; |
Melissa Zhang | db4dffa | 2020-07-01 04:03:11 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | } // namespace sharesheet |
| 72 | |
| 73 | #endif // CHROME_BROWSER_SHARESHEET_SHARESHEET_SERVICE_DELEGATE_H_ |