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

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

Issue 2862025: Canvas refactoring part 2.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/infobars/extension_infobar.h" 5 #include "chrome/browser/views/infobars/extension_infobar.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "app/slide_animation.h" 8 #include "app/slide_animation.h"
9 #include "chrome/browser/extensions/extension_context_menu_model.h" 9 #include "chrome/browser/extensions/extension_context_menu_model.h"
10 #include "chrome/browser/extensions/extension_infobar_delegate.h" 10 #include "chrome/browser/extensions/extension_infobar_delegate.h"
11 #include "chrome/browser/extensions/extension_host.h" 11 #include "chrome/browser/extensions/extension_host.h"
12 #include "chrome/browser/platform_util.h" 12 #include "chrome/browser/platform_util.h"
13 #include "chrome/browser/views/frame/browser_view.h" 13 #include "chrome/browser/views/frame/browser_view.h"
14 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
15 #include "chrome/common/extensions/extension_resource.h" 15 #include "chrome/common/extensions/extension_resource.h"
16 #include "gfx/canvas.h" 16 #include "gfx/canvas_skia.h"
17 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
18 #include "views/controls/button/menu_button.h" 18 #include "views/controls/button/menu_button.h"
19 #include "views/controls/menu/menu_2.h" 19 #include "views/controls/menu/menu_2.h"
20 #include "views/widget/widget.h" 20 #include "views/widget/widget.h"
21 21
22 // The horizontal margin between the menu and the Extension (HTML) view. 22 // The horizontal margin between the menu and the Extension (HTML) view.
23 static const int kMenuHorizontalMargin = 1; 23 static const int kMenuHorizontalMargin = 1;
24 24
25 // The amount of space to the right of the Extension (HTML) view (to avoid 25 // The amount of space to the right of the Extension (HTML) view (to avoid
26 // overlapping the close button for the InfoBar). 26 // overlapping the close button for the InfoBar).
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // We fall back on the default extension icon on failure. 108 // We fall back on the default extension icon on failure.
109 SkBitmap* icon; 109 SkBitmap* icon;
110 if (!image || image->empty()) 110 if (!image || image->empty())
111 icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION); 111 icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION);
112 else 112 else
113 icon = image; 113 icon = image;
114 114
115 SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); 115 SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW);
116 116
117 int image_size = Extension::EXTENSION_ICON_BITTY; 117 int image_size = Extension::EXTENSION_ICON_BITTY;
118 scoped_ptr<gfx::Canvas> canvas( 118 scoped_ptr<gfx::CanvasSkia> canvas(
119 new gfx::Canvas(image_size + kDropArrowLeftMargin + drop_image->width(), 119 new gfx::CanvasSkia(
120 image_size, false)); 120 image_size + kDropArrowLeftMargin + drop_image->width(),
121 image_size, false));
121 canvas->DrawBitmapInt(*icon, 122 canvas->DrawBitmapInt(*icon,
122 0, 0, icon->width(), icon->height(), 123 0, 0, icon->width(), icon->height(),
123 0, 0, image_size, image_size, 124 0, 0, image_size, image_size,
124 false); 125 false);
125 canvas->DrawBitmapInt(*drop_image, 126 canvas->DrawBitmapInt(*drop_image,
126 image_size + kDropArrowLeftMargin, 127 image_size + kDropArrowLeftMargin,
127 image_size / 2); 128 image_size / 2);
128 menu_->SetIcon(canvas->ExtractBitmap()); 129 menu_->SetIcon(canvas->ExtractBitmap());
129 menu_->SetVisible(true); 130 menu_->SetVisible(true);
130 131
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 tracker_.LoadImage(extension, icon_resource, gfx::Size(size, size), 165 tracker_.LoadImage(extension, icon_resource, gfx::Size(size, size),
165 ImageLoadingTracker::DONT_CACHE); 166 ImageLoadingTracker::DONT_CACHE);
166 } else { 167 } else {
167 OnImageLoaded(NULL, icon_resource, 0); // |image|, |index|. 168 OnImageLoaded(NULL, icon_resource, 0); // |image|, |index|.
168 } 169 }
169 } 170 }
170 171
171 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() { 172 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() {
172 return new ExtensionInfoBar(this); 173 return new ExtensionInfoBar(this);
173 } 174 }
OLDNEW
« no previous file with comments | « chrome/browser/views/extensions/browser_action_overflow_menu_controller.cc ('k') | chrome/browser/views/sad_tab_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698