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/base64.h" | 9 #include "base/base64.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 dict->SetString(kPopupUrlStorageKey, action->GetPopupUrl(kTabId).spec()); | 119 dict->SetString(kPopupUrlStorageKey, action->GetPopupUrl(kTabId).spec()); |
120 dict->SetString(kTitleStorageKey, action->GetTitle(kTabId)); | 120 dict->SetString(kTitleStorageKey, action->GetTitle(kTabId)); |
121 dict->SetString(kBadgeTextStorageKey, action->GetBadgeText(kTabId)); | 121 dict->SetString(kBadgeTextStorageKey, action->GetBadgeText(kTabId)); |
122 dict->SetString(kBadgeBackgroundColorStorageKey, | 122 dict->SetString(kBadgeBackgroundColorStorageKey, |
123 SkColorToRawString(action->GetBadgeBackgroundColor(kTabId))); | 123 SkColorToRawString(action->GetBadgeBackgroundColor(kTabId))); |
124 dict->SetString(kBadgeTextColorStorageKey, | 124 dict->SetString(kBadgeTextColorStorageKey, |
125 SkColorToRawString(action->GetBadgeTextColor(kTabId))); | 125 SkColorToRawString(action->GetBadgeTextColor(kTabId))); |
126 dict->SetInteger(kAppearanceStorageKey, | 126 dict->SetInteger(kAppearanceStorageKey, |
127 action->GetIsVisible(kTabId) ? | 127 action->GetIsVisible(kTabId) ? |
128 ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE); | 128 ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE); |
129 dict->SetString(kIconStorageKey, ImageToString(action->GetIcon(kTabId))); | 129 dict->SetString(kIconStorageKey, |
tbarzic
2012/08/29 22:01:29
this is not really intended behaviour (it will sav
| |
130 ImageToString(action->GetIcon(kTabId, NULL))); | |
130 | 131 |
131 return dict.Pass(); | 132 return dict.Pass(); |
132 } | 133 } |
133 | 134 |
134 } // namespace | 135 } // namespace |
135 | 136 |
136 namespace extensions { | 137 namespace extensions { |
137 | 138 |
138 // | 139 // |
139 // ExtensionActionStorageManager | 140 // ExtensionActionStorageManager |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 PickleIterator iter(bitmap_pickle); | 412 PickleIterator iter(bitmap_pickle); |
412 SkBitmap bitmap; | 413 SkBitmap bitmap; |
413 EXTENSION_FUNCTION_VALIDATE(IPC::ReadParam(&bitmap_pickle, &iter, &bitmap)); | 414 EXTENSION_FUNCTION_VALIDATE(IPC::ReadParam(&bitmap_pickle, &iter, &bitmap)); |
414 CHECK(!bitmap.isNull()); | 415 CHECK(!bitmap.isNull()); |
415 extension_action_->SetIcon(tab_id_, gfx::Image(bitmap)); | 416 extension_action_->SetIcon(tab_id_, gfx::Image(bitmap)); |
416 } else if (details_->GetInteger("iconIndex", &icon_index)) { | 417 } else if (details_->GetInteger("iconIndex", &icon_index)) { |
417 // If --enable-script-badges is on there might legitimately be an iconIndex | 418 // If --enable-script-badges is on there might legitimately be an iconIndex |
418 // set. Until we decide what to do with that, ignore. | 419 // set. Until we decide what to do with that, ignore. |
419 if (!GetExtension()->page_action()) | 420 if (!GetExtension()->page_action()) |
420 return true; | 421 return true; |
421 if (icon_index < 0 || | 422 if (!extension_action_->IsValidIconIndex(icon_index)) { |
422 static_cast<size_t>(icon_index) >= | |
423 extension_action_->icon_paths()->size()) { | |
424 error_ = kIconIndexOutOfBounds; | 423 error_ = kIconIndexOutOfBounds; |
425 return false; | 424 return false; |
426 } | 425 } |
427 extension_action_->SetIcon(tab_id_, gfx::Image()); | 426 extension_action_->SetIcon(tab_id_, gfx::Image()); |
428 extension_action_->SetIconIndex(tab_id_, icon_index); | 427 extension_action_->SetIconIndex(tab_id_, icon_index); |
429 } else { | 428 } else { |
430 EXTENSION_FUNCTION_VALIDATE(false); | 429 EXTENSION_FUNCTION_VALIDATE(false); |
431 } | 430 } |
431 LOG(ERROR) << "NOTIFY CHANGED"; | |
432 NotifyChange(); | 432 NotifyChange(); |
433 return true; | 433 return true; |
434 } | 434 } |
435 | 435 |
436 bool ExtensionActionSetTitleFunction::RunExtensionAction() { | 436 bool ExtensionActionSetTitleFunction::RunExtensionAction() { |
437 std::string title; | 437 std::string title; |
438 EXTENSION_FUNCTION_VALIDATE(details_->GetString("title", &title)); | 438 EXTENSION_FUNCTION_VALIDATE(details_->GetString("title", &title)); |
439 extension_action_->SetTitle(tab_id_, title); | 439 extension_action_->SetTitle(tab_id_, title); |
440 NotifyChange(); | 440 NotifyChange(); |
441 return true; | 441 return true; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { | 509 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { |
510 ListValue* list = new ListValue(); | 510 ListValue* list = new ListValue(); |
511 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); | 511 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); |
512 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); | 512 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); |
513 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); | 513 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); |
514 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); | 514 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); |
515 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); | 515 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); |
516 SetResult(list); | 516 SetResult(list); |
517 return true; | 517 return true; |
518 } | 518 } |
OLD | NEW |