1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_SHARING_HUB_SHARING_HUB_BUBBLE_CONTROLLER_CHROMEOS_IMPL_H_
#define CHROME_BROWSER_UI_SHARING_HUB_SHARING_HUB_BUBBLE_CONTROLLER_CHROMEOS_IMPL_H_
#include "base/memory/weak_ptr.h"
#include "chrome/browser/sharesheet/sharesheet_types.h"
#include "chrome/browser/ui/sharing_hub/sharing_hub_bubble_controller.h"
#include "chromeos/components/sharesheet/constants.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "ui/views/native_window_tracker.h"
#include "ui/views/view_tracker.h"
#include "ui/views/widget/widget.h"
class Profile;
namespace content {
class WebContents;
} // namespace content
namespace views {
class Button;
} // namespace views
namespace sharesheet {
class SharesheetService;
} // namespace sharesheet
namespace sharing_hub {
class SharingHubBubbleView;
// Controller component of the omnibox entry point for the Sharesheet dialog.
// Responsible for showing and hiding the Sharesheet.
class SharingHubBubbleControllerChromeOsImpl final
: public SharingHubBubbleController,
public content::WebContentsObserver,
public content::WebContentsUserData<
SharingHubBubbleControllerChromeOsImpl> {
public:
SharingHubBubbleControllerChromeOsImpl(
const SharingHubBubbleControllerChromeOsImpl&) = delete;
SharingHubBubbleControllerChromeOsImpl& operator=(
const SharingHubBubbleControllerChromeOsImpl&) = delete;
~SharingHubBubbleControllerChromeOsImpl() override;
// SharingHubBubbleController:
void HideBubble() override;
void ShowBubble(share::ShareAttempt attempt) override;
SharingHubBubbleView* sharing_hub_bubble_view() const override;
bool ShouldOfferOmniboxIcon() override;
// Returns the current profile.
Profile* GetProfile() const;
// content::WebContentsObserver:
void OnVisibilityChanged(content::Visibility visibility) override;
protected:
explicit SharingHubBubbleControllerChromeOsImpl(
content::WebContents* web_contents);
private:
friend class content::WebContentsUserData<
SharingHubBubbleControllerChromeOsImpl>;
void ShowSharesheet(views::Button* highlighted_button);
void CloseSharesheet();
sharesheet::SharesheetService* GetSharesheetService();
void ShowSharesheetAsh();
void CloseSharesheetAsh();
void OnSharesheetClosed(views::Widget::ClosedReason reason);
void DeselectIcon();
views::ViewTracker highlighted_button_tracker_;
gfx::NativeWindow parent_window_ = gfx::NativeWindow();
std::unique_ptr<views::NativeWindowTracker> parent_window_tracker_ = nullptr;
bool bubble_showing_ = false;
base::WeakPtrFactory<SharingHubBubbleControllerChromeOsImpl>
weak_ptr_factory_{this};
WEB_CONTENTS_USER_DATA_KEY_DECL();
};
} // namespace sharing_hub
#endif // CHROME_BROWSER_UI_SHARING_HUB_SHARING_HUB_BUBBLE_CONTROLLER_CHROMEOS_IMPL_H_
|