Index: chrome/browser/extensions/api/identity/identity_api.cc |
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc |
index 52005b09b4ca00bcc8a69c97fca5e3ee0f9f7cf0..a41298dc1e5cf06d0c177304063c5e336c33f92c 100644 |
--- a/chrome/browser/extensions/api/identity/identity_api.cc |
+++ b/chrome/browser/extensions/api/identity/identity_api.cc |
@@ -21,7 +21,6 @@ |
#include "chrome/browser/signin/signin_manager_factory.h" |
#include "chrome/browser/signin/token_service.h" |
#include "chrome/browser/signin/token_service_factory.h" |
-#include "chrome/browser/ui/browser.h" |
#include "chrome/common/extensions/api/identity.h" |
#include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" |
#include "chrome/common/extensions/extension.h" |
@@ -48,6 +47,7 @@ const char kUserNotSignedIn[] = "The user is not signed in."; |
const char kInteractionRequired[] = "User interaction required."; |
const char kInvalidRedirect[] = "Did not redirect to the right URL."; |
const char kOffTheRecord[] = "Identity API is disabled in incognito windows."; |
+const char kPageLoadFailure[] = "Authorization page could not be loaded."; |
const int kCachedIssueAdviceTTLSeconds = 1; |
} // namespace identity_constants |
@@ -393,16 +393,9 @@ bool IdentityLaunchWebAuthFlowFunction::RunImpl() { |
// scheme for this version of the API.) |
InitFinalRedirectURLPrefixes(GetExtension()->id()); |
- gfx::Rect initial_bounds; |
+ AddRef(); // Balanced in OnAuthFlowClosed |
- AddRef(); // Balanced in OnAuthFlowSuccess/Failure. |
- |
- Browser* current_browser = this->GetCurrentBrowser(); |
- chrome::HostDesktopType host_desktop_type = current_browser ? |
- current_browser->host_desktop_type() : chrome::GetActiveDesktop(); |
- auth_flow_.reset(new WebAuthFlow( |
- this, profile(), auth_url, mode, initial_bounds, |
- host_desktop_type)); |
+ auth_flow_.reset(new WebAuthFlow(this, profile(), auth_url, mode)); |
auth_flow_->Start(); |
return true; |
} |
@@ -439,13 +432,16 @@ void IdentityLaunchWebAuthFlowFunction::OnAuthFlowFailure( |
case WebAuthFlow::INTERACTION_REQUIRED: |
error_ = identity_constants::kInteractionRequired; |
break; |
+ case WebAuthFlow::LOAD_FAILED: |
+ error_ = std::string(identity_constants::kPageLoadFailure); |
+ break; |
default: |
NOTREACHED() << "Unexpected error from web auth flow: " << failure; |
error_ = identity_constants::kInvalidRedirect; |
break; |
} |
SendResponse(false); |
- Release(); // Balanced in RunImpl. |
+ auth_flow_->Close(); |
} |
void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( |
@@ -453,10 +449,14 @@ void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( |
if (IsFinalRedirectURL(redirect_url)) { |
SetResult(Value::CreateStringValue(redirect_url.spec())); |
SendResponse(true); |
- Release(); // Balanced in RunImpl. |
+ auth_flow_->Close(); |
} |
} |
+void IdentityLaunchWebAuthFlowFunction::OnAuthFlowClosed() { |
+ Release(); // Balanced in RunImpl. |
+} |
+ |
IdentityTokenCacheValue::IdentityTokenCacheValue() |
: status_(CACHE_STATUS_NOTFOUND) { |
} |