Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 11882025: Move "oauth2" manifest key parsing out of Extension class. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI; 336 UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI;
337 337
338 Extension::Requirements::Requirements() 338 Extension::Requirements::Requirements()
339 : webgl(false), 339 : webgl(false),
340 css3d(false), 340 css3d(false),
341 npapi(false) { 341 npapi(false) {
342 } 342 }
343 343
344 Extension::Requirements::~Requirements() {} 344 Extension::Requirements::~Requirements() {}
345 345
346 Extension::OAuth2Info::OAuth2Info() {}
347 Extension::OAuth2Info::~OAuth2Info() {}
348
349 Extension::ActionInfo::ActionInfo() {} 346 Extension::ActionInfo::ActionInfo() {}
350 Extension::ActionInfo::~ActionInfo() {} 347 Extension::ActionInfo::~ActionInfo() {}
351 348
352 Extension::FileHandlerInfo::FileHandlerInfo() {} 349 Extension::FileHandlerInfo::FileHandlerInfo() {}
353 Extension::FileHandlerInfo::~FileHandlerInfo() {} 350 Extension::FileHandlerInfo::~FileHandlerInfo() {}
354 351
355 // 352 //
356 // Extension 353 // Extension
357 // 354 //
358 355
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 !LoadSandboxedPages(error) || 1979 !LoadSandboxedPages(error) ||
1983 !LoadRequirements(error) || 1980 !LoadRequirements(error) ||
1984 !LoadDefaultLocale(error) || 1981 !LoadDefaultLocale(error) ||
1985 !LoadOfflineEnabled(error) || 1982 !LoadOfflineEnabled(error) ||
1986 !LoadOptionsPage(error) || 1983 !LoadOptionsPage(error) ||
1987 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). 1984 // LoadBackgroundScripts() must be called before LoadBackgroundPage().
1988 !LoadBackgroundScripts(error) || 1985 !LoadBackgroundScripts(error) ||
1989 !LoadBackgroundPage(api_permissions, error) || 1986 !LoadBackgroundPage(api_permissions, error) ||
1990 !LoadBackgroundPersistent(api_permissions, error) || 1987 !LoadBackgroundPersistent(api_permissions, error) ||
1991 !LoadBackgroundAllowJSAccess(api_permissions, error) || 1988 !LoadBackgroundAllowJSAccess(api_permissions, error) ||
1992 !LoadWebIntentServices(error) || 1989 !LoadWebIntentServices(error))
1993 !LoadOAuth2Info(error))
1994 return false; 1990 return false;
1995 1991
1996 return true; 1992 return true;
1997 } 1993 }
1998 1994
1999 bool Extension::LoadDescription(string16* error) { 1995 bool Extension::LoadDescription(string16* error) {
2000 if (manifest_->HasKey(keys::kDescription) && 1996 if (manifest_->HasKey(keys::kDescription) &&
2001 !manifest_->GetString(keys::kDescription, &description_)) { 1997 !manifest_->GetString(keys::kDescription, &description_)) {
2002 *error = ASCIIToUTF16(errors::kInvalidDescription); 1998 *error = ASCIIToUTF16(errors::kInvalidDescription);
2003 return false; 1999 return false;
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2841 !LoadContentSecurityPolicy(error)) 2837 !LoadContentSecurityPolicy(error))
2842 return false; 2838 return false;
2843 2839
2844 return true; 2840 return true;
2845 } 2841 }
2846 2842
2847 bool Extension::LoadManifestHandlerFeatures(string16* error) { 2843 bool Extension::LoadManifestHandlerFeatures(string16* error) {
2848 std::vector<std::string> keys = ManifestHandler::GetKeys(); 2844 std::vector<std::string> keys = ManifestHandler::GetKeys();
2849 for (size_t i = 0; i < keys.size(); ++i) { 2845 for (size_t i = 0; i < keys.size(); ++i) {
2850 Value* value = NULL; 2846 Value* value = NULL;
2851 if (!manifest_->Get(keys[i], &value)) 2847 if (!manifest_->Get(keys[i], &value)) {
2852 continue; 2848 if (!ManifestHandler::Get(keys[i])->HasNoKey(this, error))
2853 if (!ManifestHandler::Get(keys[i])->Parse(value, this, error)) 2849 return false;
2850 } else if (!ManifestHandler::Get(keys[i])->Parse(value, this, error)) {
2854 return false; 2851 return false;
2852 }
2855 } 2853 }
2856 return true; 2854 return true;
2857 } 2855 }
2858 2856
2859 bool Extension::LoadDevToolsPage(string16* error) { 2857 bool Extension::LoadDevToolsPage(string16* error) {
2860 if (!manifest_->HasKey(keys::kDevToolsPage)) 2858 if (!manifest_->HasKey(keys::kDevToolsPage))
2861 return true; 2859 return true;
2862 std::string devtools_str; 2860 std::string devtools_str;
2863 if (!manifest_->GetString(keys::kDevToolsPage, &devtools_str)) { 2861 if (!manifest_->GetString(keys::kDevToolsPage, &devtools_str)) {
2864 *error = ASCIIToUTF16(errors::kInvalidDevToolsPage); 2862 *error = ASCIIToUTF16(errors::kInvalidDevToolsPage);
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
3648 } 3646 }
3649 } else { 3647 } else {
3650 DCHECK(result->default_popup_url.is_empty()) 3648 DCHECK(result->default_popup_url.is_empty())
3651 << "Shouldn't be possible for the popup to be set."; 3649 << "Shouldn't be possible for the popup to be set.";
3652 } 3650 }
3653 } 3651 }
3654 3652
3655 return result.Pass(); 3653 return result.Pass();
3656 } 3654 }
3657 3655
3658 bool Extension::LoadOAuth2Info(string16* error) {
3659 if (!manifest_->HasKey(keys::kOAuth2))
3660 return true;
3661
3662 if (!manifest_->GetString(keys::kOAuth2ClientId, &oauth2_info_.client_id) ||
3663 oauth2_info_.client_id.empty()) {
3664 *error = ASCIIToUTF16(errors::kInvalidOAuth2ClientId);
3665 return false;
3666 }
3667
3668 ListValue* list = NULL;
3669 if (!manifest_->GetList(keys::kOAuth2Scopes, &list)) {
3670 *error = ASCIIToUTF16(errors::kInvalidOAuth2Scopes);
3671 return false;
3672 }
3673
3674 for (size_t i = 0; i < list->GetSize(); ++i) {
3675 std::string scope;
3676 if (!list->GetString(i, &scope)) {
3677 *error = ASCIIToUTF16(errors::kInvalidOAuth2Scopes);
3678 return false;
3679 }
3680 oauth2_info_.scopes.push_back(scope);
3681 }
3682
3683 return true;
3684 }
3685
3686 bool Extension::HasMultipleUISurfaces() const { 3656 bool Extension::HasMultipleUISurfaces() const {
3687 int num_surfaces = 0; 3657 int num_surfaces = 0;
3688 3658
3689 if (page_action_info()) 3659 if (page_action_info())
3690 ++num_surfaces; 3660 ++num_surfaces;
3691 3661
3692 if (browser_action_info()) 3662 if (browser_action_info())
3693 ++num_surfaces; 3663 ++num_surfaces;
3694 3664
3695 if (is_app()) 3665 if (is_app())
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
3867 3837
3868 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3838 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3869 const Extension* extension, 3839 const Extension* extension,
3870 const PermissionSet* permissions, 3840 const PermissionSet* permissions,
3871 Reason reason) 3841 Reason reason)
3872 : reason(reason), 3842 : reason(reason),
3873 extension(extension), 3843 extension(extension),
3874 permissions(permissions) {} 3844 permissions(permissions) {}
3875 3845
3876 } // namespace extensions 3846 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698