blob: 7715c118a096b8552ced55190a6960895fb1afba [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 Zhang93826e692020-07-14 04:39:0215class SharesheetBubbleView;
Melissa Zhangdb4dffa2020-07-01 04:03:1116
17namespace views {
18class View;
19}
20
Maggie Cai69305332020-08-04 23:28:2621namespace content {
22class WebContents;
23}
24
Melissa Zhangdb4dffa2020-07-01 04:03:1125namespace sharesheet {
26
27class SharesheetService;
28
Melissa Zhang93826e692020-07-14 04:39:0229// The SharesheetServiceDelegate is the middle point between the UI and the
30// business logic in the sharesheet.
31class SharesheetServiceDelegate : public SharesheetController {
Melissa Zhangdb4dffa2020-07-01 04:03:1132 public:
Maggie Cai69305332020-08-04 23:28:2633 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 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,
45 apps::mojom::IntentPtr intent);
Melissa Zhangf55c7502020-07-21 12:36:0546 void OnBubbleClosed(const base::string16& active_action);
47 void OnTargetSelected(const base::string16& target_name,
48 const TargetType type,
Melissa Zhang59ca374f2020-07-22 05:55:5149 apps::mojom::IntentPtr intent,
Melissa Zhangf55c7502020-07-21 12:36:0550 views::View* share_action_view);
51 void OnActionLaunched();
Melissa Zhang93826e692020-07-14 04:39:0252
53 // SharesheetController overrides
Melissa Zhangb330e5ab82020-07-21 05:51:3654 uint32_t GetId() override;
Melissa Zhang93826e692020-07-14 04:39:0255 void ShareActionCompleted() override;
Melissa Zhangdb4dffa2020-07-01 04:03:1156
57 private:
Melissa Zhangb330e5ab82020-07-21 05:51:3658 const uint32_t id_;
Melissa Zhangf55c7502020-07-21 12:36:0559 base::string16 active_action_;
Melissa Zhangdb4dffa2020-07-01 04:03:1160 std::unique_ptr<SharesheetBubbleView> sharesheet_bubble_view_;
Melissa Zhang93826e692020-07-14 04:39:0261 SharesheetService* sharesheet_service_;
Melissa Zhangdb4dffa2020-07-01 04:03:1162};
63
64} // namespace sharesheet
65
66#endif // CHROME_BROWSER_SHARESHEET_SHARESHEET_SERVICE_DELEGATE_H_