| 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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/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_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
| 16 #include "chrome/common/extensions/extension_file_util.h" | 16 #include "chrome/common/extensions/extension_file_util.h" |
| 17 #include "chrome/common/extensions/permissions/permissions_data.h" | 17 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 19 #include "extensions/common/error_utils.h" | 19 #include "extensions/common/error_utils.h" |
| 20 #include "extensions/common/extension_urls.h" |
| 20 #include "extensions/common/manifest.h" | 21 #include "extensions/common/manifest.h" |
| 21 #include "extensions/common/manifest_constants.h" | 22 #include "extensions/common/manifest_constants.h" |
| 22 #include "extensions/common/permissions/api_permission.h" | 23 #include "extensions/common/permissions/api_permission.h" |
| 23 #include "extensions/common/permissions/api_permission_set.h" | 24 #include "extensions/common/permissions/api_permission_set.h" |
| 24 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 26 | 27 |
| 27 #if defined(USE_AURA) | 28 #if defined(USE_AURA) |
| 28 #include "ui/keyboard/keyboard_constants.h" | 29 #include "ui/keyboard/keyboard_constants.h" |
| 29 #endif | 30 #endif |
| (...skipping 20 matching lines...) Expand all Loading... |
| 50 const GURL& ManifestURL::GetDevToolsPage(const Extension* extension) { | 51 const GURL& ManifestURL::GetDevToolsPage(const Extension* extension) { |
| 51 return GetManifestURL(extension, keys::kDevToolsPage); | 52 return GetManifestURL(extension, keys::kDevToolsPage); |
| 52 } | 53 } |
| 53 | 54 |
| 54 // static | 55 // static |
| 55 const GURL ManifestURL::GetHomepageURL(const Extension* extension) { | 56 const GURL ManifestURL::GetHomepageURL(const Extension* extension) { |
| 56 const GURL& homepage_url = GetManifestURL(extension, keys::kHomepageURL); | 57 const GURL& homepage_url = GetManifestURL(extension, keys::kHomepageURL); |
| 57 if (homepage_url.is_valid()) | 58 if (homepage_url.is_valid()) |
| 58 return homepage_url; | 59 return homepage_url; |
| 59 return UpdatesFromGallery(extension) ? | 60 return UpdatesFromGallery(extension) ? |
| 60 GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + extension->id()) : | 61 GURL(GetWebstoreItemDetailURLPrefix() + extension->id()) : |
| 61 GURL::EmptyGURL(); | 62 GURL::EmptyGURL(); |
| 62 } | 63 } |
| 63 | 64 |
| 64 // static | 65 // static |
| 65 const GURL& ManifestURL::GetUpdateURL(const Extension* extension) { | 66 const GURL& ManifestURL::GetUpdateURL(const Extension* extension) { |
| 66 return GetManifestURL(extension, keys::kUpdateURL); | 67 return GetManifestURL(extension, keys::kUpdateURL); |
| 67 } | 68 } |
| 68 | 69 |
| 69 // static | 70 // static |
| 70 bool ManifestURL::UpdatesFromGallery(const Extension* extension) { | 71 bool ManifestURL::UpdatesFromGallery(const Extension* extension) { |
| 71 return extension_urls::IsWebstoreUpdateUrl(GetUpdateURL(extension)); | 72 return extension_urls::IsWebstoreUpdateUrl(GetUpdateURL(extension)); |
| 72 } | 73 } |
| 73 | 74 |
| 74 // static | 75 // static |
| 75 const GURL& ManifestURL::GetOptionsPage(const Extension* extension) { | 76 const GURL& ManifestURL::GetOptionsPage(const Extension* extension) { |
| 76 return GetManifestURL(extension, keys::kOptionsPage); | 77 return GetManifestURL(extension, keys::kOptionsPage); |
| 77 } | 78 } |
| 78 | 79 |
| 79 // static | 80 // static |
| 80 const GURL ManifestURL::GetDetailsURL(const Extension* extension) { | 81 const GURL ManifestURL::GetDetailsURL(const Extension* extension) { |
| 81 return extension->from_webstore() ? | 82 return extension->from_webstore() ? |
| 82 GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + extension->id()) : | 83 GURL(GetWebstoreItemDetailURLPrefix() + extension->id()) : |
| 83 GURL::EmptyGURL(); | 84 GURL::EmptyGURL(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 URLOverrides::URLOverrides() { | 87 URLOverrides::URLOverrides() { |
| 87 } | 88 } |
| 88 | 89 |
| 89 URLOverrides::~URLOverrides() { | 90 URLOverrides::~URLOverrides() { |
| 90 } | 91 } |
| 91 | 92 |
| 92 static base::LazyInstance<URLOverrides::URLOverrideMap> g_empty_url_overrides = | 93 static base::LazyInstance<URLOverrides::URLOverrideMap> g_empty_url_overrides = |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 extension->SetManifestData(keys::kChromeURLOverrides, | 322 extension->SetManifestData(keys::kChromeURLOverrides, |
| 322 url_overrides.release()); | 323 url_overrides.release()); |
| 323 return true; | 324 return true; |
| 324 } | 325 } |
| 325 | 326 |
| 326 const std::vector<std::string> URLOverridesHandler::Keys() const { | 327 const std::vector<std::string> URLOverridesHandler::Keys() const { |
| 327 return SingleKey(keys::kChromeURLOverrides); | 328 return SingleKey(keys::kChromeURLOverrides); |
| 328 } | 329 } |
| 329 | 330 |
| 330 } // namespace extensions | 331 } // namespace extensions |
| OLD | NEW |