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/api/extension_action/extension_actions_api.h " | 5 #include "chrome/browser/extensions/api/extension_action/extension_actions_api.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 "base/string_piece.h" | 10 #include "base/string_piece.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 // setIcon can take a variant argument: either a canvas ImageData, or an | 205 // setIcon can take a variant argument: either a canvas ImageData, or an |
206 // icon index. | 206 // icon index. |
207 base::BinaryValue* binary = NULL; | 207 base::BinaryValue* binary = NULL; |
208 int icon_index; | 208 int icon_index; |
209 if (details_->GetBinary("imageData", &binary)) { | 209 if (details_->GetBinary("imageData", &binary)) { |
210 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); | 210 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); |
211 PickleIterator iter(bitmap_pickle); | 211 PickleIterator iter(bitmap_pickle); |
212 SkBitmap bitmap; | 212 SkBitmap bitmap; |
213 EXTENSION_FUNCTION_VALIDATE( | 213 EXTENSION_FUNCTION_VALIDATE( |
214 IPC::ReadParam(&bitmap_pickle, &iter, &bitmap)); | 214 IPC::ReadParam(&bitmap_pickle, &iter, &bitmap)); |
215 extension_action_->SetIcon(tab_id_, bitmap); | 215 extension_action_->SetIcon(tab_id_, gfx::Image(bitmap)); |
Jeffrey Yasskin
2012/08/09 21:39:04
Do you want to use the ImageSkiaRep(bitmap, SCALE_
tbarzic
2012/08/10 06:24:08
I don't think it's necessary.. I will probably jus
| |
216 } else if (details_->GetInteger("iconIndex", &icon_index)) { | 216 } else if (details_->GetInteger("iconIndex", &icon_index)) { |
217 // If --enable-script-badges is on there might legitimately be an iconIndex | 217 // If --enable-script-badges is on there might legitimately be an iconIndex |
218 // set. Until we decide what to do with that, ignore. | 218 // set. Until we decide what to do with that, ignore. |
219 if (!GetExtension()->page_action()) | 219 if (!GetExtension()->page_action()) |
220 return true; | 220 return true; |
221 if (icon_index < 0 || | 221 if (icon_index < 0 || |
222 static_cast<size_t>(icon_index) >= | 222 static_cast<size_t>(icon_index) >= |
223 extension_action_->icon_paths()->size()) { | 223 extension_action_->icon_paths()->size()) { |
224 error_ = kIconIndexOutOfBounds; | 224 error_ = kIconIndexOutOfBounds; |
225 return false; | 225 return false; |
226 } | 226 } |
227 extension_action_->SetIcon(tab_id_, SkBitmap()); | 227 extension_action_->SetIcon(tab_id_, gfx::Image()); |
228 extension_action_->SetIconIndex(tab_id_, icon_index); | 228 extension_action_->SetIconIndex(tab_id_, icon_index); |
229 } else { | 229 } else { |
230 EXTENSION_FUNCTION_VALIDATE(false); | 230 EXTENSION_FUNCTION_VALIDATE(false); |
231 } | 231 } |
232 NotifyChange(); | 232 NotifyChange(); |
233 return true; | 233 return true; |
234 } | 234 } |
235 | 235 |
236 bool ExtensionActionSetTitleFunction::RunExtensionAction() { | 236 bool ExtensionActionSetTitleFunction::RunExtensionAction() { |
237 std::string title; | 237 std::string title; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { | 309 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { |
310 ListValue* list = new ListValue(); | 310 ListValue* list = new ListValue(); |
311 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); | 311 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); |
312 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); | 312 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); |
313 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); | 313 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); |
314 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); | 314 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); |
315 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); | 315 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); |
316 SetResult(list); | 316 SetResult(list); |
317 return true; | 317 return true; |
318 } | 318 } |
OLD | NEW |