Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/browser/extensions/api/extension_action/extension_action_api.cc

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 } 144 }
145 action->SetIcon(kTabId, gfx::Image(icon)); 145 action->SetIcon(kTabId, gfx::Image(icon));
146 } 146 }
147 } 147 }
148 148
149 // Store |action|'s default values in a DictionaryValue for use in storing to 149 // Store |action|'s default values in a DictionaryValue for use in storing to
150 // disk. 150 // disk.
151 scoped_ptr<base::DictionaryValue> DefaultsToValue(ExtensionAction* action) { 151 scoped_ptr<base::DictionaryValue> DefaultsToValue(ExtensionAction* action) {
152 const int kTabId = ExtensionAction::kDefaultTabId; 152 const int kTabId = ExtensionAction::kDefaultTabId;
153 scoped_ptr<base::DictionaryValue> dict(new DictionaryValue()); 153 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
154 154
155 dict->SetString(kPopupUrlStorageKey, action->GetPopupUrl(kTabId).spec()); 155 dict->SetString(kPopupUrlStorageKey, action->GetPopupUrl(kTabId).spec());
156 dict->SetString(kTitleStorageKey, action->GetTitle(kTabId)); 156 dict->SetString(kTitleStorageKey, action->GetTitle(kTabId));
157 dict->SetString(kBadgeTextStorageKey, action->GetBadgeText(kTabId)); 157 dict->SetString(kBadgeTextStorageKey, action->GetBadgeText(kTabId));
158 dict->SetString(kBadgeBackgroundColorStorageKey, 158 dict->SetString(kBadgeBackgroundColorStorageKey,
159 SkColorToRawString(action->GetBadgeBackgroundColor(kTabId))); 159 SkColorToRawString(action->GetBadgeBackgroundColor(kTabId)));
160 dict->SetString(kBadgeTextColorStorageKey, 160 dict->SetString(kBadgeTextColorStorageKey,
161 SkColorToRawString(action->GetBadgeTextColor(kTabId))); 161 SkColorToRawString(action->GetBadgeTextColor(kTabId)));
162 dict->SetInteger(kAppearanceStorageKey, 162 dict->SetInteger(kAppearanceStorageKey,
163 action->GetIsVisible(kTabId) ? 163 action->GetIsVisible(kTabId) ?
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 NotifyChange(); 624 NotifyChange();
625 return true; 625 return true;
626 } 626 }
627 627
628 bool ExtensionActionSetBadgeBackgroundColorFunction::RunExtensionAction() { 628 bool ExtensionActionSetBadgeBackgroundColorFunction::RunExtensionAction() {
629 EXTENSION_FUNCTION_VALIDATE(details_); 629 EXTENSION_FUNCTION_VALIDATE(details_);
630 Value* color_value = NULL; 630 Value* color_value = NULL;
631 EXTENSION_FUNCTION_VALIDATE(details_->Get("color", &color_value)); 631 EXTENSION_FUNCTION_VALIDATE(details_->Get("color", &color_value));
632 SkColor color = 0; 632 SkColor color = 0;
633 if (color_value->IsType(Value::TYPE_LIST)) { 633 if (color_value->IsType(Value::TYPE_LIST)) {
634 ListValue* list = NULL; 634 base::ListValue* list = NULL;
635 EXTENSION_FUNCTION_VALIDATE(details_->GetList("color", &list)); 635 EXTENSION_FUNCTION_VALIDATE(details_->GetList("color", &list));
636 EXTENSION_FUNCTION_VALIDATE(list->GetSize() == 4); 636 EXTENSION_FUNCTION_VALIDATE(list->GetSize() == 4);
637 637
638 int color_array[4] = {0}; 638 int color_array[4] = {0};
639 for (size_t i = 0; i < arraysize(color_array); ++i) { 639 for (size_t i = 0; i < arraysize(color_array); ++i) {
640 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i])); 640 EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i]));
641 } 641 }
642 642
643 color = SkColorSetARGB(color_array[3], color_array[0], 643 color = SkColorSetARGB(color_array[3], color_array[0],
644 color_array[1], color_array[2]); 644 color_array[1], color_array[2]);
(...skipping 19 matching lines...) Expand all
664 Value::CreateStringValue(extension_action_->GetPopupUrl(tab_id_).spec())); 664 Value::CreateStringValue(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(Value::CreateStringValue(extension_action_->GetBadgeText(tab_id_)));
670 return true; 670 return true;
671 } 671 }
672 672
673 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { 673 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
674 ListValue* list = new 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(Value::CreateIntegerValue(SkColorGetR(color)));
677 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); 677 list->Append(Value::CreateIntegerValue(SkColorGetG(color)));
678 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); 678 list->Append(Value::CreateIntegerValue(SkColorGetB(color)));
679 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); 679 list->Append(Value::CreateIntegerValue(SkColorGetA(color)));
680 SetResult(list); 680 SetResult(list);
681 return true; 681 return true;
682 } 682 }
683 683
684 // 684 //
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 return true; 759 return true;
760 } 760 }
761 761
762 bool EnablePageActionsFunction::RunImpl() { 762 bool EnablePageActionsFunction::RunImpl() {
763 return SetPageActionEnabled(true); 763 return SetPageActionEnabled(true);
764 } 764 }
765 765
766 bool DisablePageActionsFunction::RunImpl() { 766 bool DisablePageActionsFunction::RunImpl() {
767 return SetPageActionEnabled(false); 767 return SetPageActionEnabled(false);
768 } 768 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698