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/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" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 ExtensionHost* extension_host = GetDelegate()->extension_host(); | 83 ExtensionHost* extension_host = GetDelegate()->extension_host(); |
84 AddChildView(extension_host->view()); | 84 AddChildView(extension_host->view()); |
85 | 85 |
86 // This must happen after adding all other children so InfoBarView can ensure | 86 // This must happen after adding all other children so InfoBarView can ensure |
87 // the close button is the last child. | 87 // the close button is the last child. |
88 InfoBarView::ViewHierarchyChanged(is_add, parent, child); | 88 InfoBarView::ViewHierarchyChanged(is_add, parent, child); |
89 | 89 |
90 // This must happen after adding all children because it can trigger layout, | 90 // This must happen after adding all children because it can trigger layout, |
91 // which assumes that particular children (e.g. the close button) have already | 91 // which assumes that particular children (e.g. the close button) have already |
92 // been added. | 92 // been added. |
93 const Extension* extension = extension_host->extension(); | 93 const extensions::Extension* extension = extension_host->extension(); |
94 ExtensionIconSet::Icons image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; | 94 ExtensionIconSet::Icons image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; |
95 ExtensionResource icon_resource = extension->GetIconResource( | 95 ExtensionResource icon_resource = extension->GetIconResource( |
96 image_size, ExtensionIconSet::MATCH_EXACTLY); | 96 image_size, ExtensionIconSet::MATCH_EXACTLY); |
97 tracker_.LoadImage(extension, icon_resource, | 97 tracker_.LoadImage(extension, icon_resource, |
98 gfx::Size(image_size, image_size), ImageLoadingTracker::DONT_CACHE); | 98 gfx::Size(image_size, image_size), ImageLoadingTracker::DONT_CACHE); |
99 } | 99 } |
100 | 100 |
101 int ExtensionInfoBar::ContentMinimumWidth() const { | 101 int ExtensionInfoBar::ContentMinimumWidth() const { |
102 return menu_->GetPreferredSize().width() + kMenuHorizontalMargin; | 102 return menu_->GetPreferredSize().width() + kMenuHorizontalMargin; |
103 } | 103 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 void ExtensionInfoBar::OnDelegateDeleted() { | 137 void ExtensionInfoBar::OnDelegateDeleted() { |
138 delegate_ = NULL; | 138 delegate_ = NULL; |
139 } | 139 } |
140 | 140 |
141 void ExtensionInfoBar::OnMenuButtonClicked(views::View* source, | 141 void ExtensionInfoBar::OnMenuButtonClicked(views::View* source, |
142 const gfx::Point& point) { | 142 const gfx::Point& point) { |
143 if (!owned()) | 143 if (!owned()) |
144 return; // We're closing; don't call anything, it might access the owner. | 144 return; // We're closing; don't call anything, it might access the owner. |
145 const Extension* extension = GetDelegate()->extension_host()->extension(); | 145 const extensions::Extension* extension = GetDelegate()->extension_host()-> |
| 146 extension(); |
146 if (!extension->ShowConfigureContextMenus()) | 147 if (!extension->ShowConfigureContextMenus()) |
147 return; | 148 return; |
148 | 149 |
149 scoped_refptr<ExtensionContextMenuModel> options_menu_contents = | 150 scoped_refptr<ExtensionContextMenuModel> options_menu_contents = |
150 new ExtensionContextMenuModel(extension, browser_); | 151 new ExtensionContextMenuModel(extension, browser_); |
151 DCHECK_EQ(menu_, source); | 152 DCHECK_EQ(menu_, source); |
152 RunMenuAt(options_menu_contents.get(), menu_, views::MenuItemView::TOPLEFT); | 153 RunMenuAt(options_menu_contents.get(), menu_, views::MenuItemView::TOPLEFT); |
153 } | 154 } |
154 | 155 |
155 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() { | 156 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() { |
156 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL; | 157 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL; |
157 } | 158 } |
OLD | NEW |