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/extensions/extension_action.h" | 5 #include "chrome/browser/extensions/extension_action.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 continue; | 143 continue; |
144 } | 144 } |
145 base::PickleIterator pickle_iter(pickle); | 145 base::PickleIterator pickle_iter(pickle); |
146 SkBitmap bitmap; | 146 SkBitmap bitmap; |
147 if (!IPC::ReadParam(&pickle, &pickle_iter, &bitmap)) | 147 if (!IPC::ReadParam(&pickle, &pickle_iter, &bitmap)) |
148 return false; | 148 return false; |
149 CHECK(!bitmap.isNull()); | 149 CHECK(!bitmap.isNull()); |
150 | 150 |
151 // Chrome helpfully scales the provided icon(s), but let's not go overboard. | 151 // Chrome helpfully scales the provided icon(s), but let's not go overboard. |
152 const int kActionIconMaxSize = 10 * extension_misc::EXTENSION_ICON_ACTION; | 152 const int kActionIconMaxSize = 10 * extension_misc::EXTENSION_ICON_ACTION; |
153 if (bitmap.drawsNothing() || bitmap.width() != bitmap.height() || | 153 if (bitmap.drawsNothing() || bitmap.width() > kActionIconMaxSize) { |
lazyboy
2016/02/05 02:15:57
nit: remove {}
Devlin
2016/02/05 20:45:18
Done.
| |
154 bitmap.width() > kActionIconMaxSize) { | |
155 continue; | 154 continue; |
156 } | 155 } |
157 | 156 |
158 float scale = | 157 float scale = |
159 static_cast<float>(bitmap.width()) / ExtensionAction::ActionIconSize(); | 158 static_cast<float>(bitmap.width()) / ExtensionAction::ActionIconSize(); |
160 icon->AddRepresentation(gfx::ImageSkiaRep(bitmap, scale)); | 159 icon->AddRepresentation(gfx::ImageSkiaRep(bitmap, scale)); |
161 } | 160 } |
162 return true; | 161 return true; |
163 } | 162 } |
164 | 163 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 // If there is a default icon, the icon width will be set depending on our | 327 // If there is a default icon, the icon width will be set depending on our |
329 // action type. | 328 // action type. |
330 if (default_icon_) | 329 if (default_icon_) |
331 return ActionIconSize(); | 330 return ActionIconSize(); |
332 | 331 |
333 // If no icon has been set and there is no default icon, we need favicon | 332 // If no icon has been set and there is no default icon, we need favicon |
334 // width. | 333 // width. |
335 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 334 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
336 IDR_EXTENSIONS_FAVICON).Width(); | 335 IDR_EXTENSIONS_FAVICON).Width(); |
337 } | 336 } |
OLD | NEW |