| 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/files/file_util.h" | 7 #include "base/files/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/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 18 #include "extensions/common/error_utils.h" | 18 #include "extensions/common/error_utils.h" |
| 19 #include "extensions/common/file_util.h" | 19 #include "extensions/common/file_util.h" |
| 20 #include "extensions/common/manifest.h" | 20 #include "extensions/common/manifest.h" |
| 21 #include "extensions/common/manifest_constants.h" | 21 #include "extensions/common/manifest_constants.h" |
| 22 #include "extensions/common/manifest_handlers/permissions_parser.h" | 22 #include "extensions/common/manifest_handlers/permissions_parser.h" |
| 23 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 23 #include "extensions/common/permissions/api_permission.h" | 24 #include "extensions/common/permissions/api_permission.h" |
| 24 #include "extensions/common/permissions/api_permission_set.h" | 25 #include "extensions/common/permissions/api_permission_set.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 |
| 30 | 31 |
| 31 namespace extensions { | 32 namespace extensions { |
| 32 | 33 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 49 // static | 50 // static |
| 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 bool use_webstore_url = UpdatesFromGallery(extension) && |
| 60 GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + extension->id()) : | 61 !SharedModuleInfo::IsSharedModule(extension); |
| 61 GURL::EmptyGURL(); | 62 return use_webstore_url |
| 63 ? GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + |
| 64 extension->id()) |
| 65 : GURL::EmptyGURL(); |
| 62 } | 66 } |
| 63 | 67 |
| 64 // static | 68 // static |
| 65 const GURL& ManifestURL::GetUpdateURL(const Extension* extension) { | 69 const GURL& ManifestURL::GetUpdateURL(const Extension* extension) { |
| 66 return GetManifestURL(extension, keys::kUpdateURL); | 70 return GetManifestURL(extension, keys::kUpdateURL); |
| 67 } | 71 } |
| 68 | 72 |
| 69 // static | 73 // static |
| 70 bool ManifestURL::UpdatesFromGallery(const Extension* extension) { | 74 bool ManifestURL::UpdatesFromGallery(const Extension* extension) { |
| 71 return extension_urls::IsWebstoreUpdateUrl(GetUpdateURL(extension)); | 75 return extension_urls::IsWebstoreUpdateUrl(GetUpdateURL(extension)); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 extension->SetManifestData(keys::kChromeURLOverrides, | 384 extension->SetManifestData(keys::kChromeURLOverrides, |
| 381 url_overrides.release()); | 385 url_overrides.release()); |
| 382 return true; | 386 return true; |
| 383 } | 387 } |
| 384 | 388 |
| 385 const std::vector<std::string> URLOverridesHandler::Keys() const { | 389 const std::vector<std::string> URLOverridesHandler::Keys() const { |
| 386 return SingleKey(keys::kChromeURLOverrides); | 390 return SingleKey(keys::kChromeURLOverrides); |
| 387 } | 391 } |
| 388 | 392 |
| 389 } // namespace extensions | 393 } // namespace extensions |
| OLD | NEW |