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

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

Issue 174277: override chrome:// URLs via extensions. (Closed)
Patch Set: fix linux errors Created 11 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
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 std::string default_locale; 990 std::string default_locale;
991 if (!source.GetString(keys::kDefaultLocale, &default_locale)) { 991 if (!source.GetString(keys::kDefaultLocale, &default_locale)) {
992 *error = errors::kInvalidDefaultLocale; 992 *error = errors::kInvalidDefaultLocale;
993 return false; 993 return false;
994 } 994 }
995 // Normalize underscores to hyphens. 995 // Normalize underscores to hyphens.
996 std::replace(default_locale.begin(), default_locale.end(), '_', '-'); 996 std::replace(default_locale.begin(), default_locale.end(), '_', '-');
997 set_default_locale(default_locale); 997 set_default_locale(default_locale);
998 } 998 }
999 999
1000 // Chrome URL overrides (optional)
1001 if (source.HasKey(keys::kChromeURLOverrides)) {
1002 DictionaryValue* overrides;
1003 if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) {
1004 *error = errors::kInvalidChromeURLOverrides;
1005 return false;
1006 }
1007 // Validate that the overrides are all strings
1008 DictionaryValue::key_iterator iter = overrides->begin_keys();
1009 while (iter != overrides->end_keys()) {
1010 // For now, only allow the new tab page. Others will work when we remove
1011 // this check, but let's keep it simple for now.
1012 // TODO(erikkay) enable other pages as well
1013 if (WideToUTF8(*iter) != chrome::kChromeUINewTabHost) {
1014 *error = errors::kInvalidChromeURLOverrides;
1015 return false;
1016 }
1017 std::string val;
1018 if (!overrides->GetString(*iter, &val)) {
1019 *error = errors::kInvalidChromeURLOverrides;
1020 return false;
1021 }
1022 // Replace the entry with a fully qualified chrome-extension:// URL.
1023 GURL url = GetResourceURL(val);
1024 overrides->SetString(*iter, url.spec());
1025 ++iter;
1026 }
1027 chrome_url_overrides_.reset(
1028 static_cast<DictionaryValue*>(overrides->DeepCopy()));
1029 }
1030
1000 return true; 1031 return true;
1001 } 1032 }
1002 1033
1003 std::set<FilePath> Extension::GetBrowserImages() { 1034 std::set<FilePath> Extension::GetBrowserImages() {
1004 std::set<FilePath> image_paths; 1035 std::set<FilePath> image_paths;
1005 1036
1006 // extension icons 1037 // extension icons
1007 for (std::map<int, std::string>::iterator iter = icons_.begin(); 1038 for (std::map<int, std::string>::iterator iter = icons_.begin();
1008 iter != icons_.end(); ++iter) { 1039 iter != icons_.end(); ++iter) {
1009 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second))); 1040 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second)));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 UserScript::PatternList::const_iterator pattern = 1116 UserScript::PatternList::const_iterator pattern =
1086 content_script->url_patterns().begin(); 1117 content_script->url_patterns().begin();
1087 for (; pattern != content_script->url_patterns().end(); ++pattern) { 1118 for (; pattern != content_script->url_patterns().end(); ++pattern) {
1088 if (pattern->match_subdomains() && pattern->host().empty()) 1119 if (pattern->match_subdomains() && pattern->host().empty())
1089 return true; 1120 return true;
1090 } 1121 }
1091 } 1122 }
1092 1123
1093 return false; 1124 return false;
1094 } 1125 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698