Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/infobars/extension_infobar.h" | 5 #include "chrome/browser/ui/views/infobars/extension_infobar.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_context_menu_model.h" | 7 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/extensions/extension_infobar_delegate.h" | 9 #include "chrome/browser/extensions/extension_infobar_delegate.h" |
| 10 #include "chrome/browser/platform_util.h" | 10 #include "chrome/browser/platform_util.h" |
| 11 #include "chrome/browser/ui/views/frame/browser_view.h" | 11 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "chrome/common/extensions/extension_icon_set.h" | 13 #include "chrome/common/extensions/extension_icon_set.h" |
| 14 #include "chrome/common/extensions/extension_resource.h" | 14 #include "chrome/common/extensions/extension_resource.h" |
| 15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
| 16 #include "ui/base/animation/slide_animation.h" | 16 #include "ui/base/animation/slide_animation.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/canvas_skia.h" | 18 #include "ui/gfx/canvas_skia.h" |
| 19 #include "views/controls/button/menu_button.h" | 19 #include "views/controls/button/menu_button.h" |
| 20 #include "views/controls/menu/menu_item_view.h" | 20 #include "views/controls/menu/menu_item_view.h" |
| 21 #include "views/controls/menu/menu_model_adapter.h" | |
| 22 #include "views/controls/menu/menu_runner.h" | |
| 23 #include "views/widget/widget.h" | 21 #include "views/widget/widget.h" |
| 24 | 22 |
| 25 // ExtensionInfoBarDelegate ---------------------------------------------------- | 23 // ExtensionInfoBarDelegate ---------------------------------------------------- |
| 26 | 24 |
| 27 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { | 25 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { |
| 28 return new ExtensionInfoBar(owner, this); | 26 return new ExtensionInfoBar(owner, this); |
| 29 } | 27 } |
| 30 | 28 |
| 31 // ExtensionInfoBar ------------------------------------------------------------ | 29 // ExtensionInfoBar ------------------------------------------------------------ |
| 32 | 30 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 void ExtensionInfoBar::RunMenu(View* source, const gfx::Point& pt) { | 139 void ExtensionInfoBar::RunMenu(View* source, const gfx::Point& pt) { |
| 142 const Extension* extension = GetDelegate()->extension_host()->extension(); | 140 const Extension* extension = GetDelegate()->extension_host()->extension(); |
| 143 if (!extension->ShowConfigureContextMenus()) | 141 if (!extension->ShowConfigureContextMenus()) |
| 144 return; | 142 return; |
| 145 | 143 |
| 146 Browser* browser = BrowserView::GetBrowserViewForNativeWindow( | 144 Browser* browser = BrowserView::GetBrowserViewForNativeWindow( |
| 147 platform_util::GetTopLevel(source->GetWidget()->GetNativeView()))-> | 145 platform_util::GetTopLevel(source->GetWidget()->GetNativeView()))-> |
| 148 browser(); | 146 browser(); |
| 149 scoped_refptr<ExtensionContextMenuModel> options_menu_contents = | 147 scoped_refptr<ExtensionContextMenuModel> options_menu_contents = |
| 150 new ExtensionContextMenuModel(extension, browser, NULL); | 148 new ExtensionContextMenuModel(extension, browser, NULL); |
| 151 views::MenuModelAdapter options_menu_delegate(options_menu_contents.get()); | 149 DCHECK_EQ(source, menu_); |
| 152 menu_runner_.reset(new views::MenuRunner(options_menu_delegate.CreateMenu())); | 150 if (RunMenuAt(options_menu_contents.get(), menu_, |
|
Peter Kasting
2011/09/15 21:43:12
Nit: Same nit.
| |
| 153 gfx::Point screen_point; | 151 views::MenuItemView::TOPLEFT) == views::MenuRunner::MENU_DELETED) |
| 154 views::View::ConvertPointToScreen(menu_, &screen_point); | |
| 155 if (menu_runner_->RunMenuAt(GetWidget(), menu_, | |
| 156 gfx::Rect(screen_point, menu_->size()), views::MenuItemView::TOPLEFT, | |
| 157 views::MenuRunner::HAS_MNEMONICS) == views::MenuRunner::MENU_DELETED) | |
| 158 return; | 152 return; |
| 159 } | 153 } |
| 160 | 154 |
| 161 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() { | 155 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() { |
| 162 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL; | 156 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL; |
| 163 } | 157 } |
| OLD | NEW |