OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 DictionaryValue* args; | 148 DictionaryValue* args; |
149 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args)); | 149 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args)); |
150 | 150 |
151 int tab_id; | 151 int tab_id; |
152 EXTENSION_FUNCTION_VALIDATE(args->GetInteger("tabId", &tab_id)); | 152 EXTENSION_FUNCTION_VALIDATE(args->GetInteger("tabId", &tab_id)); |
153 if (!InitCommon(tab_id)) | 153 if (!InitCommon(tab_id)) |
154 return false; | 154 return false; |
155 | 155 |
156 // setIcon can take a variant argument: either a canvas ImageData, or an | 156 // setIcon can take a variant argument: either a canvas ImageData, or an |
157 // icon index. | 157 // icon index. |
158 BinaryValue* binary; | 158 base::BinaryValue* binary; |
159 int icon_index; | 159 int icon_index; |
160 if (args->GetBinary("imageData", &binary)) { | 160 if (args->GetBinary("imageData", &binary)) { |
161 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); | 161 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); |
162 void* iter = NULL; | 162 void* iter = NULL; |
163 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 163 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
164 EXTENSION_FUNCTION_VALIDATE( | 164 EXTENSION_FUNCTION_VALIDATE( |
165 IPC::ReadParam(&bitmap_pickle, &iter, bitmap.get())); | 165 IPC::ReadParam(&bitmap_pickle, &iter, bitmap.get())); |
166 page_action_->SetIcon(tab_id, *bitmap); | 166 page_action_->SetIcon(tab_id, *bitmap); |
167 } else if (args->GetInteger("iconIndex", &icon_index)) { | 167 } else if (args->GetInteger("iconIndex", &icon_index)) { |
168 if (icon_index < 0 || static_cast<size_t>(icon_index) >= | 168 if (icon_index < 0 || static_cast<size_t>(icon_index) >= |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 if (!InitCommon(tab_id)) | 283 if (!InitCommon(tab_id)) |
284 return false; | 284 return false; |
285 | 285 |
286 std::string text; | 286 std::string text; |
287 EXTENSION_FUNCTION_VALIDATE(args->GetString("text", &text)); | 287 EXTENSION_FUNCTION_VALIDATE(args->GetString("text", &text)); |
288 | 288 |
289 page_action_->SetBadgeText(tab_id, text); | 289 page_action_->SetBadgeText(tab_id, text); |
290 contents_->extension_tab_helper()->PageActionStateChanged(); | 290 contents_->extension_tab_helper()->PageActionStateChanged(); |
291 return true; | 291 return true; |
292 } | 292 } |
OLD | NEW |