| 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 |
| 25 namespace keys = extension_manifest_keys; | 29 namespace keys = extension_manifest_keys; |
| 26 namespace errors = extension_manifest_errors; | 30 namespace errors = extension_manifest_errors; |
| 27 | 31 |
| 28 namespace extensions { | 32 namespace extensions { |
| 29 | 33 |
| 30 namespace { | 34 namespace { |
| 31 | 35 |
| 32 const char kOverrideExtentUrlPatternFormat[] = "chrome://%s/*"; | 36 const char kOverrideExtentUrlPatternFormat[] = "chrome://%s/*"; |
| 33 | 37 |
| 34 const GURL& GetManifestURL(const Extension* extension, | 38 const GURL& GetManifestURL(const Extension* extension, |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 page != chrome::kChromeUIHistoryHost); | 273 page != chrome::kChromeUIHistoryHost); |
| 270 #if defined(OS_CHROMEOS) | 274 #if defined(OS_CHROMEOS) |
| 271 is_override = (is_override && | 275 is_override = (is_override && |
| 272 page != chrome::kChromeUIActivationMessageHost); | 276 page != chrome::kChromeUIActivationMessageHost); |
| 273 #endif | 277 #endif |
| 274 #if defined(FILE_MANAGER_EXTENSION) | 278 #if defined(FILE_MANAGER_EXTENSION) |
| 275 is_override = (is_override && | 279 is_override = (is_override && |
| 276 !(extension->location() == Manifest::COMPONENT && | 280 !(extension->location() == Manifest::COMPONENT && |
| 277 page == chrome::kChromeUIFileManagerHost)); | 281 page == chrome::kChromeUIFileManagerHost)); |
| 278 #endif | 282 #endif |
| 283 #if defined(USE_AURA) |
| 284 is_override = (is_override && page != keyboard::kKeyboardWebUIHost); |
| 285 #endif |
| 279 | 286 |
| 280 if (is_override || !iter.value().GetAsString(&val)) { | 287 if (is_override || !iter.value().GetAsString(&val)) { |
| 281 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides); | 288 *error = ASCIIToUTF16(errors::kInvalidChromeURLOverrides); |
| 282 return false; | 289 return false; |
| 283 } | 290 } |
| 284 // Replace the entry with a fully qualified chrome-extension:// URL. | 291 // Replace the entry with a fully qualified chrome-extension:// URL. |
| 285 url_overrides->chrome_url_overrides_[page] = extension->GetResourceURL(val); | 292 url_overrides->chrome_url_overrides_[page] = extension->GetResourceURL(val); |
| 286 | 293 |
| 287 // For component extensions, add override URL to extent patterns. | 294 // For component extensions, add override URL to extent patterns. |
| 288 if (extension->is_legacy_packaged_app() && | 295 if (extension->is_legacy_packaged_app() && |
| (...skipping 18 matching lines...) Expand all Loading... |
| 307 extension->SetManifestData(keys::kChromeURLOverrides, | 314 extension->SetManifestData(keys::kChromeURLOverrides, |
| 308 url_overrides.release()); | 315 url_overrides.release()); |
| 309 return true; | 316 return true; |
| 310 } | 317 } |
| 311 | 318 |
| 312 const std::vector<std::string> URLOverridesHandler::Keys() const { | 319 const std::vector<std::string> URLOverridesHandler::Keys() const { |
| 313 return SingleKey(keys::kChromeURLOverrides); | 320 return SingleKey(keys::kChromeURLOverrides); |
| 314 } | 321 } |
| 315 | 322 |
| 316 } // namespace extensions | 323 } // namespace extensions |
| OLD | NEW |