| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/extensions/extension_browser_event_router.h" | 11 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 12 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 12 #include "chrome/browser/extensions/extension_host.h" | 13 #include "chrome/browser/extensions/extension_host.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/extension_tabs_module.h" | 15 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/sessions/restore_tab_helper.h" | 17 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 20 #include "chrome/browser/ui/view_ids.h" | 21 #include "chrome/browser/ui/view_ids.h" |
| 21 #include "chrome/browser/ui/views/detachable_toolbar_view.h" | 22 #include "chrome/browser/ui/views/detachable_toolbar_view.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 266 |
| 266 void BrowserActionButton::ShowContextMenu(const gfx::Point& p, | 267 void BrowserActionButton::ShowContextMenu(const gfx::Point& p, |
| 267 bool is_mouse_gesture) { | 268 bool is_mouse_gesture) { |
| 268 if (!extension()->ShowConfigureContextMenus()) | 269 if (!extension()->ShowConfigureContextMenus()) |
| 269 return; | 270 return; |
| 270 | 271 |
| 271 SetButtonPushed(); | 272 SetButtonPushed(); |
| 272 | 273 |
| 273 // Reconstructs the menu every time because the menu's contents are dynamic. | 274 // Reconstructs the menu every time because the menu's contents are dynamic. |
| 274 scoped_refptr<ExtensionContextMenuModel> context_menu_contents_( | 275 scoped_refptr<ExtensionContextMenuModel> context_menu_contents_( |
| 275 new ExtensionContextMenuModel(extension(), panel_->browser(), panel_)); | 276 new ExtensionContextMenuModel(extension(), panel_->browser())); |
| 276 views::MenuModelAdapter menu_model_adapter(context_menu_contents_.get()); | 277 views::MenuModelAdapter menu_model_adapter(context_menu_contents_.get()); |
| 277 views::MenuRunner menu_runner(menu_model_adapter.CreateMenu()); | 278 views::MenuRunner menu_runner(menu_model_adapter.CreateMenu()); |
| 278 | 279 |
| 279 context_menu_ = menu_runner.GetMenu(); | 280 context_menu_ = menu_runner.GetMenu(); |
| 280 gfx::Point screen_loc; | 281 gfx::Point screen_loc; |
| 281 views::View::ConvertPointToScreen(this, &screen_loc); | 282 views::View::ConvertPointToScreen(this, &screen_loc); |
| 282 if (menu_runner.RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), | 283 if (menu_runner.RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), |
| 283 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) == | 284 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) == |
| 284 views::MenuRunner::MENU_DELETED) | 285 views::MenuRunner::MENU_DELETED) |
| 285 return; | 286 return; |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 OnBrowserActionVisibilityChanged(); | 802 OnBrowserActionVisibilityChanged(); |
| 802 suppress_chevron_ = false; | 803 suppress_chevron_ = false; |
| 803 } | 804 } |
| 804 | 805 |
| 805 void BrowserActionsContainer::NotifyMenuDeleted( | 806 void BrowserActionsContainer::NotifyMenuDeleted( |
| 806 BrowserActionOverflowMenuController* controller) { | 807 BrowserActionOverflowMenuController* controller) { |
| 807 DCHECK(controller == overflow_menu_); | 808 DCHECK(controller == overflow_menu_); |
| 808 overflow_menu_ = NULL; | 809 overflow_menu_ = NULL; |
| 809 } | 810 } |
| 810 | 811 |
| 811 void BrowserActionsContainer::InspectPopup(ExtensionAction* action) { | |
| 812 OnBrowserActionExecuted(GetBrowserActionView(action)->button(), true); | |
| 813 } | |
| 814 | |
| 815 void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) { | 812 void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) { |
| 816 DCHECK_EQ(popup_->GetWidget(), widget); | 813 DCHECK_EQ(popup_->GetWidget(), widget); |
| 817 popup_->GetWidget()->RemoveObserver(this); | 814 popup_->GetWidget()->RemoveObserver(this); |
| 818 popup_ = NULL; | 815 popup_ = NULL; |
| 819 // |popup_button_| is NULL if the extension has been removed. | 816 // |popup_button_| is NULL if the extension has been removed. |
| 820 if (popup_button_) { | 817 if (popup_button_) { |
| 821 popup_button_->SetButtonNotPushed(); | 818 popup_button_->SetButtonNotPushed(); |
| 822 popup_button_ = NULL; | 819 popup_button_ = NULL; |
| 823 } | 820 } |
| 824 } | 821 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 } | 1123 } |
| 1127 } | 1124 } |
| 1128 | 1125 |
| 1129 bool BrowserActionsContainer::ShouldDisplayBrowserAction( | 1126 bool BrowserActionsContainer::ShouldDisplayBrowserAction( |
| 1130 const Extension* extension) { | 1127 const Extension* extension) { |
| 1131 // Only display incognito-enabled extensions while in incognito mode. | 1128 // Only display incognito-enabled extensions while in incognito mode. |
| 1132 return | 1129 return |
| 1133 (!profile_->IsOffTheRecord() || | 1130 (!profile_->IsOffTheRecord() || |
| 1134 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); | 1131 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); |
| 1135 } | 1132 } |
| OLD | NEW |