Chromium Code Reviews| Index: chrome/browser/extensions/api/identity/identity_api.cc |
| =================================================================== |
| --- chrome/browser/extensions/api/identity/identity_api.cc (revision 177049) |
| +++ chrome/browser/extensions/api/identity/identity_api.cc (working copy) |
| @@ -1,9 +1,10 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "chrome/browser/extensions/api/identity/identity_api.h" |
| +#include "base/lazy_instance.h" |
| #include "base/values.h" |
| #include "chrome/common/extensions/api/experimental_identity.h" |
| #include "chrome/browser/extensions/extension_install_prompt.h" |
| @@ -17,7 +18,10 @@ |
| #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
| +#include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" |
| #include "chrome/common/extensions/extension.h" |
| +#include "chrome/common/extensions/extension_manifest_constants.h" |
| +#include "chrome/common/extensions/manifest_handler.h" |
| #include "chrome/common/url_constants.h" |
| #include "content/public/common/page_transition_types.h" |
| #include "googleurl/src/gurl.h" |
| @@ -33,7 +37,7 @@ |
| const char kUserRejected[] = "The user did not approve access."; |
| const char kUserNotSignedIn[] = "The user is not signed in."; |
| const char kInvalidRedirect[] = "Did not redirect to the right URL."; |
| -} |
| +} // namespace identity_constants |
| namespace GetAuthToken = extensions::api::experimental_identity::GetAuthToken; |
|
Devlin
2013/01/16 19:36:12
Remove all extensions:: prefixes, please.
SanjoyPal
2013/01/16 20:11:28
Done.
|
| namespace LaunchWebAuthFlow = |
| @@ -50,7 +54,7 @@ |
| if (params->details.get() && params->details->interactive.get()) |
| interactive_ = *params->details->interactive; |
| - const Extension::OAuth2Info& oauth2_info = GetExtension()->oauth2_info(); |
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(GetExtension()); |
| // Check that the necessary information is present in the manfist. |
| if (oauth2_info.client_id.empty()) { |
| @@ -183,7 +187,7 @@ |
| OAuth2MintTokenFlow* IdentityGetAuthTokenFunction::CreateMintTokenFlow( |
| OAuth2MintTokenFlow::Mode mode) { |
| - const Extension::OAuth2Info& oauth2_info = GetExtension()->oauth2_info(); |
| + const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(GetExtension()); |
| TokenService* token_service = TokenServiceFactory::GetForProfile(profile()); |
| return new OAuth2MintTokenFlow( |
| profile()->GetRequestContext(), |
| @@ -252,4 +256,20 @@ |
| Release(); // Balanced in RunImpl. |
| } |
| +IdentityAPI::IdentityAPI(Profile* profile) { |
| + ManifestHandler::Register(extension_manifest_keys::kOAuth2, |
| + new OAuth2ManifestHandler); |
| +} |
| + |
| +IdentityAPI::~IdentityAPI() { |
| +} |
| + |
| +static base::LazyInstance<ProfileKeyedAPIFactory<IdentityAPI> > |
| + g_factory = LAZY_INSTANCE_INITIALIZER; |
| + |
| +// static |
| +ProfileKeyedAPIFactory<IdentityAPI>* IdentityAPI::GetFactoryInstance() { |
| + return &g_factory.Get(); |
| +} |
| + |
| } // namespace extensions |