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 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" | 5 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 namespace { | 37 namespace { |
38 | 38 |
39 // We have smaller insets than normal STYLE_TEXTBUTTON buttons so that we can | 39 // We have smaller insets than normal STYLE_TEXTBUTTON buttons so that we can |
40 // fit user supplied icons in without clipping them. | 40 // fit user supplied icons in without clipping them. |
41 const int kBorderInset = 4; | 41 const int kBorderInset = 4; |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 //////////////////////////////////////////////////////////////////////////////// | 45 //////////////////////////////////////////////////////////////////////////////// |
46 // BrowserActionView | 46 // BrowserActionView |
47 | |
48 BrowserActionView::BrowserActionView(const Extension* extension, | 47 BrowserActionView::BrowserActionView(const Extension* extension, |
49 Browser* browser, | 48 Browser* browser, |
50 BrowserActionView::Delegate* delegate) | 49 BrowserActionView::Delegate* delegate) |
51 : delegate_(delegate) { | |
52 set_id(VIEW_ID_BROWSER_ACTION); | |
53 button_.reset(new BrowserActionButton(extension, browser, delegate_)); | |
54 button_->set_drag_controller(delegate_); | |
55 button_->set_owned_by_client(); | |
56 AddChildView(button_.get()); | |
57 button_->UpdateState(); | |
58 } | |
59 | |
60 BrowserActionView::~BrowserActionView() { | |
61 } | |
62 | |
63 gfx::ImageSkia BrowserActionView::GetIconWithBadge() { | |
64 return button_->GetIconWithBadge(); | |
65 } | |
66 | |
67 void BrowserActionView::Layout() { | |
68 button_->SetBounds(0, 0, width(), height()); | |
69 } | |
70 | |
71 void BrowserActionView::GetAccessibleState(ui::AXViewState* state) { | |
72 state->name = l10n_util::GetStringUTF16( | |
73 IDS_ACCNAME_EXTENSIONS_BROWSER_ACTION); | |
74 state->role = ui::AX_ROLE_GROUP; | |
75 } | |
76 | |
77 gfx::Size BrowserActionView::GetPreferredSize() const { | |
78 return gfx::Size(BrowserActionsContainer::IconWidth(false), | |
79 BrowserActionsContainer::IconHeight()); | |
80 } | |
81 | |
82 void BrowserActionView::PaintChildren(gfx::Canvas* canvas, | |
83 const views::CullSet& cull_set) { | |
84 View::PaintChildren(canvas, cull_set); | |
85 ExtensionAction* action = button_->extension_action(); | |
86 int tab_id = button_->view_controller()->GetCurrentTabId(); | |
87 if (tab_id >= 0) | |
88 action->PaintBadge(canvas, GetLocalBounds(), tab_id); | |
89 } | |
90 | |
91 //////////////////////////////////////////////////////////////////////////////// | |
92 // BrowserActionButton | |
93 | |
94 BrowserActionButton::BrowserActionButton(const Extension* extension, | |
95 Browser* browser, | |
96 BrowserActionView::Delegate* delegate) | |
97 : MenuButton(this, base::string16(), NULL, false), | 50 : MenuButton(this, base::string16(), NULL, false), |
98 view_controller_(new ExtensionActionViewController( | 51 view_controller_(new ExtensionActionViewController( |
99 extension, | 52 extension, |
100 browser, | 53 browser, |
101 extensions::ExtensionActionManager::Get(browser->profile())-> | 54 extensions::ExtensionActionManager::Get(browser->profile())-> |
102 GetBrowserAction(*extension), | 55 GetBrowserAction(*extension), |
103 this)), | 56 this)), |
104 delegate_(delegate), | 57 delegate_(delegate), |
105 called_registered_extension_command_(false), | 58 called_registered_extension_command_(false), |
106 icon_observer_(NULL) { | 59 icon_observer_(NULL) { |
| 60 set_id(VIEW_ID_BROWSER_ACTION); |
107 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 61 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
108 set_context_menu_controller(view_controller_.get()); | 62 set_context_menu_controller(view_controller_.get()); |
109 | 63 set_drag_controller(delegate_); |
110 // No UpdateState() here because View hierarchy not setup yet. Our parent | |
111 // should call UpdateState() after creation. | |
112 | 64 |
113 content::NotificationSource notification_source = | 65 content::NotificationSource notification_source = |
114 content::Source<Profile>(browser->profile()->GetOriginalProfile()); | 66 content::Source<Profile>(browser->profile()->GetOriginalProfile()); |
115 registrar_.Add(this, | 67 registrar_.Add(this, |
116 extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, | 68 extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, |
117 content::Source<ExtensionAction>(extension_action())); | 69 content::Source<ExtensionAction>(extension_action())); |
118 registrar_.Add(this, | 70 registrar_.Add(this, |
119 extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED, | 71 extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED, |
120 notification_source); | 72 notification_source); |
121 registrar_.Add(this, | 73 registrar_.Add(this, |
122 extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED, | 74 extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED, |
123 notification_source); | 75 notification_source); |
124 | 76 |
125 // We also listen for browser theme changes on linux because a switch from or | 77 // We also listen for browser theme changes on linux because a switch from or |
126 // to GTK requires that we regrab our browser action images. | 78 // to GTK requires that we regrab our browser action images. |
127 registrar_.Add( | 79 registrar_.Add( |
128 this, | 80 this, |
129 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 81 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
130 content::Source<ThemeService>( | 82 content::Source<ThemeService>( |
131 ThemeServiceFactory::GetForProfile(browser->profile()))); | 83 ThemeServiceFactory::GetForProfile(browser->profile()))); |
| 84 |
| 85 UpdateState(); |
132 } | 86 } |
133 | 87 |
134 void BrowserActionButton::ViewHierarchyChanged( | 88 BrowserActionView::~BrowserActionView() { |
| 89 } |
| 90 |
| 91 void BrowserActionView::ViewHierarchyChanged( |
135 const ViewHierarchyChangedDetails& details) { | 92 const ViewHierarchyChangedDetails& details) { |
136 if (details.is_add && !called_registered_extension_command_ && | 93 if (details.is_add && !called_registered_extension_command_ && |
137 GetFocusManager()) { | 94 GetFocusManager()) { |
138 view_controller_->RegisterCommand(); | 95 view_controller_->RegisterCommand(); |
139 called_registered_extension_command_ = true; | 96 called_registered_extension_command_ = true; |
140 } | 97 } |
141 | 98 |
142 MenuButton::ViewHierarchyChanged(details); | 99 MenuButton::ViewHierarchyChanged(details); |
143 } | 100 } |
144 | 101 |
145 void BrowserActionButton::OnDragDone() { | 102 void BrowserActionView::OnDragDone() { |
146 delegate_->OnBrowserActionViewDragDone(); | 103 delegate_->OnBrowserActionViewDragDone(); |
147 } | 104 } |
148 | 105 |
149 void BrowserActionButton::GetAccessibleState(ui::AXViewState* state) { | 106 gfx::Size BrowserActionView::GetPreferredSize() const { |
| 107 return gfx::Size(BrowserActionsContainer::IconWidth(false), |
| 108 BrowserActionsContainer::IconHeight()); |
| 109 } |
| 110 |
| 111 void BrowserActionView::PaintChildren(gfx::Canvas* canvas, |
| 112 const views::CullSet& cull_set) { |
| 113 View::PaintChildren(canvas, cull_set); |
| 114 int tab_id = view_controller_->GetCurrentTabId(); |
| 115 if (tab_id >= 0) |
| 116 extension_action()->PaintBadge(canvas, GetLocalBounds(), tab_id); |
| 117 } |
| 118 |
| 119 void BrowserActionView::GetAccessibleState(ui::AXViewState* state) { |
150 views::MenuButton::GetAccessibleState(state); | 120 views::MenuButton::GetAccessibleState(state); |
| 121 state->name = l10n_util::GetStringUTF16( |
| 122 IDS_ACCNAME_EXTENSIONS_BROWSER_ACTION); |
151 state->role = ui::AX_ROLE_BUTTON; | 123 state->role = ui::AX_ROLE_BUTTON; |
152 } | 124 } |
153 | 125 |
154 void BrowserActionButton::ButtonPressed(views::Button* sender, | 126 void BrowserActionView::ButtonPressed(views::Button* sender, |
155 const ui::Event& event) { | 127 const ui::Event& event) { |
156 view_controller_->ExecuteActionByUser(); | 128 view_controller_->ExecuteActionByUser(); |
157 } | 129 } |
158 | 130 |
159 void BrowserActionButton::UpdateState() { | 131 void BrowserActionView::UpdateState() { |
160 int tab_id = view_controller_->GetCurrentTabId(); | 132 int tab_id = view_controller_->GetCurrentTabId(); |
161 if (tab_id < 0) | 133 if (tab_id < 0) |
162 return; | 134 return; |
163 | 135 |
164 if (!IsEnabled(tab_id)) { | 136 if (!IsEnabled(tab_id)) { |
165 SetState(views::CustomButton::STATE_DISABLED); | 137 SetState(views::CustomButton::STATE_DISABLED); |
166 } else { | 138 } else { |
167 SetState(menu_visible_ ? | 139 SetState(menu_visible_ ? |
168 views::CustomButton::STATE_PRESSED : | 140 views::CustomButton::STATE_PRESSED : |
169 views::CustomButton::STATE_NORMAL); | 141 views::CustomButton::STATE_NORMAL); |
(...skipping 13 matching lines...) Expand all Loading... |
183 gfx::ImageSkiaOperations::CreateSuperimposedImage(bg, icon)); | 155 gfx::ImageSkiaOperations::CreateSuperimposedImage(bg, icon)); |
184 } | 156 } |
185 | 157 |
186 // If the browser action name is empty, show the extension name instead. | 158 // If the browser action name is empty, show the extension name instead. |
187 std::string title = extension_action()->GetTitle(tab_id); | 159 std::string title = extension_action()->GetTitle(tab_id); |
188 base::string16 name = | 160 base::string16 name = |
189 base::UTF8ToUTF16(title.empty() ? extension()->name() : title); | 161 base::UTF8ToUTF16(title.empty() ? extension()->name() : title); |
190 SetTooltipText(name); | 162 SetTooltipText(name); |
191 SetAccessibleName(name); | 163 SetAccessibleName(name); |
192 | 164 |
193 parent()->SchedulePaint(); | 165 SchedulePaint(); |
194 } | 166 } |
195 | 167 |
196 bool BrowserActionButton::IsPopup() { | 168 bool BrowserActionView::IsPopup() { |
197 int tab_id = view_controller_->GetCurrentTabId(); | 169 int tab_id = view_controller_->GetCurrentTabId(); |
198 return (tab_id < 0) ? false : extension_action()->HasPopup(tab_id); | 170 return (tab_id < 0) ? false : extension_action()->HasPopup(tab_id); |
199 } | 171 } |
200 | 172 |
201 void BrowserActionButton::Observe(int type, | 173 void BrowserActionView::Observe(int type, |
202 const content::NotificationSource& source, | 174 const content::NotificationSource& source, |
203 const content::NotificationDetails& details) { | 175 const content::NotificationDetails& details) { |
204 switch (type) { | 176 switch (type) { |
205 case extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED: | 177 case extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED: |
206 UpdateState(); | 178 UpdateState(); |
207 // The browser action may have become visible/hidden so we need to make | 179 // The browser action may have become visible/hidden so we need to make |
208 // sure the state gets updated. | 180 // sure the state gets updated. |
209 delegate_->OnBrowserActionVisibilityChanged(); | 181 delegate_->OnBrowserActionVisibilityChanged(); |
210 break; | 182 break; |
211 case extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED: | 183 case extensions::NOTIFICATION_EXTENSION_COMMAND_ADDED: |
212 case extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED: { | 184 case extensions::NOTIFICATION_EXTENSION_COMMAND_REMOVED: { |
213 std::pair<const std::string, const std::string>* payload = | 185 std::pair<const std::string, const std::string>* payload = |
(...skipping 11 matching lines...) Expand all Loading... |
225 } | 197 } |
226 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: | 198 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: |
227 UpdateState(); | 199 UpdateState(); |
228 break; | 200 break; |
229 default: | 201 default: |
230 NOTREACHED(); | 202 NOTREACHED(); |
231 break; | 203 break; |
232 } | 204 } |
233 } | 205 } |
234 | 206 |
235 bool BrowserActionButton::Activate() { | 207 bool BrowserActionView::Activate() { |
236 if (!IsPopup()) | 208 if (!IsPopup()) |
237 return true; | 209 return true; |
238 | 210 |
239 view_controller_->ExecuteActionByUser(); | 211 view_controller_->ExecuteActionByUser(); |
240 | 212 |
241 // TODO(erikkay): Run a nested modal loop while the mouse is down to | 213 // TODO(erikkay): Run a nested modal loop while the mouse is down to |
242 // enable menu-like drag-select behavior. | 214 // enable menu-like drag-select behavior. |
243 | 215 |
244 // The return value of this method is returned via OnMousePressed. | 216 // The return value of this method is returned via OnMousePressed. |
245 // We need to return false here since we're handing off focus to another | 217 // We need to return false here since we're handing off focus to another |
246 // widget/view, and true will grab it right back and try to send events | 218 // widget/view, and true will grab it right back and try to send events |
247 // to us. | 219 // to us. |
248 return false; | 220 return false; |
249 } | 221 } |
250 | 222 |
251 bool BrowserActionButton::OnMousePressed(const ui::MouseEvent& event) { | 223 bool BrowserActionView::OnMousePressed(const ui::MouseEvent& event) { |
252 if (!event.IsRightMouseButton()) { | 224 if (!event.IsRightMouseButton()) { |
253 return IsPopup() ? MenuButton::OnMousePressed(event) : | 225 return IsPopup() ? MenuButton::OnMousePressed(event) : |
254 LabelButton::OnMousePressed(event); | 226 LabelButton::OnMousePressed(event); |
255 } | 227 } |
256 | 228 |
257 if (!views::View::ShouldShowContextMenuOnMousePress()) { | 229 if (!views::View::ShouldShowContextMenuOnMousePress()) { |
258 // See comments in MenuButton::Activate() as to why this is needed. | 230 // See comments in MenuButton::Activate() as to why this is needed. |
259 SetMouseHandler(NULL); | 231 SetMouseHandler(NULL); |
260 | 232 |
261 ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); | 233 ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); |
262 } | 234 } |
263 return false; | 235 return false; |
264 } | 236 } |
265 | 237 |
266 void BrowserActionButton::OnMouseReleased(const ui::MouseEvent& event) { | 238 void BrowserActionView::OnMouseReleased(const ui::MouseEvent& event) { |
267 if (IsPopup() || view_controller_->is_menu_running()) { | 239 if (IsPopup() || view_controller_->is_menu_running()) { |
268 // TODO(erikkay) this never actually gets called (probably because of the | 240 // TODO(erikkay) this never actually gets called (probably because of the |
269 // loss of focus). | 241 // loss of focus). |
270 MenuButton::OnMouseReleased(event); | 242 MenuButton::OnMouseReleased(event); |
271 } else { | 243 } else { |
272 LabelButton::OnMouseReleased(event); | 244 LabelButton::OnMouseReleased(event); |
273 } | 245 } |
274 } | 246 } |
275 | 247 |
276 void BrowserActionButton::OnMouseExited(const ui::MouseEvent& event) { | 248 void BrowserActionView::OnMouseExited(const ui::MouseEvent& event) { |
277 if (IsPopup() || view_controller_->is_menu_running()) | 249 if (IsPopup() || view_controller_->is_menu_running()) |
278 MenuButton::OnMouseExited(event); | 250 MenuButton::OnMouseExited(event); |
279 else | 251 else |
280 LabelButton::OnMouseExited(event); | 252 LabelButton::OnMouseExited(event); |
281 } | 253 } |
282 | 254 |
283 bool BrowserActionButton::OnKeyReleased(const ui::KeyEvent& event) { | 255 bool BrowserActionView::OnKeyReleased(const ui::KeyEvent& event) { |
284 return IsPopup() ? MenuButton::OnKeyReleased(event) : | 256 return IsPopup() ? MenuButton::OnKeyReleased(event) : |
285 LabelButton::OnKeyReleased(event); | 257 LabelButton::OnKeyReleased(event); |
286 } | 258 } |
287 | 259 |
288 void BrowserActionButton::OnGestureEvent(ui::GestureEvent* event) { | 260 void BrowserActionView::OnGestureEvent(ui::GestureEvent* event) { |
289 if (IsPopup()) | 261 if (IsPopup()) |
290 MenuButton::OnGestureEvent(event); | 262 MenuButton::OnGestureEvent(event); |
291 else | 263 else |
292 LabelButton::OnGestureEvent(event); | 264 LabelButton::OnGestureEvent(event); |
293 } | 265 } |
294 | 266 |
295 scoped_ptr<LabelButtonBorder> BrowserActionButton::CreateDefaultBorder() const { | 267 scoped_ptr<LabelButtonBorder> BrowserActionView::CreateDefaultBorder() const { |
296 scoped_ptr<LabelButtonBorder> border = LabelButton::CreateDefaultBorder(); | 268 scoped_ptr<LabelButtonBorder> border = LabelButton::CreateDefaultBorder(); |
297 border->set_insets(gfx::Insets(kBorderInset, kBorderInset, | 269 border->set_insets(gfx::Insets(kBorderInset, kBorderInset, |
298 kBorderInset, kBorderInset)); | 270 kBorderInset, kBorderInset)); |
299 return border.Pass(); | 271 return border.Pass(); |
300 } | 272 } |
301 | 273 |
302 void BrowserActionButton::SetButtonPushed() { | 274 void BrowserActionView::SetButtonPushed() { |
303 SetState(views::CustomButton::STATE_PRESSED); | 275 SetState(views::CustomButton::STATE_PRESSED); |
304 menu_visible_ = true; | 276 menu_visible_ = true; |
305 } | 277 } |
306 | 278 |
307 void BrowserActionButton::SetButtonNotPushed() { | 279 void BrowserActionView::SetButtonNotPushed() { |
308 SetState(views::CustomButton::STATE_NORMAL); | 280 SetState(views::CustomButton::STATE_NORMAL); |
309 menu_visible_ = false; | 281 menu_visible_ = false; |
310 } | 282 } |
311 | 283 |
312 bool BrowserActionButton::IsEnabled(int tab_id) const { | 284 bool BrowserActionView::IsEnabled(int tab_id) const { |
313 return view_controller_->extension_action()->GetIsVisible(tab_id); | 285 return view_controller_->extension_action()->GetIsVisible(tab_id); |
314 } | 286 } |
315 | 287 |
316 gfx::ImageSkia BrowserActionButton::GetIconWithBadge() { | 288 gfx::ImageSkia BrowserActionView::GetIconWithBadge() { |
317 int tab_id = view_controller_->GetCurrentTabId(); | 289 int tab_id = view_controller_->GetCurrentTabId(); |
318 gfx::Size spacing(0, ToolbarView::kVertSpacing); | 290 gfx::Size spacing(0, ToolbarView::kVertSpacing); |
319 gfx::ImageSkia icon = *view_controller_->GetIcon(tab_id).ToImageSkia(); | 291 gfx::ImageSkia icon = *view_controller_->GetIcon(tab_id).ToImageSkia(); |
320 if (!IsEnabled(tab_id)) | 292 if (!IsEnabled(tab_id)) |
321 icon = gfx::ImageSkiaOperations::CreateTransparentImage(icon, .25); | 293 icon = gfx::ImageSkiaOperations::CreateTransparentImage(icon, .25); |
322 return extension_action()->GetIconWithBadge(icon, tab_id, spacing); | 294 return extension_action()->GetIconWithBadge(icon, tab_id, spacing); |
323 } | 295 } |
324 | 296 |
325 gfx::ImageSkia BrowserActionButton::GetIconForTest() { | 297 gfx::ImageSkia BrowserActionView::GetIconForTest() { |
326 return GetImage(views::Button::STATE_NORMAL); | 298 return GetImage(views::Button::STATE_NORMAL); |
327 } | 299 } |
328 | 300 |
329 BrowserActionButton::~BrowserActionButton() { | 301 void BrowserActionView::OnIconUpdated() { |
330 } | |
331 | |
332 void BrowserActionButton::OnIconUpdated() { | |
333 UpdateState(); | 302 UpdateState(); |
334 if (icon_observer_) | 303 if (icon_observer_) |
335 icon_observer_->OnIconUpdated(GetIconWithBadge()); | 304 icon_observer_->OnIconUpdated(GetIconWithBadge()); |
336 } | 305 } |
337 | 306 |
338 views::View* BrowserActionButton::GetAsView() { | 307 views::View* BrowserActionView::GetAsView() { |
339 return this; | 308 return this; |
340 } | 309 } |
341 | 310 |
342 bool BrowserActionButton::IsShownInMenu() { | 311 bool BrowserActionView::IsShownInMenu() { |
343 return delegate_->ShownInsideMenu(); | 312 return delegate_->ShownInsideMenu(); |
344 } | 313 } |
345 | 314 |
346 views::FocusManager* BrowserActionButton::GetFocusManagerForAccelerator() { | 315 views::FocusManager* BrowserActionView::GetFocusManagerForAccelerator() { |
347 return GetFocusManager(); | 316 return GetFocusManager(); |
348 } | 317 } |
349 | 318 |
350 views::Widget* BrowserActionButton::GetParentForContextMenu() { | 319 views::Widget* BrowserActionView::GetParentForContextMenu() { |
351 // RunMenuAt expects a nested menu to be parented by the same widget as the | 320 // RunMenuAt expects a nested menu to be parented by the same widget as the |
352 // already visible menu, in this case the Chrome menu. | 321 // already visible menu, in this case the Chrome menu. |
353 return delegate_->ShownInsideMenu() ? | 322 return delegate_->ShownInsideMenu() ? |
354 BrowserView::GetBrowserViewForBrowser(view_controller_->browser()) | 323 BrowserView::GetBrowserViewForBrowser(view_controller_->browser()) |
355 ->toolbar()->app_menu()->GetWidget() : | 324 ->toolbar()->app_menu()->GetWidget() : |
356 GetWidget(); | 325 GetWidget(); |
357 } | 326 } |
358 | 327 |
359 views::View* BrowserActionButton::GetReferenceViewForPopup() { | 328 views::View* BrowserActionView::GetReferenceViewForPopup() { |
360 // Browser actions in the overflow menu can still show popups, so we may need | 329 // Browser actions in the overflow menu can still show popups, so we may need |
361 // a reference view other than this button's parent. If so, use the overflow | 330 // a reference view other than this button's parent. If so, use the overflow |
362 // view. | 331 // view. |
363 return parent()->visible() ? this : delegate_->GetOverflowReferenceView(); | 332 return visible() ? this : delegate_->GetOverflowReferenceView(); |
364 } | 333 } |
365 | 334 |
366 content::WebContents* BrowserActionButton::GetCurrentWebContents() { | 335 content::WebContents* BrowserActionView::GetCurrentWebContents() { |
367 return delegate_->GetCurrentWebContents(); | 336 return delegate_->GetCurrentWebContents(); |
368 } | 337 } |
369 | 338 |
370 void BrowserActionButton::HideActivePopup() { | 339 void BrowserActionView::HideActivePopup() { |
371 delegate_->HideActivePopup(); | 340 delegate_->HideActivePopup(); |
372 } | 341 } |
373 | 342 |
374 void BrowserActionButton::OnPopupShown(bool grant_tab_permissions) { | 343 void BrowserActionView::OnPopupShown(bool grant_tab_permissions) { |
375 delegate_->SetPopupOwner(this); | 344 delegate_->SetPopupOwner(this); |
376 if (grant_tab_permissions) | 345 if (grant_tab_permissions) |
377 SetButtonPushed(); | 346 SetButtonPushed(); |
378 } | 347 } |
379 | 348 |
380 void BrowserActionButton::CleanupPopup() { | 349 void BrowserActionView::CleanupPopup() { |
381 // We need to do these actions synchronously (instead of closing and then | 350 // We need to do these actions synchronously (instead of closing and then |
382 // performing the rest of the cleanup in OnWidgetDestroyed()) because | 351 // performing the rest of the cleanup in OnWidgetDestroyed()) because |
383 // OnWidgetDestroyed() can be called asynchronously from Close(), and we need | 352 // OnWidgetDestroyed() can be called asynchronously from Close(), and we need |
384 // to keep the delegate's popup owner up-to-date. | 353 // to keep the delegate's popup owner up-to-date. |
385 SetButtonNotPushed(); | 354 SetButtonNotPushed(); |
386 delegate_->SetPopupOwner(NULL); | 355 delegate_->SetPopupOwner(NULL); |
387 } | 356 } |
388 | 357 |
389 void BrowserActionButton::OnWillShowContextMenus() { | 358 void BrowserActionView::OnWillShowContextMenus() { |
390 SetButtonPushed(); | 359 SetButtonPushed(); |
391 } | 360 } |
392 | 361 |
393 void BrowserActionButton::OnContextMenuDone() { | 362 void BrowserActionView::OnContextMenuDone() { |
394 SetButtonNotPushed(); | 363 SetButtonNotPushed(); |
395 } | 364 } |
OLD | NEW |