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
|
// Copyright 2013 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_VIEWS_TOOLBAR_HOME_BUTTON_H_
#define CHROME_BROWSER_UI_VIEWS_TOOLBAR_HOME_BUTTON_H_
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/views/metadata/view_factory.h"
#include "ui/views/view_tracker.h"
class BrowserWindowInterface;
class PrefService;
class HomePageUndoBubbleCoordinator {
public:
HomePageUndoBubbleCoordinator(views::View* anchor_view, PrefService* prefs);
HomePageUndoBubbleCoordinator(const HomePageUndoBubbleCoordinator&) = delete;
HomePageUndoBubbleCoordinator& operator=(
const HomePageUndoBubbleCoordinator&) = delete;
~HomePageUndoBubbleCoordinator();
void Show(const GURL& undo_url, bool undo_value_is_ntp);
private:
const raw_ptr<views::View> anchor_view_;
const raw_ptr<PrefService> prefs_;
views::ViewTracker tracker_;
};
class HomeButton : public ToolbarButton {
METADATA_HEADER(HomeButton, ToolbarButton)
public:
explicit HomeButton(BrowserWindowInterface* browser_window_interface,
PressedCallback callback);
HomeButton(const HomeButton&) = delete;
HomeButton& operator=(const HomeButton&) = delete;
~HomeButton() override;
// ToolbarButton:
bool GetDropFormats(int* formats,
std::set<ui::ClipboardFormatType>* format_types) override;
bool CanDrop(const OSExchangeData& data) override;
int OnDragUpdated(const ui::DropTargetEvent& event) override;
views::View::DropCallback GetDropCallback(
const ui::DropTargetEvent& event) override;
private:
void UpdateHomePage(
const ui::DropTargetEvent& event,
ui::mojom::DragOperation& output_drag_op,
std::unique_ptr<ui::LayerTreeOwner> drag_image_layer_owner);
const raw_ptr<PrefService> prefs_;
HomePageUndoBubbleCoordinator coordinator_;
base::WeakPtrFactory<HomeButton> weak_ptr_factory_{this};
};
BEGIN_VIEW_BUILDER(/* no export */, HomeButton, ToolbarButton)
END_VIEW_BUILDER
DEFINE_VIEW_BUILDER(/* no export */, HomeButton)
#endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_HOME_BUTTON_H_
|