Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc

Issue 11786003: Move Icons out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/extensions/image_loader.h" 10 #include "chrome/browser/extensions/image_loader.h"
11 #include "chrome/browser/platform_util.h" 11 #include "chrome/browser/platform_util.h"
12 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 12 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
13 #include "chrome/browser/ui/gtk/custom_button.h" 13 #include "chrome/browser/ui/gtk/custom_button.h"
14 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" 14 #include "chrome/browser/ui/gtk/gtk_chrome_button.h"
15 #include "chrome/browser/ui/gtk/gtk_util.h" 15 #include "chrome/browser/ui/gtk/gtk_util.h"
16 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" 16 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h"
17 #include "chrome/common/extensions/api/icons/icons_handler.h"
17 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
19 #include "chrome/common/extensions/extension_icon_set.h" 20 #include "chrome/common/extensions/extension_icon_set.h"
20 #include "chrome/common/extensions/extension_resource.h" 21 #include "chrome/common/extensions/extension_resource.h"
21 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
22 #include "content/public/browser/render_widget_host_view.h" 23 #include "content/public/browser/render_widget_host_view.h"
23 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
24 #include "ui/base/gtk/gtk_signal_registrar.h" 25 #include "ui/base/gtk/gtk_signal_registrar.h"
25 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 reinterpret_cast<void*>(true)); 105 reinterpret_cast<void*>(true));
105 106
106 icon_ = gtk_image_new(); 107 icon_ = gtk_image_new();
107 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5); 108 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5);
108 gtk_button_set_image(GTK_BUTTON(button_), icon_); 109 gtk_button_set_image(GTK_BUTTON(button_), icon_);
109 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0); 110 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0);
110 111
111 // Start loading the image for the menu button. 112 // Start loading the image for the menu button.
112 const extensions::Extension* extension = 113 const extensions::Extension* extension =
113 delegate_->extension_host()->extension(); 114 delegate_->extension_host()->extension();
114 ExtensionResource icon_resource = extension->GetIconResource( 115 ExtensionResource icon_resource = extensions::IconsInfo::GetIconResource(
115 extension_misc::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); 116 extension,
117 extension_misc::EXTENSION_ICON_BITTY,
118 ExtensionIconSet::MATCH_EXACTLY);
116 // Load image asynchronously, calling back OnImageLoaded. 119 // Load image asynchronously, calling back OnImageLoaded.
117 extensions::ImageLoader* loader = 120 extensions::ImageLoader* loader =
118 extensions::ImageLoader::Get(delegate_->extension_host()->profile()); 121 extensions::ImageLoader::Get(delegate_->extension_host()->profile());
119 loader->LoadImageAsync(extension, icon_resource, 122 loader->LoadImageAsync(extension, icon_resource,
120 gfx::Size(extension_misc::EXTENSION_ICON_BITTY, 123 gfx::Size(extension_misc::EXTENSION_ICON_BITTY,
121 extension_misc::EXTENSION_ICON_BITTY), 124 extension_misc::EXTENSION_ICON_BITTY),
122 base::Bind(&ExtensionInfoBarGtk::OnImageLoaded, 125 base::Bind(&ExtensionInfoBarGtk::OnImageLoaded,
123 weak_ptr_factory_.GetWeakPtr())); 126 weak_ptr_factory_.GetWeakPtr()));
124 127
125 // Pad the bottom of the infobar by one pixel for the border. 128 // Pad the bottom of the infobar by one pixel for the border.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // We also need to draw our infobar arrows over the renderer. 203 // We also need to draw our infobar arrows over the renderer.
201 static_cast<InfoBarContainerGtk*>(container())-> 204 static_cast<InfoBarContainerGtk*>(container())->
202 PaintInfobarBitsOn(sender, event, this); 205 PaintInfobarBitsOn(sender, event, this);
203 206
204 return FALSE; 207 return FALSE;
205 } 208 }
206 209
207 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { 210 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
208 return new ExtensionInfoBarGtk(owner, this); 211 return new ExtensionInfoBarGtk(owner, this);
209 } 212 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698