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

Unified Diff: chrome/browser/extensions/api/identity/identity_api.cc

Issue 14081014: Identity API: Change WebAuthFlow to use <webview> instead of a normal browser pop-up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chrome.identity side-by-side with chrome.experimental.identity Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
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) {
}
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_api.h ('k') | chrome/browser/extensions/api/identity/identity_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698