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

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

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/manifest_url_handler.h" 5 #include "chrome/common/extensions/manifest_url_handler.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Restrict override pages to a list of supported URLs. 220 // Restrict override pages to a list of supported URLs.
221 bool is_override = (page != chrome::kChromeUINewTabHost && 221 bool is_override = (page != chrome::kChromeUINewTabHost &&
222 page != chrome::kChromeUIBookmarksHost && 222 page != chrome::kChromeUIBookmarksHost &&
223 page != chrome::kChromeUIHistoryHost); 223 page != chrome::kChromeUIHistoryHost);
224 #if defined(OS_CHROMEOS) 224 #if defined(OS_CHROMEOS)
225 is_override = (is_override && 225 is_override = (is_override &&
226 page != chrome::kChromeUIActivationMessageHost); 226 page != chrome::kChromeUIActivationMessageHost);
227 #endif 227 #endif
228 #if defined(FILE_MANAGER_EXTENSION) 228 #if defined(FILE_MANAGER_EXTENSION)
229 is_override = (is_override && 229 is_override = (is_override &&
230 !(extension->location() == Extension::COMPONENT && 230 !(extension->location() == Manifest::COMPONENT &&
231 page == chrome::kChromeUIFileManagerHost)); 231 page == chrome::kChromeUIFileManagerHost));
232 #endif 232 #endif
233 233
234 if (is_override || !overrides->GetStringWithoutPathExpansion(*iter, &val)) { 234 if (is_override || !overrides->GetStringWithoutPathExpansion(*iter, &val)) {
235 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides); 235 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides);
236 return false; 236 return false;
237 } 237 }
238 // Replace the entry with a fully qualified chrome-extension:// URL. 238 // Replace the entry with a fully qualified chrome-extension:// URL.
239 url_overrides->chrome_url_overrides_[page] = extension->GetResourceURL(val); 239 url_overrides->chrome_url_overrides_[page] = extension->GetResourceURL(val);
240 240
241 // For component extensions, add override URL to extent patterns. 241 // For component extensions, add override URL to extent patterns.
242 if (extension->is_legacy_packaged_app() && 242 if (extension->is_legacy_packaged_app() &&
243 extension->location() == Extension::COMPONENT) { 243 extension->location() == Manifest::COMPONENT) {
244 URLPattern pattern(URLPattern::SCHEME_CHROMEUI); 244 URLPattern pattern(URLPattern::SCHEME_CHROMEUI);
245 std::string url = base::StringPrintf(kOverrideExtentUrlPatternFormat, 245 std::string url = base::StringPrintf(kOverrideExtentUrlPatternFormat,
246 page.c_str()); 246 page.c_str());
247 if (pattern.Parse(url) != URLPattern::PARSE_SUCCESS) { 247 if (pattern.Parse(url) != URLPattern::PARSE_SUCCESS) {
248 *error = ErrorUtils::FormatErrorMessageUTF16( 248 *error = ErrorUtils::FormatErrorMessageUTF16(
249 errors::kInvalidURLPatternError, url); 249 errors::kInvalidURLPatternError, url);
250 return false; 250 return false;
251 } 251 }
252 extension->AddWebExtentPattern(pattern); 252 extension->AddWebExtentPattern(pattern);
253 } 253 }
254 } 254 }
255 255
256 // An extension may override at most one page. 256 // An extension may override at most one page.
257 if (overrides->size() > 1) { 257 if (overrides->size() > 1) {
258 *error = ASCIIToUTF16(errors::kMultipleOverrides); 258 *error = ASCIIToUTF16(errors::kMultipleOverrides);
259 return false; 259 return false;
260 } 260 }
261 extension->SetManifestData(keys::kChromeURLOverrides, 261 extension->SetManifestData(keys::kChromeURLOverrides,
262 url_overrides.release()); 262 url_overrides.release());
263 return true; 263 return true;
264 } 264 }
265 265
266 } // namespace extensions 266 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest_unittest.cc ('k') | chrome/common/extensions/permissions/permission_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698