| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI; | 305 UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI; |
| 306 | 306 |
| 307 Extension::Requirements::Requirements() | 307 Extension::Requirements::Requirements() |
| 308 : webgl(false), | 308 : webgl(false), |
| 309 css3d(false), | 309 css3d(false), |
| 310 npapi(false) { | 310 npapi(false) { |
| 311 } | 311 } |
| 312 | 312 |
| 313 Extension::Requirements::~Requirements() {} | 313 Extension::Requirements::~Requirements() {} |
| 314 | 314 |
| 315 Extension::OAuth2Info::OAuth2Info() {} | |
| 316 Extension::OAuth2Info::~OAuth2Info() {} | |
| 317 | |
| 318 // | 315 // |
| 319 // Extension | 316 // Extension |
| 320 // | 317 // |
| 321 | 318 |
| 322 bool Extension::InstallWarning::operator==(const InstallWarning& other) const { | 319 bool Extension::InstallWarning::operator==(const InstallWarning& other) const { |
| 323 return format == other.format && message == other.message; | 320 return format == other.format && message == other.message; |
| 324 } | 321 } |
| 325 | 322 |
| 326 // static | 323 // static |
| 327 scoped_refptr<Extension> Extension::Create(const FilePath& path, | 324 scoped_refptr<Extension> Extension::Create(const FilePath& path, |
| (...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1921 !LoadPlugins(error) || | 1918 !LoadPlugins(error) || |
| 1922 !LoadNaClModules(error) || | 1919 !LoadNaClModules(error) || |
| 1923 !LoadSandboxedPages(error) || | 1920 !LoadSandboxedPages(error) || |
| 1924 !LoadRequirements(error) || | 1921 !LoadRequirements(error) || |
| 1925 !LoadDefaultLocale(error) || | 1922 !LoadDefaultLocale(error) || |
| 1926 !LoadOfflineEnabled(error) || | 1923 !LoadOfflineEnabled(error) || |
| 1927 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). | 1924 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). |
| 1928 !LoadBackgroundScripts(error) || | 1925 !LoadBackgroundScripts(error) || |
| 1929 !LoadBackgroundPage(api_permissions, error) || | 1926 !LoadBackgroundPage(api_permissions, error) || |
| 1930 !LoadBackgroundPersistent(api_permissions, error) || | 1927 !LoadBackgroundPersistent(api_permissions, error) || |
| 1931 !LoadBackgroundAllowJSAccess(api_permissions, error) || | 1928 !LoadBackgroundAllowJSAccess(api_permissions, error)) |
| 1932 !LoadOAuth2Info(error)) | |
| 1933 return false; | 1929 return false; |
| 1934 | 1930 |
| 1935 return true; | 1931 return true; |
| 1936 } | 1932 } |
| 1937 | 1933 |
| 1938 bool Extension::LoadDescription(string16* error) { | 1934 bool Extension::LoadDescription(string16* error) { |
| 1939 if (manifest_->HasKey(keys::kDescription) && | 1935 if (manifest_->HasKey(keys::kDescription) && |
| 1940 !manifest_->GetString(keys::kDescription, &description_)) { | 1936 !manifest_->GetString(keys::kDescription, &description_)) { |
| 1941 *error = ASCIIToUTF16(errors::kInvalidDescription); | 1937 *error = ASCIIToUTF16(errors::kInvalidDescription); |
| 1942 return false; | 1938 return false; |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2995 base::IntToString(i)); | 2991 base::IntToString(i)); |
| 2996 return false; | 2992 return false; |
| 2997 } | 2993 } |
| 2998 | 2994 |
| 2999 (instance->*add_method)(glob); | 2995 (instance->*add_method)(glob); |
| 3000 } | 2996 } |
| 3001 | 2997 |
| 3002 return true; | 2998 return true; |
| 3003 } | 2999 } |
| 3004 | 3000 |
| 3005 bool Extension::LoadOAuth2Info(string16* error) { | |
| 3006 if (!manifest_->HasKey(keys::kOAuth2)) | |
| 3007 return true; | |
| 3008 | |
| 3009 if (!manifest_->GetString(keys::kOAuth2ClientId, &oauth2_info_.client_id) || | |
| 3010 oauth2_info_.client_id.empty()) { | |
| 3011 *error = ASCIIToUTF16(errors::kInvalidOAuth2ClientId); | |
| 3012 return false; | |
| 3013 } | |
| 3014 | |
| 3015 ListValue* list = NULL; | |
| 3016 if (!manifest_->GetList(keys::kOAuth2Scopes, &list)) { | |
| 3017 *error = ASCIIToUTF16(errors::kInvalidOAuth2Scopes); | |
| 3018 return false; | |
| 3019 } | |
| 3020 | |
| 3021 for (size_t i = 0; i < list->GetSize(); ++i) { | |
| 3022 std::string scope; | |
| 3023 if (!list->GetString(i, &scope)) { | |
| 3024 *error = ASCIIToUTF16(errors::kInvalidOAuth2Scopes); | |
| 3025 return false; | |
| 3026 } | |
| 3027 oauth2_info_.scopes.push_back(scope); | |
| 3028 } | |
| 3029 | |
| 3030 return true; | |
| 3031 } | |
| 3032 | |
| 3033 bool Extension::HasMultipleUISurfaces() const { | 3001 bool Extension::HasMultipleUISurfaces() const { |
| 3034 int num_surfaces = 0; | 3002 int num_surfaces = 0; |
| 3035 | 3003 |
| 3036 if (page_action_info()) | 3004 if (page_action_info()) |
| 3037 ++num_surfaces; | 3005 ++num_surfaces; |
| 3038 | 3006 |
| 3039 if (browser_action_info()) | 3007 if (browser_action_info()) |
| 3040 ++num_surfaces; | 3008 ++num_surfaces; |
| 3041 | 3009 |
| 3042 if (is_app()) | 3010 if (is_app()) |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3214 | 3182 |
| 3215 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3183 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3216 const Extension* extension, | 3184 const Extension* extension, |
| 3217 const PermissionSet* permissions, | 3185 const PermissionSet* permissions, |
| 3218 Reason reason) | 3186 Reason reason) |
| 3219 : reason(reason), | 3187 : reason(reason), |
| 3220 extension(extension), | 3188 extension(extension), |
| 3221 permissions(permissions) {} | 3189 permissions(permissions) {} |
| 3222 | 3190 |
| 3223 } // namespace extensions | 3191 } // namespace extensions |
| OLD | NEW |