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_action_api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_action_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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // static | 246 // static |
247 void ExtensionActionAPI::SetBrowserActionVisibility( | 247 void ExtensionActionAPI::SetBrowserActionVisibility( |
248 ExtensionPrefs* prefs, | 248 ExtensionPrefs* prefs, |
249 const std::string& extension_id, | 249 const std::string& extension_id, |
250 bool visible) { | 250 bool visible) { |
251 if (GetBrowserActionVisibility(prefs, extension_id) == visible) | 251 if (GetBrowserActionVisibility(prefs, extension_id) == visible) |
252 return; | 252 return; |
253 | 253 |
254 prefs->UpdateExtensionPref(extension_id, | 254 prefs->UpdateExtensionPref(extension_id, |
255 kBrowserActionVisible, | 255 kBrowserActionVisible, |
256 Value::CreateBooleanValue(visible)); | 256 new base::FundamentalValue(visible)); |
257 content::NotificationService::current()->Notify( | 257 content::NotificationService::current()->Notify( |
258 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 258 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
259 content::Source<ExtensionPrefs>(prefs), | 259 content::Source<ExtensionPrefs>(prefs), |
260 content::Details<const std::string>(&extension_id)); | 260 content::Details<const std::string>(&extension_id)); |
261 } | 261 } |
262 | 262 |
263 // | 263 // |
264 // ExtensionActionStorageManager | 264 // ExtensionActionStorageManager |
265 // | 265 // |
266 | 266 |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 if (!ParseCSSColorString(color_string, &color)) | 648 if (!ParseCSSColorString(color_string, &color)) |
649 return false; | 649 return false; |
650 } | 650 } |
651 | 651 |
652 extension_action_->SetBadgeBackgroundColor(tab_id_, color); | 652 extension_action_->SetBadgeBackgroundColor(tab_id_, color); |
653 NotifyChange(); | 653 NotifyChange(); |
654 return true; | 654 return true; |
655 } | 655 } |
656 | 656 |
657 bool ExtensionActionGetTitleFunction::RunExtensionAction() { | 657 bool ExtensionActionGetTitleFunction::RunExtensionAction() { |
658 SetResult(Value::CreateStringValue(extension_action_->GetTitle(tab_id_))); | 658 SetResult(new base::StringValue(extension_action_->GetTitle(tab_id_))); |
659 return true; | 659 return true; |
660 } | 660 } |
661 | 661 |
662 bool ExtensionActionGetPopupFunction::RunExtensionAction() { | 662 bool ExtensionActionGetPopupFunction::RunExtensionAction() { |
663 SetResult( | 663 SetResult( |
664 Value::CreateStringValue(extension_action_->GetPopupUrl(tab_id_).spec())); | 664 new base::StringValue(extension_action_->GetPopupUrl(tab_id_).spec())); |
665 return true; | 665 return true; |
666 } | 666 } |
667 | 667 |
668 bool ExtensionActionGetBadgeTextFunction::RunExtensionAction() { | 668 bool ExtensionActionGetBadgeTextFunction::RunExtensionAction() { |
669 SetResult(Value::CreateStringValue(extension_action_->GetBadgeText(tab_id_))); | 669 SetResult(new base::StringValue(extension_action_->GetBadgeText(tab_id_))); |
670 return true; | 670 return true; |
671 } | 671 } |
672 | 672 |
673 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { | 673 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { |
674 base::ListValue* list = new base::ListValue(); | 674 base::ListValue* list = new base::ListValue(); |
675 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); | 675 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); |
676 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); | 676 list->Append( |
677 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); | 677 new base::FundamentalValue(static_cast<int>(SkColorGetR(color)))); |
678 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); | 678 list->Append( |
679 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); | 679 new base::FundamentalValue(static_cast<int>(SkColorGetG(color)))); |
| 680 list->Append( |
| 681 new base::FundamentalValue(static_cast<int>(SkColorGetB(color)))); |
| 682 list->Append( |
| 683 new base::FundamentalValue(static_cast<int>(SkColorGetA(color)))); |
680 SetResult(list); | 684 SetResult(list); |
681 return true; | 685 return true; |
682 } | 686 } |
683 | 687 |
684 // | 688 // |
685 // ScriptBadgeGetAttentionFunction | 689 // ScriptBadgeGetAttentionFunction |
686 // | 690 // |
687 | 691 |
688 ScriptBadgeGetAttentionFunction::~ScriptBadgeGetAttentionFunction() {} | 692 ScriptBadgeGetAttentionFunction::~ScriptBadgeGetAttentionFunction() {} |
689 | 693 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 return true; | 763 return true; |
760 } | 764 } |
761 | 765 |
762 bool EnablePageActionsFunction::RunImpl() { | 766 bool EnablePageActionsFunction::RunImpl() { |
763 return SetPageActionEnabled(true); | 767 return SetPageActionEnabled(true); |
764 } | 768 } |
765 | 769 |
766 bool DisablePageActionsFunction::RunImpl() { | 770 bool DisablePageActionsFunction::RunImpl() { |
767 return SetPageActionEnabled(false); | 771 return SetPageActionEnabled(false); |
768 } | 772 } |
OLD | NEW |