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