| 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/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/string_piece.h" | 20 #include "base/string_piece.h" |
| 21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
| 23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "base/version.h" | 25 #include "base/version.h" |
| 26 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/chrome_version_info.h" | 28 #include "chrome/common/chrome_version_info.h" |
| 29 // TODO(rdevlin.cronin): Remove this once PageAction, BrowserAction, and | 29 // TODO(rdevlin.cronin): Remove these once all accessors have been moved out of |
| 30 // SystemIndicator have been moved out of Extension. | 30 // the core Extension class. |
| 31 #include "chrome/common/extensions/api/extension_action/action_handler_helpers.h
" | 31 #include "chrome/common/extensions/api/extension_action/action_handler_helpers.h
" |
| 32 #include "chrome/common/extensions/api/extension_action/action_info.h" | 32 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 33 #include "chrome/common/extensions/api/extension_urls/extension_urls_handler.h" |
| 33 #include "chrome/common/extensions/csp_validator.h" | 34 #include "chrome/common/extensions/csp_validator.h" |
| 34 #include "chrome/common/extensions/extension_manifest_constants.h" | 35 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 35 #include "chrome/common/extensions/extension_resource.h" | 36 #include "chrome/common/extensions/extension_resource.h" |
| 36 #include "chrome/common/extensions/feature_switch.h" | 37 #include "chrome/common/extensions/feature_switch.h" |
| 37 #include "chrome/common/extensions/features/base_feature_provider.h" | 38 #include "chrome/common/extensions/features/base_feature_provider.h" |
| 38 #include "chrome/common/extensions/features/feature.h" | 39 #include "chrome/common/extensions/features/feature.h" |
| 39 #include "chrome/common/extensions/manifest.h" | 40 #include "chrome/common/extensions/manifest.h" |
| 40 #include "chrome/common/extensions/manifest_handler.h" | 41 #include "chrome/common/extensions/manifest_handler.h" |
| 41 #include "chrome/common/extensions/manifest_handler_helpers.h" | 42 #include "chrome/common/extensions/manifest_handler_helpers.h" |
| 42 #include "chrome/common/extensions/permissions/permission_set.h" | 43 #include "chrome/common/extensions/permissions/permission_set.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 444 |
| 444 void Extension::GetBasicInfo(bool enabled, | 445 void Extension::GetBasicInfo(bool enabled, |
| 445 DictionaryValue* info) const { | 446 DictionaryValue* info) const { |
| 446 info->SetString(info_keys::kIdKey, id()); | 447 info->SetString(info_keys::kIdKey, id()); |
| 447 info->SetString(info_keys::kNameKey, name()); | 448 info->SetString(info_keys::kNameKey, name()); |
| 448 info->SetBoolean(info_keys::kEnabledKey, enabled); | 449 info->SetBoolean(info_keys::kEnabledKey, enabled); |
| 449 info->SetBoolean(info_keys::kOfflineEnabledKey, offline_enabled()); | 450 info->SetBoolean(info_keys::kOfflineEnabledKey, offline_enabled()); |
| 450 info->SetString(info_keys::kVersionKey, VersionString()); | 451 info->SetString(info_keys::kVersionKey, VersionString()); |
| 451 info->SetString(info_keys::kDescriptionKey, description()); | 452 info->SetString(info_keys::kDescriptionKey, description()); |
| 452 info->SetString(info_keys::kOptionsUrlKey, | 453 info->SetString(info_keys::kOptionsUrlKey, |
| 453 options_url().possibly_invalid_spec()); | 454 ExtensionURL::GetOptionsURL(this).possibly_invalid_spec()); |
| 454 info->SetString(info_keys::kHomepageUrlKey, | 455 info->SetString(info_keys::kHomepageUrlKey, |
| 455 GetHomepageURL().possibly_invalid_spec()); | 456 ExtensionURL::GetHomepageURL(this).possibly_invalid_spec()); |
| 456 info->SetString(info_keys::kDetailsUrlKey, | 457 info->SetString(info_keys::kDetailsUrlKey, |
| 457 details_url().possibly_invalid_spec()); | 458 details_url().possibly_invalid_spec()); |
| 458 info->SetBoolean(info_keys::kPackagedAppKey, is_platform_app()); | 459 info->SetBoolean(info_keys::kPackagedAppKey, is_platform_app()); |
| 459 } | 460 } |
| 460 | 461 |
| 461 Extension::Type Extension::GetType() const { | 462 Extension::Type Extension::GetType() const { |
| 462 return converted_from_user_script() ? TYPE_USER_SCRIPT : manifest_->type(); | 463 return converted_from_user_script() ? TYPE_USER_SCRIPT : manifest_->type(); |
| 463 } | 464 } |
| 464 | 465 |
| 465 // static | 466 // static |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 } | 911 } |
| 911 | 912 |
| 912 bool Extension::ShowConfigureContextMenus() const { | 913 bool Extension::ShowConfigureContextMenus() const { |
| 913 // Don't show context menu for component extensions. We might want to show | 914 // Don't show context menu for component extensions. We might want to show |
| 914 // options for component extension button but now there is no component | 915 // options for component extension button but now there is no component |
| 915 // extension with options. All other menu items like uninstall have | 916 // extension with options. All other menu items like uninstall have |
| 916 // no sense for component extensions. | 917 // no sense for component extensions. |
| 917 return location() != Extension::COMPONENT; | 918 return location() != Extension::COMPONENT; |
| 918 } | 919 } |
| 919 | 920 |
| 920 GURL Extension::GetHomepageURL() const { | |
| 921 if (homepage_url_.is_valid()) | |
| 922 return homepage_url_; | |
| 923 | |
| 924 return UpdatesFromGallery() ? | |
| 925 GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + id()) : GURL(); | |
| 926 } | |
| 927 | |
| 928 std::set<FilePath> Extension::GetBrowserImages() const { | 921 std::set<FilePath> Extension::GetBrowserImages() const { |
| 929 std::set<FilePath> image_paths; | 922 std::set<FilePath> image_paths; |
| 930 // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())| | 923 // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())| |
| 931 // indicate that we're doing something wrong. | 924 // indicate that we're doing something wrong. |
| 932 | 925 |
| 933 // Extension icons. | 926 // Extension icons. |
| 934 for (ExtensionIconSet::IconMap::const_iterator iter = icons().map().begin(); | 927 for (ExtensionIconSet::IconMap::const_iterator iter = icons().map().begin(); |
| 935 iter != icons().map().end(); ++iter) { | 928 iter != icons().map().end(); ++iter) { |
| 936 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second))); | 929 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second))); |
| 937 } | 930 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 return true; | 1101 return true; |
| 1109 | 1102 |
| 1110 if (error) { | 1103 if (error) { |
| 1111 *error = ErrorUtils::FormatErrorMessage(errors::kCannotAccessPage, | 1104 *error = ErrorUtils::FormatErrorMessage(errors::kCannotAccessPage, |
| 1112 page_url.spec()); | 1105 page_url.spec()); |
| 1113 } | 1106 } |
| 1114 return false; | 1107 return false; |
| 1115 } | 1108 } |
| 1116 | 1109 |
| 1117 bool Extension::UpdatesFromGallery() const { | 1110 bool Extension::UpdatesFromGallery() const { |
| 1118 return extension_urls::IsWebstoreUpdateUrl(update_url()); | 1111 return extension_urls::IsWebstoreUpdateUrl(ExtensionURL::GetUpdateURL(this)); |
| 1119 } | 1112 } |
| 1120 | 1113 |
| 1121 bool Extension::OverlapsWithOrigin(const GURL& origin) const { | 1114 bool Extension::OverlapsWithOrigin(const GURL& origin) const { |
| 1122 if (url() == origin) | 1115 if (url() == origin) |
| 1123 return true; | 1116 return true; |
| 1124 | 1117 |
| 1125 if (web_extent().is_empty()) | 1118 if (web_extent().is_empty()) |
| 1126 return false; | 1119 return false; |
| 1127 | 1120 |
| 1128 // Note: patterns and extents ignore port numbers. | 1121 // Note: patterns and extents ignore port numbers. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1141 Extension::SyncType Extension::GetSyncType() const { | 1134 Extension::SyncType Extension::GetSyncType() const { |
| 1142 if (!IsSyncable()) { | 1135 if (!IsSyncable()) { |
| 1143 // We have a non-standard location. | 1136 // We have a non-standard location. |
| 1144 return SYNC_TYPE_NONE; | 1137 return SYNC_TYPE_NONE; |
| 1145 } | 1138 } |
| 1146 | 1139 |
| 1147 // Disallow extensions with non-gallery auto-update URLs for now. | 1140 // Disallow extensions with non-gallery auto-update URLs for now. |
| 1148 // | 1141 // |
| 1149 // TODO(akalin): Relax this restriction once we've put in UI to | 1142 // TODO(akalin): Relax this restriction once we've put in UI to |
| 1150 // approve synced extensions. | 1143 // approve synced extensions. |
| 1151 if (!update_url().is_empty() && !UpdatesFromGallery()) | 1144 if (!ExtensionURL::GetUpdateURL(this).is_empty() && !UpdatesFromGallery()) |
| 1152 return SYNC_TYPE_NONE; | 1145 return SYNC_TYPE_NONE; |
| 1153 | 1146 |
| 1154 // Disallow extensions with native code plugins. | 1147 // Disallow extensions with native code plugins. |
| 1155 // | 1148 // |
| 1156 // TODO(akalin): Relax this restriction once we've put in UI to | 1149 // TODO(akalin): Relax this restriction once we've put in UI to |
| 1157 // approve synced extensions. | 1150 // approve synced extensions. |
| 1158 if (!plugins().empty()) { | 1151 if (!plugins().empty()) { |
| 1159 return SYNC_TYPE_NONE; | 1152 return SYNC_TYPE_NONE; |
| 1160 } | 1153 } |
| 1161 | 1154 |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 extent_.ClearPatterns(); | 1893 extent_.ClearPatterns(); |
| 1901 } | 1894 } |
| 1902 | 1895 |
| 1903 return true; | 1896 return true; |
| 1904 } | 1897 } |
| 1905 | 1898 |
| 1906 bool Extension::LoadSharedFeatures( | 1899 bool Extension::LoadSharedFeatures( |
| 1907 const APIPermissionSet& api_permissions, | 1900 const APIPermissionSet& api_permissions, |
| 1908 string16* error) { | 1901 string16* error) { |
| 1909 if (!LoadDescription(error) || | 1902 if (!LoadDescription(error) || |
| 1910 !LoadHomepageURL(error) || | |
| 1911 !LoadUpdateURL(error) || | |
| 1912 !LoadIcons(error) || | 1903 !LoadIcons(error) || |
| 1913 !LoadCommands(error) || | 1904 !LoadCommands(error) || |
| 1914 !LoadPlugins(error) || | 1905 !LoadPlugins(error) || |
| 1915 !LoadNaClModules(error) || | 1906 !LoadNaClModules(error) || |
| 1916 !LoadWebAccessibleResources(error) || | 1907 !LoadWebAccessibleResources(error) || |
| 1917 !LoadSandboxedPages(error) || | 1908 !LoadSandboxedPages(error) || |
| 1918 !LoadRequirements(error) || | 1909 !LoadRequirements(error) || |
| 1919 !LoadDefaultLocale(error) || | 1910 !LoadDefaultLocale(error) || |
| 1920 !LoadOfflineEnabled(error) || | 1911 !LoadOfflineEnabled(error) || |
| 1921 !LoadOptionsPage(error) || | |
| 1922 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). | 1912 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). |
| 1923 !LoadBackgroundScripts(error) || | 1913 !LoadBackgroundScripts(error) || |
| 1924 !LoadBackgroundPage(api_permissions, error) || | 1914 !LoadBackgroundPage(api_permissions, error) || |
| 1925 !LoadBackgroundPersistent(api_permissions, error) || | 1915 !LoadBackgroundPersistent(api_permissions, error) || |
| 1926 !LoadBackgroundAllowJSAccess(api_permissions, error) || | 1916 !LoadBackgroundAllowJSAccess(api_permissions, error) || |
| 1927 !LoadWebIntentServices(error) || | 1917 !LoadWebIntentServices(error) || |
| 1928 !LoadOAuth2Info(error)) | 1918 !LoadOAuth2Info(error)) |
| 1929 return false; | 1919 return false; |
| 1930 | 1920 |
| 1931 return true; | 1921 return true; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1959 switches::kAllowLegacyExtensionManifests)) { | 1949 switches::kAllowLegacyExtensionManifests)) { |
| 1960 *error = ErrorUtils::FormatErrorMessageUTF16( | 1950 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 1961 errors::kInvalidManifestVersionOld, | 1951 errors::kInvalidManifestVersionOld, |
| 1962 base::IntToString(kModernManifestVersion)); | 1952 base::IntToString(kModernManifestVersion)); |
| 1963 return false; | 1953 return false; |
| 1964 } | 1954 } |
| 1965 | 1955 |
| 1966 return true; | 1956 return true; |
| 1967 } | 1957 } |
| 1968 | 1958 |
| 1969 bool Extension::LoadHomepageURL(string16* error) { | |
| 1970 if (!manifest_->HasKey(keys::kHomepageURL)) | |
| 1971 return true; | |
| 1972 std::string tmp_homepage_url; | |
| 1973 if (!manifest_->GetString(keys::kHomepageURL, &tmp_homepage_url)) { | |
| 1974 *error = ErrorUtils::FormatErrorMessageUTF16( | |
| 1975 errors::kInvalidHomepageURL, ""); | |
| 1976 return false; | |
| 1977 } | |
| 1978 homepage_url_ = GURL(tmp_homepage_url); | |
| 1979 if (!homepage_url_.is_valid() || | |
| 1980 (!homepage_url_.SchemeIs("http") && | |
| 1981 !homepage_url_.SchemeIs("https"))) { | |
| 1982 *error = ErrorUtils::FormatErrorMessageUTF16( | |
| 1983 errors::kInvalidHomepageURL, tmp_homepage_url); | |
| 1984 return false; | |
| 1985 } | |
| 1986 return true; | |
| 1987 } | |
| 1988 | |
| 1989 bool Extension::LoadUpdateURL(string16* error) { | |
| 1990 if (!manifest_->HasKey(keys::kUpdateURL)) | |
| 1991 return true; | |
| 1992 std::string tmp_update_url; | |
| 1993 if (!manifest_->GetString(keys::kUpdateURL, &tmp_update_url)) { | |
| 1994 *error = ErrorUtils::FormatErrorMessageUTF16( | |
| 1995 errors::kInvalidUpdateURL, ""); | |
| 1996 return false; | |
| 1997 } | |
| 1998 update_url_ = GURL(tmp_update_url); | |
| 1999 if (!update_url_.is_valid() || | |
| 2000 update_url_.has_ref()) { | |
| 2001 *error = ErrorUtils::FormatErrorMessageUTF16( | |
| 2002 errors::kInvalidUpdateURL, tmp_update_url); | |
| 2003 return false; | |
| 2004 } | |
| 2005 return true; | |
| 2006 } | |
| 2007 | |
| 2008 bool Extension::LoadIcons(string16* error) { | 1959 bool Extension::LoadIcons(string16* error) { |
| 2009 if (!manifest_->HasKey(keys::kIcons)) | 1960 if (!manifest_->HasKey(keys::kIcons)) |
| 2010 return true; | 1961 return true; |
| 2011 DictionaryValue* icons_value = NULL; | 1962 DictionaryValue* icons_value = NULL; |
| 2012 if (!manifest_->GetDictionary(keys::kIcons, &icons_value)) { | 1963 if (!manifest_->GetDictionary(keys::kIcons, &icons_value)) { |
| 2013 *error = ASCIIToUTF16(errors::kInvalidIcons); | 1964 *error = ASCIIToUTF16(errors::kInvalidIcons); |
| 2014 return false; | 1965 return false; |
| 2015 } | 1966 } |
| 2016 | 1967 |
| 2017 return manifest_handler_helpers::LoadIconsFromDictionary( | 1968 return manifest_handler_helpers::LoadIconsFromDictionary( |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 offline_enabled_ = is_platform_app(); | 2301 offline_enabled_ = is_platform_app(); |
| 2351 return true; | 2302 return true; |
| 2352 } | 2303 } |
| 2353 if (!manifest_->GetBoolean(keys::kOfflineEnabled, &offline_enabled_)) { | 2304 if (!manifest_->GetBoolean(keys::kOfflineEnabled, &offline_enabled_)) { |
| 2354 *error = ASCIIToUTF16(errors::kInvalidOfflineEnabled); | 2305 *error = ASCIIToUTF16(errors::kInvalidOfflineEnabled); |
| 2355 return false; | 2306 return false; |
| 2356 } | 2307 } |
| 2357 return true; | 2308 return true; |
| 2358 } | 2309 } |
| 2359 | 2310 |
| 2360 bool Extension::LoadOptionsPage(string16* error) { | |
| 2361 if (!manifest_->HasKey(keys::kOptionsPage)) | |
| 2362 return true; | |
| 2363 std::string options_str; | |
| 2364 if (!manifest_->GetString(keys::kOptionsPage, &options_str)) { | |
| 2365 *error = ASCIIToUTF16(errors::kInvalidOptionsPage); | |
| 2366 return false; | |
| 2367 } | |
| 2368 | |
| 2369 if (is_hosted_app()) { | |
| 2370 // hosted apps require an absolute URL. | |
| 2371 GURL options_url(options_str); | |
| 2372 if (!options_url.is_valid() || | |
| 2373 !(options_url.SchemeIs("http") || options_url.SchemeIs("https"))) { | |
| 2374 *error = ASCIIToUTF16(errors::kInvalidOptionsPageInHostedApp); | |
| 2375 return false; | |
| 2376 } | |
| 2377 options_url_ = options_url; | |
| 2378 } else { | |
| 2379 GURL absolute(options_str); | |
| 2380 if (absolute.is_valid()) { | |
| 2381 *error = ASCIIToUTF16(errors::kInvalidOptionsPageExpectUrlInPackage); | |
| 2382 return false; | |
| 2383 } | |
| 2384 options_url_ = GetResourceURL(options_str); | |
| 2385 if (!options_url_.is_valid()) { | |
| 2386 *error = ASCIIToUTF16(errors::kInvalidOptionsPage); | |
| 2387 return false; | |
| 2388 } | |
| 2389 } | |
| 2390 | |
| 2391 return true; | |
| 2392 } | |
| 2393 | |
| 2394 bool Extension::LoadBackgroundScripts(string16* error) { | 2311 bool Extension::LoadBackgroundScripts(string16* error) { |
| 2395 const std::string& key = is_platform_app() ? | 2312 const std::string& key = is_platform_app() ? |
| 2396 keys::kPlatformAppBackgroundScripts : keys::kBackgroundScripts; | 2313 keys::kPlatformAppBackgroundScripts : keys::kBackgroundScripts; |
| 2397 return LoadBackgroundScripts(key, error); | 2314 return LoadBackgroundScripts(key, error); |
| 2398 } | 2315 } |
| 2399 | 2316 |
| 2400 bool Extension::LoadBackgroundScripts(const std::string& key, string16* error) { | 2317 bool Extension::LoadBackgroundScripts(const std::string& key, string16* error) { |
| 2401 Value* background_scripts_value = NULL; | 2318 Value* background_scripts_value = NULL; |
| 2402 if (!manifest_->Get(key, &background_scripts_value)) | 2319 if (!manifest_->Get(key, &background_scripts_value)) |
| 2403 return true; | 2320 return true; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2758 return true; | 2675 return true; |
| 2759 } | 2676 } |
| 2760 | 2677 |
| 2761 bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions, | 2678 bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions, |
| 2762 string16* error) { | 2679 string16* error) { |
| 2763 if (manifest_->HasKey(keys::kConvertedFromUserScript)) | 2680 if (manifest_->HasKey(keys::kConvertedFromUserScript)) |
| 2764 manifest_->GetBoolean(keys::kConvertedFromUserScript, | 2681 manifest_->GetBoolean(keys::kConvertedFromUserScript, |
| 2765 &converted_from_user_script_); | 2682 &converted_from_user_script_); |
| 2766 | 2683 |
| 2767 if (!LoadManifestHandlerFeatures(error) || | 2684 if (!LoadManifestHandlerFeatures(error) || |
| 2768 !LoadDevToolsPage(error) || | |
| 2769 !LoadInputComponents(*api_permissions, error) || | 2685 !LoadInputComponents(*api_permissions, error) || |
| 2770 !LoadContentScripts(error) || | 2686 !LoadContentScripts(error) || |
| 2771 !LoadPageAction(error) || | 2687 !LoadPageAction(error) || |
| 2772 !LoadSystemIndicator(api_permissions, error) || | 2688 !LoadSystemIndicator(api_permissions, error) || |
| 2773 !LoadChromeURLOverrides(error) || | 2689 !LoadChromeURLOverrides(error) || |
| 2774 !LoadTextToSpeechVoices(error) || | 2690 !LoadTextToSpeechVoices(error) || |
| 2775 !LoadIncognitoMode(error) || | 2691 !LoadIncognitoMode(error) || |
| 2776 !LoadFileHandlers(error) || | 2692 !LoadFileHandlers(error) || |
| 2777 !LoadContentSecurityPolicy(error)) | 2693 !LoadContentSecurityPolicy(error)) |
| 2778 return false; | 2694 return false; |
| 2779 | 2695 |
| 2780 return true; | 2696 return true; |
| 2781 } | 2697 } |
| 2782 | 2698 |
| 2783 bool Extension::LoadManifestHandlerFeatures(string16* error) { | 2699 bool Extension::LoadManifestHandlerFeatures(string16* error) { |
| 2784 std::vector<std::string> keys = ManifestHandler::GetKeys(); | 2700 std::vector<std::string> keys = ManifestHandler::GetKeys(); |
| 2785 for (size_t i = 0; i < keys.size(); ++i) { | 2701 for (size_t i = 0; i < keys.size(); ++i) { |
| 2786 Value* value = NULL; | 2702 Value* value = NULL; |
| 2787 if (!manifest_->Get(keys[i], &value)) { | 2703 if (!manifest_->Get(keys[i], &value)) { |
| 2788 if (!ManifestHandler::Get(keys[i])->HasNoKey(this, error)) | 2704 if (!ManifestHandler::Get(keys[i])->HasNoKey(this, error)) |
| 2789 return false; | 2705 return false; |
| 2790 } else if (!ManifestHandler::Get(keys[i])->Parse(value, this, error)) { | 2706 } else if (!ManifestHandler::Get(keys[i])->Parse(value, this, error)) { |
| 2791 return false; | 2707 return false; |
| 2792 } | 2708 } |
| 2793 } | 2709 } |
| 2794 return true; | 2710 return true; |
| 2795 } | 2711 } |
| 2796 | 2712 |
| 2797 bool Extension::LoadDevToolsPage(string16* error) { | |
| 2798 if (!manifest_->HasKey(keys::kDevToolsPage)) | |
| 2799 return true; | |
| 2800 std::string devtools_str; | |
| 2801 if (!manifest_->GetString(keys::kDevToolsPage, &devtools_str)) { | |
| 2802 *error = ASCIIToUTF16(errors::kInvalidDevToolsPage); | |
| 2803 return false; | |
| 2804 } | |
| 2805 devtools_url_ = GetResourceURL(devtools_str); | |
| 2806 return true; | |
| 2807 } | |
| 2808 | |
| 2809 bool Extension::LoadInputComponents(const APIPermissionSet& api_permissions, | 2713 bool Extension::LoadInputComponents(const APIPermissionSet& api_permissions, |
| 2810 string16* error) { | 2714 string16* error) { |
| 2811 if (!manifest_->HasKey(keys::kInputComponents)) | 2715 if (!manifest_->HasKey(keys::kInputComponents)) |
| 2812 return true; | 2716 return true; |
| 2813 ListValue* list_value = NULL; | 2717 ListValue* list_value = NULL; |
| 2814 if (!manifest_->GetList(keys::kInputComponents, &list_value)) { | 2718 if (!manifest_->GetList(keys::kInputComponents, &list_value)) { |
| 2815 *error = ASCIIToUTF16(errors::kInvalidInputComponents); | 2719 *error = ASCIIToUTF16(errors::kInvalidInputComponents); |
| 2816 return false; | 2720 return false; |
| 2817 } | 2721 } |
| 2818 | 2722 |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3821 | 3725 |
| 3822 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3726 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3823 const Extension* extension, | 3727 const Extension* extension, |
| 3824 const PermissionSet* permissions, | 3728 const PermissionSet* permissions, |
| 3825 Reason reason) | 3729 Reason reason) |
| 3826 : reason(reason), | 3730 : reason(reason), |
| 3827 extension(extension), | 3731 extension(extension), |
| 3828 permissions(permissions) {} | 3732 permissions(permissions) {} |
| 3829 | 3733 |
| 3830 } // namespace extensions | 3734 } // namespace extensions |
| OLD | NEW |