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