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_infobar_delegate.h" | 8 #include "chrome/browser/extensions/extension_infobar_delegate.h" |
9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
10 #include "chrome/browser/platform_util.h" | 10 #include "chrome/browser/platform_util.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 Layout(); | 141 Layout(); |
142 } | 142 } |
143 | 143 |
144 void ExtensionInfoBar::OnDelegateDeleted() { | 144 void ExtensionInfoBar::OnDelegateDeleted() { |
145 delegate_->extension_host()->view()->SetContainer(NULL); | 145 delegate_->extension_host()->view()->SetContainer(NULL); |
146 delegate_ = NULL; | 146 delegate_ = NULL; |
147 } | 147 } |
148 | 148 |
149 void ExtensionInfoBar::RunMenu(View* source, const gfx::Point& pt) { | 149 void ExtensionInfoBar::RunMenu(View* source, const gfx::Point& pt) { |
| 150 const Extension* extension = delegate_->extension_host()->extension(); |
| 151 if (!extension->ShowConfigureContextMenus()) |
| 152 return; |
| 153 |
150 if (!options_menu_contents_.get()) { | 154 if (!options_menu_contents_.get()) { |
151 Browser* browser = BrowserView::GetBrowserViewForNativeWindow( | 155 Browser* browser = BrowserView::GetBrowserViewForNativeWindow( |
152 platform_util::GetTopLevel(source->GetWidget()->GetNativeView()))-> | 156 platform_util::GetTopLevel(source->GetWidget()->GetNativeView()))-> |
153 browser(); | 157 browser(); |
154 options_menu_contents_ = new ExtensionContextMenuModel( | 158 options_menu_contents_ = new ExtensionContextMenuModel( |
155 delegate_->extension_host()->extension(), browser, NULL); | 159 extension, browser, NULL); |
156 } | 160 } |
157 | 161 |
158 options_menu_menu_.reset(new views::Menu2(options_menu_contents_.get())); | 162 options_menu_menu_.reset(new views::Menu2(options_menu_contents_.get())); |
159 options_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPLEFT); | 163 options_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPLEFT); |
160 } | 164 } |
161 | 165 |
162 void ExtensionInfoBar::SetupIconAndMenu() { | 166 void ExtensionInfoBar::SetupIconAndMenu() { |
163 menu_ = new views::MenuButton(NULL, std::wstring(), this, false); | 167 menu_ = new views::MenuButton(NULL, std::wstring(), this, false); |
164 menu_->SetVisible(false); | 168 menu_->SetVisible(false); |
165 AddChildView(menu_); | 169 AddChildView(menu_); |
166 | 170 |
167 const Extension* extension = delegate_->extension_host()->extension(); | 171 const Extension* extension = delegate_->extension_host()->extension(); |
168 ExtensionResource icon_resource = extension->GetIconResource( | 172 ExtensionResource icon_resource = extension->GetIconResource( |
169 Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); | 173 Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); |
170 if (!icon_resource.relative_path().empty()) { | 174 if (!icon_resource.relative_path().empty()) { |
171 // Create a tracker to load the image. It will report back on OnImageLoaded. | 175 // Create a tracker to load the image. It will report back on OnImageLoaded. |
172 tracker_.LoadImage(extension, icon_resource, | 176 tracker_.LoadImage(extension, icon_resource, |
173 gfx::Size(Extension::EXTENSION_ICON_BITTY, | 177 gfx::Size(Extension::EXTENSION_ICON_BITTY, |
174 Extension::EXTENSION_ICON_BITTY), | 178 Extension::EXTENSION_ICON_BITTY), |
175 ImageLoadingTracker::DONT_CACHE); | 179 ImageLoadingTracker::DONT_CACHE); |
176 } else { | 180 } else { |
177 OnImageLoaded(NULL, icon_resource, 0); // |image|, |index|. | 181 OnImageLoaded(NULL, icon_resource, 0); // |image|, |index|. |
178 } | 182 } |
179 } | 183 } |
180 | 184 |
181 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() { | 185 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() { |
182 return new ExtensionInfoBar(this); | 186 return new ExtensionInfoBar(this); |
183 } | 187 } |
OLD | NEW |