blob: 1641a9e3988ac1bc2f355c7d050220fd90b649ab [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>
9
Melissa Zhangf55c7502020-07-21 12:36:0510#include "base/strings/string16.h"
Melissa Zhang93826e692020-07-14 04:39:0211#include "chrome/browser/sharesheet/sharesheet_controller.h"
Melissa Zhangb330e5ab82020-07-21 05:51:3612#include "chrome/browser/sharesheet/sharesheet_types.h"
Melissa Zhang59ca374f2020-07-22 05:55:5113#include "components/services/app_service/public/mojom/types.mojom.h"
Melissa Zhangdb4dffa2020-07-01 04:03:1114
Melissa Zhang575490a2020-08-31 07:14:4015class Profile;
Melissa Zhang93826e692020-07-14 04:39:0216class SharesheetBubbleView;
Melissa Zhangdb4dffa2020-07-01 04:03:1117
18namespace views {
19class View;
20}
21
Maggie Cai69305332020-08-04 23:28:2622namespace content {
23class WebContents;
24}
25
Melissa Zhangdb4dffa2020-07-01 04:03:1126namespace sharesheet {
27
28class SharesheetService;
29
Melissa Zhang93826e692020-07-14 04:39:0230// The SharesheetServiceDelegate is the middle point between the UI and the
31// business logic in the sharesheet.
32class SharesheetServiceDelegate : public SharesheetController {
Melissa Zhangdb4dffa2020-07-01 04:03:1133 public:
Maggie Cai69305332020-08-04 23:28:2634 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 Zhang93826e692020-07-14 04:39:0240 ~SharesheetServiceDelegate() override;
Melissa Zhangdb4dffa2020-07-01 04:03:1141 SharesheetServiceDelegate(const SharesheetServiceDelegate&) = delete;
42 SharesheetServiceDelegate& operator=(const SharesheetServiceDelegate&) =
43 delete;
44
Melissa Zhang59ca374f2020-07-22 05:55:5145 void ShowBubble(std::vector<TargetInfo> targets,
46 apps::mojom::IntentPtr intent);
Melissa Zhangf55c7502020-07-21 12:36:0547 void OnBubbleClosed(const base::string16& active_action);
48 void OnTargetSelected(const base::string16& target_name,
49 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);
52 void OnActionLaunched();
Melissa Zhang93826e692020-07-14 04:39:0253
54 // SharesheetController overrides
Melissa Zhangb330e5ab82020-07-21 05:51:3655 uint32_t GetId() override;
Melissa Zhang575490a2020-08-31 07:14:4056 Profile* GetProfile() override;
Melissa Zhang0f75f3b2020-08-19 05:24:2657 void SetSharesheetSize(const int& width, const int& height) override;
Melissa Zhangd1a8ba92020-08-07 00:32:4958 void CloseSharesheet() override;
Melissa Zhangdb4dffa2020-07-01 04:03:1159
60 private:
Melissa Zhangb330e5ab82020-07-21 05:51:3661 const uint32_t id_;
Melissa Zhangf55c7502020-07-21 12:36:0562 base::string16 active_action_;
Melissa Zhangdb4dffa2020-07-01 04:03:1163 std::unique_ptr<SharesheetBubbleView> sharesheet_bubble_view_;
Melissa Zhang93826e692020-07-14 04:39:0264 SharesheetService* sharesheet_service_;
Melissa Zhangdb4dffa2020-07-01 04:03:1165};
66
67} // namespace sharesheet
68
69#endif // CHROME_BROWSER_SHARESHEET_SHARESHEET_SERVICE_DELEGATE_H_