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

Unified Diff: chrome/browser/extensions/api/extension_action/extension_action_api.cc

Issue 477193003: Refactor setIcon to allow for more general use of imageData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/extension_action/extension_action_api.cc
diff --git a/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
index 8b2ed3f19c55e1e2622b52552a3910a376a0d394..73ef15630e45ce105811da543ba0a08294d286dc 100644
--- a/chrome/browser/extensions/api/extension_action/extension_action_api.cc
+++ b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
@@ -671,14 +671,17 @@ bool ExtensionActionSetIconFunction::RunExtensionAction() {
// setIcon can take a variant argument: either a dictionary of canvas
// ImageData, or an icon index.
base::DictionaryValue* canvas_set = NULL;
- int icon_index;
if (details_->GetDictionary("imageData", &canvas_set)) {
gfx::ImageSkia icon;
// Extract icon representations from the ImageDataSet dictionary.
for (size_t i = 0; i < arraysize(kIconSizes); i++) {
- base::BinaryValue* binary;
- if (canvas_set->GetBinary(kIconSizes[i].size_string, &binary)) {
- IPC::Message pickle(binary->GetBuffer(), binary->GetSize());
+ std::string binary_string64;
+ if (canvas_set->GetString(kIconSizes[i].size_string, &binary_string64)) {
+ std::string binary_data;
+ if (!base::Base64Decode(binary_string64, &binary_data))
+ return false;
+
+ IPC::Message pickle(binary_data.c_str(), binary_data.length());
not at google - send to devlin 2014/08/19 00:04:43 You should only need to do this Binary -> std::str
gpdavis 2014/08/19 00:54:15 You don't think we should keep it this way so it w
not at google - send to devlin 2014/08/19 17:32:29 There are 2 things here: (1) The serialization for
PickleIterator iter(pickle);
SkBitmap bitmap;
EXTENSION_FUNCTION_VALIDATE(IPC::ReadParam(&pickle, &iter, &bitmap));
@@ -689,7 +692,7 @@ bool ExtensionActionSetIconFunction::RunExtensionAction() {
}
extension_action_->SetIcon(tab_id_, gfx::Image(icon));
- } else if (details_->GetInteger("iconIndex", &icon_index)) {
+ } else if (details_->HasKey("iconIndex")) {
// Obsolete argument: ignore it.
return true;
} else {

Powered by Google App Engine
This is Rietveld 408576698