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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 void ExtensionAction::SetIcon(int tab_id, const gfx::Image& image) { | 120 void ExtensionAction::SetIcon(int tab_id, const gfx::Image& image) { |
121 SetValue(&icon_, tab_id, image); | 121 SetValue(&icon_, tab_id, image); |
122 } | 122 } |
123 | 123 |
124 bool ExtensionAction::ParseIconFromCanvasDictionary( | 124 bool ExtensionAction::ParseIconFromCanvasDictionary( |
125 const base::DictionaryValue& dict, | 125 const base::DictionaryValue& dict, |
126 gfx::ImageSkia* icon) { | 126 gfx::ImageSkia* icon) { |
127 for (base::DictionaryValue::Iterator iter(dict); !iter.IsAtEnd(); | 127 for (base::DictionaryValue::Iterator iter(dict); !iter.IsAtEnd(); |
128 iter.Advance()) { | 128 iter.Advance()) { |
129 const base::Value* image_data; | |
130 std::string binary_string64; | 129 std::string binary_string64; |
131 IPC::Message pickle; | 130 IPC::Message pickle; |
132 if (iter.value().GetAsBinary(&image_data)) { | 131 if (iter.value().is_blob()) { |
133 pickle = IPC::Message(image_data->GetBlob().data(), | 132 pickle = IPC::Message(iter.value().GetBlob().data(), |
134 image_data->GetBlob().size()); | 133 iter.value().GetBlob().size()); |
135 } else if (iter.value().GetAsString(&binary_string64)) { | 134 } else if (iter.value().GetAsString(&binary_string64)) { |
136 std::string binary_string; | 135 std::string binary_string; |
137 if (!base::Base64Decode(binary_string64, &binary_string)) | 136 if (!base::Base64Decode(binary_string64, &binary_string)) |
138 return false; | 137 return false; |
139 pickle = IPC::Message(binary_string.c_str(), binary_string.length()); | 138 pickle = IPC::Message(binary_string.c_str(), binary_string.length()); |
140 } else { | 139 } else { |
141 continue; | 140 continue; |
142 } | 141 } |
143 base::PickleIterator pickle_iter(pickle); | 142 base::PickleIterator pickle_iter(pickle); |
144 SkBitmap bitmap; | 143 SkBitmap bitmap; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 return icon.Width(); | 312 return icon.Width(); |
314 // 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 |
315 // action type. | 314 // action type. |
316 if (default_icon_) | 315 if (default_icon_) |
317 return ActionIconSize(); | 316 return ActionIconSize(); |
318 | 317 |
319 // 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 |
320 // width. | 319 // width. |
321 return FallbackIcon().Width(); | 320 return FallbackIcon().Width(); |
322 } | 321 } |
OLD | NEW |