OLD | NEW |
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // Restrict override pages to a list of supported URLs. | 227 // Restrict override pages to a list of supported URLs. |
228 bool is_override = (page != chrome::kChromeUINewTabHost && | 228 bool is_override = (page != chrome::kChromeUINewTabHost && |
229 page != chrome::kChromeUIBookmarksHost && | 229 page != chrome::kChromeUIBookmarksHost && |
230 page != chrome::kChromeUIHistoryHost); | 230 page != chrome::kChromeUIHistoryHost); |
231 #if defined(OS_CHROMEOS) | 231 #if defined(OS_CHROMEOS) |
232 is_override = (is_override && | 232 is_override = (is_override && |
233 page != chrome::kChromeUIActivationMessageHost); | 233 page != chrome::kChromeUIActivationMessageHost); |
234 #endif | 234 #endif |
235 #if defined(FILE_MANAGER_EXTENSION) | 235 #if defined(FILE_MANAGER_EXTENSION) |
236 is_override = (is_override && | 236 is_override = (is_override && |
237 !(extension->location() == Extension::COMPONENT && | 237 !(extension->location() == Manifest::COMPONENT && |
238 page == chrome::kChromeUIFileManagerHost)); | 238 page == chrome::kChromeUIFileManagerHost)); |
239 #endif | 239 #endif |
240 | 240 |
241 if (is_override || !overrides->GetStringWithoutPathExpansion(*iter, &val)) { | 241 if (is_override || !overrides->GetStringWithoutPathExpansion(*iter, &val)) { |
242 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides); | 242 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides); |
243 return false; | 243 return false; |
244 } | 244 } |
245 // Replace the entry with a fully qualified chrome-extension:// URL. | 245 // Replace the entry with a fully qualified chrome-extension:// URL. |
246 url_overrides->chrome_url_overrides_[page] = extension->GetResourceURL(val); | 246 url_overrides->chrome_url_overrides_[page] = extension->GetResourceURL(val); |
247 | 247 |
248 // For component extensions, add override URL to extent patterns. | 248 // For component extensions, add override URL to extent patterns. |
249 if (extension->is_legacy_packaged_app() && | 249 if (extension->is_legacy_packaged_app() && |
250 extension->location() == Extension::COMPONENT) { | 250 extension->location() == Manifest::COMPONENT) { |
251 URLPattern pattern(URLPattern::SCHEME_CHROMEUI); | 251 URLPattern pattern(URLPattern::SCHEME_CHROMEUI); |
252 std::string url = base::StringPrintf(kOverrideExtentUrlPatternFormat, | 252 std::string url = base::StringPrintf(kOverrideExtentUrlPatternFormat, |
253 page.c_str()); | 253 page.c_str()); |
254 if (pattern.Parse(url) != URLPattern::PARSE_SUCCESS) { | 254 if (pattern.Parse(url) != URLPattern::PARSE_SUCCESS) { |
255 *error = ErrorUtils::FormatErrorMessageUTF16( | 255 *error = ErrorUtils::FormatErrorMessageUTF16( |
256 errors::kInvalidURLPatternError, url); | 256 errors::kInvalidURLPatternError, url); |
257 return false; | 257 return false; |
258 } | 258 } |
259 extension->AddWebExtentPattern(pattern); | 259 extension->AddWebExtentPattern(pattern); |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 // An extension may override at most one page. | 263 // An extension may override at most one page. |
264 if (overrides->size() > 1) { | 264 if (overrides->size() > 1) { |
265 *error = ASCIIToUTF16(errors::kMultipleOverrides); | 265 *error = ASCIIToUTF16(errors::kMultipleOverrides); |
266 return false; | 266 return false; |
267 } | 267 } |
268 extension->SetManifestData(keys::kChromeURLOverrides, | 268 extension->SetManifestData(keys::kChromeURLOverrides, |
269 url_overrides.release()); | 269 url_overrides.release()); |
270 return true; | 270 return true; |
271 } | 271 } |
272 | 272 |
273 } // namespace extensions | 273 } // namespace extensions |
OLD | NEW |