| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "ui/gfx/image/image_skia.h" | 11 #include "ui/gfx/image/image_skia.h" |
| 12 #include "ui/gfx/vector_icons_public.h" | |
| 13 #include "ui/views/animation/ink_drop_host_view.h" | 12 #include "ui/views/animation/ink_drop_host_view.h" |
| 14 #include "ui/views/controls/image_view.h" | 13 #include "ui/views/controls/image_view.h" |
| 15 #include "ui/views/widget/widget_observer.h" | 14 #include "ui/views/widget/widget_observer.h" |
| 16 | 15 |
| 17 class CommandUpdater; | 16 class CommandUpdater; |
| 18 | 17 |
| 19 namespace gfx { | 18 namespace gfx { |
| 20 enum class VectorIconId; | 19 struct VectorIcon; |
| 21 } | 20 } |
| 22 | 21 |
| 23 namespace views { | 22 namespace views { |
| 24 class BubbleDialogDelegateView; | 23 class BubbleDialogDelegateView; |
| 25 } | 24 } |
| 26 | 25 |
| 27 // Represents an icon on the omnibox that shows a bubble when clicked. | 26 // Represents an icon on the omnibox that shows a bubble when clicked. |
| 28 class BubbleIconView : public views::InkDropHostView, | 27 class BubbleIconView : public views::InkDropHostView, |
| 29 public views::WidgetObserver { | 28 public views::WidgetObserver { |
| 29 public: |
| 30 void Init(); |
| 31 |
| 30 protected: | 32 protected: |
| 31 enum ExecuteSource { | 33 enum ExecuteSource { |
| 32 EXECUTE_SOURCE_MOUSE, | 34 EXECUTE_SOURCE_MOUSE, |
| 33 EXECUTE_SOURCE_KEYBOARD, | 35 EXECUTE_SOURCE_KEYBOARD, |
| 34 EXECUTE_SOURCE_GESTURE, | 36 EXECUTE_SOURCE_GESTURE, |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 BubbleIconView(CommandUpdater* command_updater, int command_id); | 39 BubbleIconView(CommandUpdater* command_updater, int command_id); |
| 38 ~BubbleIconView() override; | 40 ~BubbleIconView() override; |
| 39 | 41 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | 84 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; |
| 83 | 85 |
| 84 protected: | 86 protected: |
| 85 // Calls OnExecuting and runs |command_id_| with a valid |command_updater_|. | 87 // Calls OnExecuting and runs |command_id_| with a valid |command_updater_|. |
| 86 virtual void ExecuteCommand(ExecuteSource source); | 88 virtual void ExecuteCommand(ExecuteSource source); |
| 87 | 89 |
| 88 // Returns the bubble instance for the icon. | 90 // Returns the bubble instance for the icon. |
| 89 virtual views::BubbleDialogDelegateView* GetBubble() const = 0; | 91 virtual views::BubbleDialogDelegateView* GetBubble() const = 0; |
| 90 | 92 |
| 91 // Gets the given vector icon in the correct color and size based on |active|. | 93 // Gets the given vector icon in the correct color and size based on |active|. |
| 92 virtual gfx::VectorIconId GetVectorIcon() const; | 94 virtual const gfx::VectorIcon& GetVectorIcon() const = 0; |
| 93 | 95 |
| 94 // views::View: | 96 // views::View: |
| 95 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 97 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 96 | 98 |
| 97 // Updates the icon after some state has changed. | 99 // Updates the icon after some state has changed. |
| 98 void UpdateIcon(); | 100 void UpdateIcon(); |
| 99 | 101 |
| 100 // Sets the active state of the icon. An active icon will be displayed in a | 102 // Sets the active state of the icon. An active icon will be displayed in a |
| 101 // "call to action" color. | 103 // "call to action" color. |
| 102 void SetActiveInternal(bool active); | 104 void SetActiveInternal(bool active); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 120 | 122 |
| 121 // This is used to check if the bookmark bubble was showing during the mouse | 123 // This is used to check if the bookmark bubble was showing during the mouse |
| 122 // pressed event. If this is true then the mouse released event is ignored to | 124 // pressed event. If this is true then the mouse released event is ignored to |
| 123 // prevent the bubble from reshowing. | 125 // prevent the bubble from reshowing. |
| 124 bool suppress_mouse_released_action_; | 126 bool suppress_mouse_released_action_; |
| 125 | 127 |
| 126 DISALLOW_COPY_AND_ASSIGN(BubbleIconView); | 128 DISALLOW_COPY_AND_ASSIGN(BubbleIconView); |
| 127 }; | 129 }; |
| 128 | 130 |
| 129 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ | 131 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_BUBBLE_ICON_VIEW_H_ |
| OLD | NEW |