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 #import "chrome/browser/ui/cocoa/infobars/extension_infobar_controller.h" | 5 #import "chrome/browser/ui/cocoa/infobars/extension_infobar_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
10 #include "chrome/browser/extensions/extension_infobar_delegate.h" | 10 #include "chrome/browser/extensions/extension_infobar_delegate.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION); | 98 icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION); |
99 else | 99 else |
100 icon = image.ToSkBitmap(); | 100 icon = image.ToSkBitmap(); |
101 | 101 |
102 SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); | 102 SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); |
103 | 103 |
104 const int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; | 104 const int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; |
105 scoped_ptr<gfx::Canvas> canvas( | 105 scoped_ptr<gfx::Canvas> canvas( |
106 new gfx::Canvas( | 106 new gfx::Canvas( |
107 gfx::Size(image_size + kDropArrowLeftMarginPx + drop_image->width(), | 107 gfx::Size(image_size + kDropArrowLeftMarginPx + drop_image->width(), |
108 image_size), ui::SCALE_FACTOR_100P, false)); | 108 image_size), false)); |
109 canvas->DrawImageInt(*icon, | 109 canvas->DrawImageInt(*icon, |
110 0, 0, icon->width(), icon->height(), | 110 0, 0, icon->width(), icon->height(), |
111 0, 0, image_size, image_size, | 111 0, 0, image_size, image_size, |
112 false); | 112 false); |
113 canvas->DrawImageInt(*drop_image, | 113 canvas->DrawImageInt(*drop_image, |
114 image_size + kDropArrowLeftMarginPx, | 114 image_size + kDropArrowLeftMarginPx, |
115 image_size / 2); | 115 image_size / 2); |
116 [owner_ setButtonImage:gfx::SkBitmapToNSImage( | 116 [owner_ setButtonImage:gfx::SkBitmapToNSImage(canvas->ExtractBitmap())]; |
117 canvas->ExtractImageRep().sk_bitmap())]; | |
118 } | 117 } |
119 | 118 |
120 // Overridden from ExtensionInfoBarDelegate::DelegateObserver: | 119 // Overridden from ExtensionInfoBarDelegate::DelegateObserver: |
121 virtual void OnDelegateDeleted() { | 120 virtual void OnDelegateDeleted() { |
122 delegate_ = NULL; | 121 delegate_ = NULL; |
123 } | 122 } |
124 | 123 |
125 private: | 124 private: |
126 // Weak. Owns us. | 125 // Weak. Owns us. |
127 ExtensionInfoBarController* owner_; | 126 ExtensionInfoBarController* owner_; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 272 |
274 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { | 273 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { |
275 NSWindow* window = | 274 NSWindow* window = |
276 [(NSView*)owner->web_contents()->GetContentNativeView() window]; | 275 [(NSView*)owner->web_contents()->GetContentNativeView() window]; |
277 ExtensionInfoBarController* controller = | 276 ExtensionInfoBarController* controller = |
278 [[ExtensionInfoBarController alloc] initWithDelegate:this | 277 [[ExtensionInfoBarController alloc] initWithDelegate:this |
279 owner:owner | 278 owner:owner |
280 window:window]; | 279 window:window]; |
281 return new InfoBar(controller, this); | 280 return new InfoBar(controller, this); |
282 } | 281 } |
OLD | NEW |