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