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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 10914244: Remove support for page_action.icons, and the legacy code surrounding it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: constants removed Created 8 years, 3 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/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 string16* error) { 803 string16* error) {
804 scoped_ptr<ExtensionAction> result(new ExtensionAction(id(), action_type)); 804 scoped_ptr<ExtensionAction> result(new ExtensionAction(id(), action_type));
805 805
806 // Page/script actions are hidden/disabled by default, and browser actions are 806 // Page/script actions are hidden/disabled by default, and browser actions are
807 // visible/enabled by default. 807 // visible/enabled by default.
808 result->SetAppearance(ExtensionAction::kDefaultTabId, 808 result->SetAppearance(ExtensionAction::kDefaultTabId,
809 action_type == ExtensionAction::TYPE_BROWSER ? 809 action_type == ExtensionAction::TYPE_BROWSER ?
810 ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE); 810 ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE);
811 811
812 if (manifest_version_ == 1) { 812 if (manifest_version_ == 1) {
813 // kPageActionIcons is obsolete, and used by very few extensions. Continue
814 // loading it, but only take the first icon as the default_icon path.
813 const ListValue* icons = NULL; 815 const ListValue* icons = NULL;
814 if (extension_action->HasKey(keys::kPageActionIcons) && 816 if (extension_action->HasKey(keys::kPageActionIcons) &&
815 extension_action->GetList(keys::kPageActionIcons, &icons)) { 817 extension_action->GetList(keys::kPageActionIcons, &icons)) {
816 for (ListValue::const_iterator iter = icons->begin(); 818 for (ListValue::const_iterator iter = icons->begin();
817 iter != icons->end(); ++iter) { 819 iter != icons->end(); ++iter) {
818 std::string path; 820 std::string path;
819 if (!(*iter)->GetAsString(&path) || path.empty()) { 821 if (!(*iter)->GetAsString(&path) || path.empty()) {
820 *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath); 822 *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath);
821 return scoped_ptr<ExtensionAction>(); 823 return scoped_ptr<ExtensionAction>();
822 } 824 }
823 825
824 result->icon_paths()->push_back(path); 826 result->set_default_icon_path(path);
827 break;
825 } 828 }
826 } 829 }
827 830
828 std::string id; 831 std::string id;
829 if (extension_action->HasKey(keys::kPageActionId)) { 832 if (extension_action->HasKey(keys::kPageActionId)) {
830 if (!extension_action->GetString(keys::kPageActionId, &id)) { 833 if (!extension_action->GetString(keys::kPageActionId, &id)) {
831 *error = ASCIIToUTF16(errors::kInvalidPageActionId); 834 *error = ASCIIToUTF16(errors::kInvalidPageActionId);
832 return scoped_ptr<ExtensionAction>(); 835 return scoped_ptr<ExtensionAction>();
833 } 836 }
834 result->set_id(id); 837 result->set_id(id);
(...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after
3192 for (DictionaryValue::key_iterator it = theme_images->begin_keys(); 3195 for (DictionaryValue::key_iterator it = theme_images->begin_keys();
3193 it != theme_images->end_keys(); ++it) { 3196 it != theme_images->end_keys(); ++it) {
3194 std::string val; 3197 std::string val;
3195 if (theme_images->GetStringWithoutPathExpansion(*it, &val)) 3198 if (theme_images->GetStringWithoutPathExpansion(*it, &val))
3196 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(val))); 3199 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(val)));
3197 } 3200 }
3198 } 3201 }
3199 3202
3200 // Page action icons. 3203 // Page action icons.
3201 if (page_action()) { 3204 if (page_action()) {
3202 std::vector<std::string>* icon_paths = page_action()->icon_paths(); 3205 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(
3203 for (std::vector<std::string>::iterator iter = icon_paths->begin(); 3206 page_action()->default_icon_path())));
3204 iter != icon_paths->end(); ++iter) {
3205 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(*iter)));
3206 }
3207 } 3207 }
3208 3208
3209 // Browser action icons. 3209 // Browser action icons.
3210 if (browser_action()) { 3210 if (browser_action()) {
3211 std::vector<std::string>* icon_paths = browser_action()->icon_paths(); 3211 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(
3212 for (std::vector<std::string>::iterator iter = icon_paths->begin(); 3212 browser_action()->default_icon_path())));
3213 iter != icon_paths->end(); ++iter) {
3214 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(*iter)));
3215 }
3216 } 3213 }
3217 3214
3218 return image_paths; 3215 return image_paths;
3219 } 3216 }
3220 3217
3221 GURL Extension::GetFullLaunchURL() const { 3218 GURL Extension::GetFullLaunchURL() const {
3222 return launch_local_path().empty() ? GURL(launch_web_url()) : 3219 return launch_local_path().empty() ? GURL(launch_web_url()) :
3223 url().Resolve(launch_local_path()); 3220 url().Resolve(launch_local_path());
3224 } 3221 }
3225 3222
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
3965 3962
3966 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3963 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3967 const Extension* extension, 3964 const Extension* extension,
3968 const PermissionSet* permissions, 3965 const PermissionSet* permissions,
3969 Reason reason) 3966 Reason reason)
3970 : reason(reason), 3967 : reason(reason),
3971 extension(extension), 3968 extension(extension),
3972 permissions(permissions) {} 3969 permissions(permissions) {}
3973 3970
3974 } // namespace extensions 3971 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/page_action.json ('k') | chrome/common/extensions/extension_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698