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

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

Issue 276074: Fix chrome_url_overides to work with packed extensions. (Closed)
Patch Set: review Created 11 years, 2 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 } 1010 }
1011 } 1011 }
1012 1012
1013 // Chrome URL overrides (optional) 1013 // Chrome URL overrides (optional)
1014 if (source.HasKey(keys::kChromeURLOverrides)) { 1014 if (source.HasKey(keys::kChromeURLOverrides)) {
1015 DictionaryValue* overrides; 1015 DictionaryValue* overrides;
1016 if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) { 1016 if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) {
1017 *error = errors::kInvalidChromeURLOverrides; 1017 *error = errors::kInvalidChromeURLOverrides;
1018 return false; 1018 return false;
1019 } 1019 }
1020
1020 // Validate that the overrides are all strings 1021 // Validate that the overrides are all strings
1021 DictionaryValue::key_iterator iter = overrides->begin_keys(); 1022 DictionaryValue::key_iterator iter = overrides->begin_keys();
1022 while (iter != overrides->end_keys()) { 1023 while (iter != overrides->end_keys()) {
1024 std::string page = WideToUTF8(*iter);
1023 // For now, only allow the new tab page. Others will work when we remove 1025 // For now, only allow the new tab page. Others will work when we remove
1024 // this check, but let's keep it simple for now. 1026 // this check, but let's keep it simple for now.
1025 // TODO(erikkay) enable other pages as well 1027 // TODO(erikkay) enable other pages as well
1026 if (WideToUTF8(*iter) != chrome::kChromeUINewTabHost) { 1028 if (page != chrome::kChromeUINewTabHost) {
1027 *error = errors::kInvalidChromeURLOverrides; 1029 *error = errors::kInvalidChromeURLOverrides;
1028 return false; 1030 return false;
1029 } 1031 }
1030 std::string val; 1032 std::string val;
1031 if (!overrides->GetString(*iter, &val)) { 1033 if (!overrides->GetString(*iter, &val)) {
1032 *error = errors::kInvalidChromeURLOverrides; 1034 *error = errors::kInvalidChromeURLOverrides;
1033 return false; 1035 return false;
1034 } 1036 }
1035 // Replace the entry with a fully qualified chrome-extension:// URL. 1037 // Replace the entry with a fully qualified chrome-extension:// URL.
1036 GURL url = GetResourceURL(val); 1038 chrome_url_overrides_[page] = GetResourceURL(val);
1037 overrides->SetString(*iter, url.spec());
1038 ++iter; 1039 ++iter;
1039 } 1040 }
1040 chrome_url_overrides_.reset(
1041 static_cast<DictionaryValue*>(overrides->DeepCopy()));
1042 } 1041 }
1043 1042
1043 // Although |source| is passed in as a const, it's still possible to modify
1044 // it. This is dangerous since the utility process re-uses |source| after
1045 // it calls InitFromValue, passing it up to the browser process which calls
1046 // InitFromValue again. As a result, we need to make sure that nobody
1047 // accidentally modifies it.
1048 DCHECK(source.Equals(manifest_value_.get()));
1049
1044 return true; 1050 return true;
1045 } 1051 }
1046 1052
1047 std::set<FilePath> Extension::GetBrowserImages() { 1053 std::set<FilePath> Extension::GetBrowserImages() {
1048 std::set<FilePath> image_paths; 1054 std::set<FilePath> image_paths;
1049 1055
1050 // extension icons 1056 // extension icons
1051 for (std::map<int, std::string>::iterator iter = icons_.begin(); 1057 for (std::map<int, std::string>::iterator iter = icons_.begin();
1052 iter != icons_.end(); ++iter) { 1058 iter != icons_.end(); ++iter) {
1053 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second))); 1059 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second)));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 UserScript::PatternList::const_iterator pattern = 1153 UserScript::PatternList::const_iterator pattern =
1148 content_script->url_patterns().begin(); 1154 content_script->url_patterns().begin();
1149 for (; pattern != content_script->url_patterns().end(); ++pattern) { 1155 for (; pattern != content_script->url_patterns().end(); ++pattern) {
1150 if (pattern->match_subdomains() && pattern->host().empty()) 1156 if (pattern->match_subdomains() && pattern->host().empty())
1151 return true; 1157 return true;
1152 } 1158 }
1153 } 1159 }
1154 1160
1155 return false; 1161 return false;
1156 } 1162 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/test/data/extensions/samples/override_igoogle/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698