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/gtk/infobars/extension_infobar_gtk.h" | 5 #include "chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "chrome/browser/extensions/extension_context_menu_model.h" | 8 #include "chrome/browser/extensions/extension_context_menu_model.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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(button_), FALSE); | 102 gtk_chrome_button_set_use_gtk_rendering(GTK_CHROME_BUTTON(button_), FALSE); |
103 g_object_set_data(G_OBJECT(button_), "left-align-popup", | 103 g_object_set_data(G_OBJECT(button_), "left-align-popup", |
104 reinterpret_cast<void*>(true)); | 104 reinterpret_cast<void*>(true)); |
105 | 105 |
106 icon_ = gtk_image_new(); | 106 icon_ = gtk_image_new(); |
107 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5); | 107 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5); |
108 gtk_button_set_image(GTK_BUTTON(button_), icon_); | 108 gtk_button_set_image(GTK_BUTTON(button_), icon_); |
109 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0); | 109 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0); |
110 | 110 |
111 // Start loading the image for the menu button. | 111 // Start loading the image for the menu button. |
112 const Extension* extension = delegate_->extension_host()->extension(); | 112 const extensions::Extension* extension = delegate_->extension_host()-> |
| 113 extension(); |
113 ExtensionResource icon_resource = extension->GetIconResource( | 114 ExtensionResource icon_resource = extension->GetIconResource( |
114 ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); | 115 ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); |
115 // Create a tracker to load the image. It will report back on OnImageLoaded. | 116 // Create a tracker to load the image. It will report back on OnImageLoaded. |
116 tracker_.LoadImage(extension, icon_resource, | 117 tracker_.LoadImage(extension, icon_resource, |
117 gfx::Size(ExtensionIconSet::EXTENSION_ICON_BITTY, | 118 gfx::Size(ExtensionIconSet::EXTENSION_ICON_BITTY, |
118 ExtensionIconSet::EXTENSION_ICON_BITTY), | 119 ExtensionIconSet::EXTENSION_ICON_BITTY), |
119 ImageLoadingTracker::DONT_CACHE); | 120 ImageLoadingTracker::DONT_CACHE); |
120 | 121 |
121 // Pad the bottom of the infobar by one pixel for the border. | 122 // Pad the bottom of the infobar by one pixel for the border. |
122 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 123 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
(...skipping 24 matching lines...) Expand all Loading... |
147 Browser* ExtensionInfoBarGtk::GetBrowser() { | 148 Browser* ExtensionInfoBarGtk::GetBrowser() { |
148 // Get the Browser object this infobar is attached to. | 149 // Get the Browser object this infobar is attached to. |
149 GtkWindow* parent = platform_util::GetTopLevel(icon_); | 150 GtkWindow* parent = platform_util::GetTopLevel(icon_); |
150 if (!parent) | 151 if (!parent) |
151 return NULL; | 152 return NULL; |
152 | 153 |
153 return BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent)->browser(); | 154 return BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent)->browser(); |
154 } | 155 } |
155 | 156 |
156 ui::MenuModel* ExtensionInfoBarGtk::BuildMenuModel() { | 157 ui::MenuModel* ExtensionInfoBarGtk::BuildMenuModel() { |
157 const Extension* extension = delegate_->extension(); | 158 const extensions::Extension* extension = delegate_->extension(); |
158 if (!extension->ShowConfigureContextMenus()) | 159 if (!extension->ShowConfigureContextMenus()) |
159 return NULL; | 160 return NULL; |
160 | 161 |
161 Browser* browser = GetBrowser(); | 162 Browser* browser = GetBrowser(); |
162 if (!browser) | 163 if (!browser) |
163 return NULL; | 164 return NULL; |
164 | 165 |
165 return new ExtensionContextMenuModel(extension, browser); | 166 return new ExtensionContextMenuModel(extension, browser); |
166 } | 167 } |
167 | 168 |
(...skipping 28 matching lines...) Expand all Loading... |
196 // We also need to draw our infobar arrows over the renderer. | 197 // We also need to draw our infobar arrows over the renderer. |
197 static_cast<InfoBarContainerGtk*>(container())-> | 198 static_cast<InfoBarContainerGtk*>(container())-> |
198 PaintInfobarBitsOn(sender, event, this); | 199 PaintInfobarBitsOn(sender, event, this); |
199 | 200 |
200 return FALSE; | 201 return FALSE; |
201 } | 202 } |
202 | 203 |
203 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { | 204 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { |
204 return new ExtensionInfoBarGtk(owner, this); | 205 return new ExtensionInfoBarGtk(owner, this); |
205 } | 206 } |
OLD | NEW |