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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/values.h" |
13 #include "chrome/grit/theme_resources.h" | 14 #include "chrome/grit/theme_resources.h" |
14 #include "extensions/browser/extension_icon_image.h" | 15 #include "extensions/browser/extension_icon_image.h" |
15 #include "extensions/browser/extension_icon_placeholder.h" | 16 #include "extensions/browser/extension_icon_placeholder.h" |
16 #include "extensions/common/constants.h" | 17 #include "extensions/common/constants.h" |
17 #include "extensions/common/extension_icon_set.h" | 18 #include "extensions/common/extension_icon_set.h" |
18 #include "extensions/common/manifest_handlers/icons_handler.h" | 19 #include "extensions/common/manifest_handlers/icons_handler.h" |
19 #include "ipc/ipc_message.h" | 20 #include "ipc/ipc_message.h" |
20 #include "ipc/ipc_message_utils.h" | 21 #include "ipc/ipc_message_utils.h" |
21 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
22 #include "third_party/skia/include/core/SkCanvas.h" | 23 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 119 |
119 void ExtensionAction::SetIcon(int tab_id, const gfx::Image& image) { | 120 void ExtensionAction::SetIcon(int tab_id, const gfx::Image& image) { |
120 SetValue(&icon_, tab_id, image); | 121 SetValue(&icon_, tab_id, image); |
121 } | 122 } |
122 | 123 |
123 bool ExtensionAction::ParseIconFromCanvasDictionary( | 124 bool ExtensionAction::ParseIconFromCanvasDictionary( |
124 const base::DictionaryValue& dict, | 125 const base::DictionaryValue& dict, |
125 gfx::ImageSkia* icon) { | 126 gfx::ImageSkia* icon) { |
126 for (base::DictionaryValue::Iterator iter(dict); !iter.IsAtEnd(); | 127 for (base::DictionaryValue::Iterator iter(dict); !iter.IsAtEnd(); |
127 iter.Advance()) { | 128 iter.Advance()) { |
128 const base::BinaryValue* image_data; | 129 const base::Value* image_data; |
129 std::string binary_string64; | 130 std::string binary_string64; |
130 IPC::Message pickle; | 131 IPC::Message pickle; |
131 if (iter.value().GetAsBinary(&image_data)) { | 132 if (iter.value().GetAsBinary(&image_data)) { |
132 pickle = IPC::Message(image_data->GetBuffer(), image_data->GetSize()); | 133 pickle = IPC::Message(image_data->GetBuffer(), image_data->GetSize()); |
133 } else if (iter.value().GetAsString(&binary_string64)) { | 134 } else if (iter.value().GetAsString(&binary_string64)) { |
134 std::string binary_string; | 135 std::string binary_string; |
135 if (!base::Base64Decode(binary_string64, &binary_string)) | 136 if (!base::Base64Decode(binary_string64, &binary_string)) |
136 return false; | 137 return false; |
137 pickle = IPC::Message(binary_string.c_str(), binary_string.length()); | 138 pickle = IPC::Message(binary_string.c_str(), binary_string.length()); |
138 } else { | 139 } else { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 return icon.Width(); | 312 return icon.Width(); |
312 // If there is a default icon, the icon width will be set depending on our | 313 // If there is a default icon, the icon width will be set depending on our |
313 // action type. | 314 // action type. |
314 if (default_icon_) | 315 if (default_icon_) |
315 return ActionIconSize(); | 316 return ActionIconSize(); |
316 | 317 |
317 // If no icon has been set and there is no default icon, we need favicon | 318 // If no icon has been set and there is no default icon, we need favicon |
318 // width. | 319 // width. |
319 return FallbackIcon().Width(); | 320 return FallbackIcon().Width(); |
320 } | 321 } |
OLD | NEW |