Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1088)

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_action_view.h

Issue 888043003: [Extensions Toolbar Views] Add a ToolbarActionView unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_
7 7
8 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h" 8 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h"
9 #include "content/public/browser/notification_observer.h" 9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h" 10 #include "content/public/browser/notification_registrar.h"
11 #include "ui/views/controls/button/menu_button.h" 11 #include "ui/views/controls/button/menu_button.h"
12 #include "ui/views/controls/button/menu_button_listener.h" 12 #include "ui/views/controls/button/menu_button_listener.h"
13 #include "ui/views/drag_controller.h" 13 #include "ui/views/drag_controller.h"
14 #include "ui/views/view.h" 14 #include "ui/views/view.h"
15 15
16 class Browser;
17 class ExtensionAction; 16 class ExtensionAction;
17 class Profile;
18 18
19 namespace extensions { 19 namespace extensions {
20 class Extension; 20 class Extension;
21 } 21 }
22 22
23 namespace gfx { 23 namespace gfx {
24 class Image; 24 class Image;
25 } 25 }
26 26
27 //////////////////////////////////////////////////////////////////////////////// 27 ////////////////////////////////////////////////////////////////////////////////
(...skipping 28 matching lines...) Expand all
56 // Returns the primary ToolbarActionView associated with the given 56 // Returns the primary ToolbarActionView associated with the given
57 // |extension|. 57 // |extension|.
58 virtual ToolbarActionView* GetMainViewForAction( 58 virtual ToolbarActionView* GetMainViewForAction(
59 ToolbarActionView* view) = 0; 59 ToolbarActionView* view) = 0;
60 60
61 protected: 61 protected:
62 ~Delegate() override {} 62 ~Delegate() override {}
63 }; 63 };
64 64
65 ToolbarActionView(ToolbarActionViewController* view_controller, 65 ToolbarActionView(ToolbarActionViewController* view_controller,
66 Browser* browser, 66 Profile* profile,
67 Delegate* delegate); 67 Delegate* delegate);
68 ~ToolbarActionView() override; 68 ~ToolbarActionView() override;
69 69
70 // Modifies the given |border| in order to display a "popped out" for when 70 // Modifies the given |border| in order to display a "popped out" for when
71 // an action wants to run. 71 // an action wants to run.
72 static void DecorateWantsToRunBorder(views::LabelButtonBorder* border); 72 static void DecorateWantsToRunBorder(views::LabelButtonBorder* border);
73 73
74 // views::MenuButton: 74 // views::MenuButton:
75 void GetAccessibleState(ui::AXViewState* state) override; 75 void GetAccessibleState(ui::AXViewState* state) override;
76 76
(...skipping 18 matching lines...) Expand all
95 void OnGestureEvent(ui::GestureEvent* event) override; 95 void OnGestureEvent(ui::GestureEvent* event) override;
96 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; 96 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override;
97 97
98 // ToolbarActionViewDelegate: (public because called by others). 98 // ToolbarActionViewDelegate: (public because called by others).
99 void UpdateState() override; 99 void UpdateState() override;
100 content::WebContents* GetCurrentWebContents() const override; 100 content::WebContents* GetCurrentWebContents() const override;
101 101
102 ToolbarActionViewController* view_controller() { 102 ToolbarActionViewController* view_controller() {
103 return view_controller_; 103 return view_controller_;
104 } 104 }
105 Browser* browser() { return browser_; }
106 105
107 // Returns button icon so it can be accessed during tests. 106 // Returns button icon so it can be accessed during tests.
108 gfx::ImageSkia GetIconForTest(); 107 gfx::ImageSkia GetIconForTest();
109 108
110 bool wants_to_run_for_testing() const { return wants_to_run_; } 109 bool wants_to_run_for_testing() const { return wants_to_run_; }
111 110
112 private: 111 private:
113 // views::MenuButton: 112 // views::MenuButton:
114 gfx::Size GetPreferredSize() const override; 113 gfx::Size GetPreferredSize() const override;
115 const char* GetClassName() const override; 114 const char* GetClassName() const override;
(...skipping 14 matching lines...) Expand all
130 views::MenuButton* GetContextMenuButton() override; 129 views::MenuButton* GetContextMenuButton() override;
131 void OnPopupShown(bool by_user) override; 130 void OnPopupShown(bool by_user) override;
132 void OnPopupClosed() override; 131 void OnPopupClosed() override;
133 132
134 // A lock to keep the MenuButton pressed when a menu or popup is visible. 133 // A lock to keep the MenuButton pressed when a menu or popup is visible.
135 scoped_ptr<views::MenuButton::PressedLock> pressed_lock_; 134 scoped_ptr<views::MenuButton::PressedLock> pressed_lock_;
136 135
137 // The controller for this toolbar action view. 136 // The controller for this toolbar action view.
138 ToolbarActionViewController* view_controller_; 137 ToolbarActionViewController* view_controller_;
139 138
140 // The associated browser. 139 // The associated profile.
141 Browser* browser_; 140 Profile* profile_;
142 141
143 // Delegate that usually represents a container for ToolbarActionView. 142 // Delegate that usually represents a container for ToolbarActionView.
144 Delegate* delegate_; 143 Delegate* delegate_;
145 144
146 // Used to make sure we only register the command once. 145 // Used to make sure we only register the command once.
147 bool called_register_command_; 146 bool called_register_command_;
148 147
149 // The cached value of whether or not the action wants to run on the current 148 // The cached value of whether or not the action wants to run on the current
150 // tab. 149 // tab.
151 bool wants_to_run_; 150 bool wants_to_run_;
152 151
153 // A special border to draw when the action wants to run. 152 // A special border to draw when the action wants to run.
154 scoped_ptr<views::LabelButtonBorder> wants_to_run_border_; 153 scoped_ptr<views::LabelButtonBorder> wants_to_run_border_;
155 154
156 content::NotificationRegistrar registrar_; 155 content::NotificationRegistrar registrar_;
157 156
158 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView); 157 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView);
159 }; 158 };
160 159
161 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ 160 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/chevron_menu_button.cc ('k') | chrome/browser/ui/views/toolbar/toolbar_action_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698