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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
15 #include "chrome/common/extensions/extension_file_util.h" | 15 #include "chrome/common/extensions/extension_file_util.h" |
16 #include "chrome/common/extensions/extension_manifest_constants.h" | 16 #include "chrome/common/extensions/extension_manifest_constants.h" |
17 #include "chrome/common/extensions/manifest.h" | 17 #include "chrome/common/extensions/manifest.h" |
18 #include "chrome/common/extensions/permissions/api_permission.h" | 18 #include "chrome/common/extensions/permissions/api_permission.h" |
19 #include "chrome/common/extensions/permissions/api_permission_set.h" | 19 #include "chrome/common/extensions/permissions/api_permission_set.h" |
20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
21 #include "extensions/common/error_utils.h" | 21 #include "extensions/common/error_utils.h" |
22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 | 24 |
25 #if defined(USE_AURA) | |
26 #include "ui/keyboard/keyboard_constants.h" | |
27 #endif | |
28 | |
29 namespace keys = extension_manifest_keys; | 25 namespace keys = extension_manifest_keys; |
30 namespace errors = extension_manifest_errors; | 26 namespace errors = extension_manifest_errors; |
31 | 27 |
32 namespace extensions { | 28 namespace extensions { |
33 | 29 |
34 namespace { | 30 namespace { |
35 | 31 |
36 const char kOverrideExtentUrlPatternFormat[] = "chrome://%s/*"; | 32 const char kOverrideExtentUrlPatternFormat[] = "chrome://%s/*"; |
37 | 33 |
38 const GURL& GetManifestURL(const Extension* extension, | 34 const GURL& GetManifestURL(const Extension* extension, |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 page != chrome::kChromeUIHistoryHost); | 269 page != chrome::kChromeUIHistoryHost); |
274 #if defined(OS_CHROMEOS) | 270 #if defined(OS_CHROMEOS) |
275 is_override = (is_override && | 271 is_override = (is_override && |
276 page != chrome::kChromeUIActivationMessageHost); | 272 page != chrome::kChromeUIActivationMessageHost); |
277 #endif | 273 #endif |
278 #if defined(FILE_MANAGER_EXTENSION) | 274 #if defined(FILE_MANAGER_EXTENSION) |
279 is_override = (is_override && | 275 is_override = (is_override && |
280 !(extension->location() == Manifest::COMPONENT && | 276 !(extension->location() == Manifest::COMPONENT && |
281 page == chrome::kChromeUIFileManagerHost)); | 277 page == chrome::kChromeUIFileManagerHost)); |
282 #endif | 278 #endif |
283 #if defined(USE_AURA) | |
284 is_override = (is_override && page != keyboard::kKeyboardWebUIHost); | |
285 #endif | |
286 | 279 |
287 if (is_override || !iter.value().GetAsString(&val)) { | 280 if (is_override || !iter.value().GetAsString(&val)) { |
288 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides); | 281 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides); |
289 return false; | 282 return false; |
290 } | 283 } |
291 // Replace the entry with a fully qualified chrome-extension:// URL. | 284 // Replace the entry with a fully qualified chrome-extension:// URL. |
292 url_overrides->chrome_url_overrides_[page] = extension->GetResourceURL(val); | 285 url_overrides->chrome_url_overrides_[page] = extension->GetResourceURL(val); |
293 | 286 |
294 // For component extensions, add override URL to extent patterns. | 287 // For component extensions, add override URL to extent patterns. |
295 if (extension->is_legacy_packaged_app() && | 288 if (extension->is_legacy_packaged_app() && |
(...skipping 18 matching lines...) Expand all Loading... |
314 extension->SetManifestData(keys::kChromeURLOverrides, | 307 extension->SetManifestData(keys::kChromeURLOverrides, |
315 url_overrides.release()); | 308 url_overrides.release()); |
316 return true; | 309 return true; |
317 } | 310 } |
318 | 311 |
319 const std::vector<std::string> URLOverridesHandler::Keys() const { | 312 const std::vector<std::string> URLOverridesHandler::Keys() const { |
320 return SingleKey(keys::kChromeURLOverrides); | 313 return SingleKey(keys::kChromeURLOverrides); |
321 } | 314 } |
322 | 315 |
323 } // namespace extensions | 316 } // namespace extensions |
OLD | NEW |