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

Side by Side Diff: chrome/browser/ui/views/infobars/extension_infobar.cc

Issue 10453101: Convert most of the rest of chrome to ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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/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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 int ExtensionInfoBar::ContentMinimumWidth() const { 101 int ExtensionInfoBar::ContentMinimumWidth() const {
102 return menu_->GetPreferredSize().width() + kMenuHorizontalMargin; 102 return menu_->GetPreferredSize().width() + kMenuHorizontalMargin;
103 } 103 }
104 104
105 void ExtensionInfoBar::OnImageLoaded(const gfx::Image& image, 105 void ExtensionInfoBar::OnImageLoaded(const gfx::Image& image,
106 const std::string& extension_id, 106 const std::string& extension_id,
107 int index) { 107 int index) {
108 if (!GetDelegate()) 108 if (!GetDelegate())
109 return; // The delegate can go away while we asynchronously load images. 109 return; // The delegate can go away while we asynchronously load images.
110 110
111 const SkBitmap* icon = NULL; 111 const gfx::ImageSkia* icon = NULL;
112 // Fall back on the default extension icon on failure. 112 // Fall back on the default extension icon on failure.
113 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 113 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
114 if (image.IsEmpty()) 114 if (image.IsEmpty())
115 icon = rb.GetImageNamed(IDR_EXTENSIONS_SECTION).ToSkBitmap(); 115 icon = rb.GetImageNamed(IDR_EXTENSIONS_SECTION).ToImageSkia();
116 else 116 else
117 icon = image.ToSkBitmap(); 117 icon = image.ToImageSkia();
118 118
119 const SkBitmap* drop_image = rb.GetImageNamed(IDR_APP_DROPARROW).ToSkBitmap(); 119 const gfx::ImageSkia* drop_image =
120 rb.GetImageNamed(IDR_APP_DROPARROW).ToImageSkia();
120 121
121 int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; 122 int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY;
122 // The margin between the extension icon and the drop-down arrow bitmap. 123 // The margin between the extension icon and the drop-down arrow image.
123 static const int kDropArrowLeftMargin = 3; 124 static const int kDropArrowLeftMargin = 3;
124 scoped_ptr<gfx::Canvas> canvas(new gfx::Canvas( 125 scoped_ptr<gfx::Canvas> canvas(new gfx::Canvas(
125 gfx::Size(image_size + kDropArrowLeftMargin + drop_image->width(), 126 gfx::Size(image_size + kDropArrowLeftMargin + drop_image->width(),
126 image_size), false)); 127 image_size), false));
127 canvas->DrawBitmapInt(*icon, 0, 0, icon->width(), icon->height(), 0, 0, 128 canvas->DrawBitmapInt(*icon, 0, 0, icon->width(), icon->height(), 0, 0,
128 image_size, image_size, false); 129 image_size, image_size, false);
129 canvas->DrawBitmapInt(*drop_image, image_size + kDropArrowLeftMargin, 130 canvas->DrawBitmapInt(*drop_image, image_size + kDropArrowLeftMargin,
130 image_size / 2); 131 image_size / 2);
131 menu_->SetIcon(canvas->ExtractBitmap()); 132 menu_->SetIcon(canvas->ExtractBitmap());
132 menu_->SetVisible(true); 133 menu_->SetVisible(true);
(...skipping 16 matching lines...) Expand all
149 150
150 scoped_refptr<ExtensionContextMenuModel> options_menu_contents = 151 scoped_refptr<ExtensionContextMenuModel> options_menu_contents =
151 new ExtensionContextMenuModel(extension, browser_); 152 new ExtensionContextMenuModel(extension, browser_);
152 DCHECK_EQ(menu_, source); 153 DCHECK_EQ(menu_, source);
153 RunMenuAt(options_menu_contents.get(), menu_, views::MenuItemView::TOPLEFT); 154 RunMenuAt(options_menu_contents.get(), menu_, views::MenuItemView::TOPLEFT);
154 } 155 }
155 156
156 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() { 157 ExtensionInfoBarDelegate* ExtensionInfoBar::GetDelegate() {
157 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL; 158 return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL;
158 } 159 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.cc ('k') | chrome/browser/ui/views/location_bar/icon_label_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698