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_page_actions_module.h" | 5 #include "chrome/browser/extensions/extension_page_actions_module.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" | 10 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 EXTENSION_FUNCTION_VALIDATE(args->GetInteger("tabId", &tab_id)); | 154 EXTENSION_FUNCTION_VALIDATE(args->GetInteger("tabId", &tab_id)); |
155 if (!InitCommon(tab_id)) | 155 if (!InitCommon(tab_id)) |
156 return false; | 156 return false; |
157 | 157 |
158 // setIcon can take a variant argument: either a canvas ImageData, or an | 158 // setIcon can take a variant argument: either a canvas ImageData, or an |
159 // icon index. | 159 // icon index. |
160 base::BinaryValue* binary; | 160 base::BinaryValue* binary; |
161 int icon_index; | 161 int icon_index; |
162 if (args->GetBinary("imageData", &binary)) { | 162 if (args->GetBinary("imageData", &binary)) { |
163 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); | 163 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); |
164 void* iter = NULL; | 164 PickleIterator iter(bitmap_pickle); |
165 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 165 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
166 EXTENSION_FUNCTION_VALIDATE( | 166 EXTENSION_FUNCTION_VALIDATE( |
167 IPC::ReadParam(&bitmap_pickle, &iter, bitmap.get())); | 167 IPC::ReadParam(&bitmap_pickle, &iter, bitmap.get())); |
168 page_action_->SetIcon(tab_id, *bitmap); | 168 page_action_->SetIcon(tab_id, *bitmap); |
169 } else if (args->GetInteger("iconIndex", &icon_index)) { | 169 } else if (args->GetInteger("iconIndex", &icon_index)) { |
170 if (icon_index < 0 || static_cast<size_t>(icon_index) >= | 170 if (icon_index < 0 || static_cast<size_t>(icon_index) >= |
171 page_action_->icon_paths()->size()) { | 171 page_action_->icon_paths()->size()) { |
172 error_ = kIconIndexOutOfBounds; | 172 error_ = kIconIndexOutOfBounds; |
173 return false; | 173 return false; |
174 } | 174 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 if (!InitCommon(tab_id)) | 285 if (!InitCommon(tab_id)) |
286 return false; | 286 return false; |
287 | 287 |
288 std::string text; | 288 std::string text; |
289 EXTENSION_FUNCTION_VALIDATE(args->GetString("text", &text)); | 289 EXTENSION_FUNCTION_VALIDATE(args->GetString("text", &text)); |
290 | 290 |
291 page_action_->SetBadgeText(tab_id, text); | 291 page_action_->SetBadgeText(tab_id, text); |
292 contents_->extension_tab_helper()->PageActionStateChanged(); | 292 contents_->extension_tab_helper()->PageActionStateChanged(); |
293 return true; | 293 return true; |
294 } | 294 } |
OLD | NEW |