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

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

Issue 2342233004: Change WebAuthFlow to use the new WebContentsObserver navigation notifications. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « chrome/browser/extensions/api/identity/web_auth_flow.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/identity/web_auth_flow.cc
diff --git a/chrome/browser/extensions/api/identity/web_auth_flow.cc b/chrome/browser/extensions/api/identity/web_auth_flow.cc
index 6aa3289e3ddd62cd7d4b68349dd404eada669263..9639bbf5319ee8682505b659e1de47daaaa40998 100644
--- a/chrome/browser/extensions/api/identity/web_auth_flow.cc
+++ b/chrome/browser/extensions/api/identity/web_auth_flow.cc
@@ -22,6 +22,7 @@
#include "components/guest_view/browser/guest_view_base.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
@@ -33,6 +34,7 @@
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_system.h"
+#include "net/http/http_response_headers.h"
#include "url/gurl.h"
using content::RenderViewHost;
@@ -177,31 +179,6 @@ void WebAuthFlow::RenderProcessGone(base::TerminationStatus status) {
delegate_->OnAuthFlowFailure(WebAuthFlow::WINDOW_CLOSED);
}
-void WebAuthFlow::DidStartProvisionalLoadForFrame(
- content::RenderFrameHost* render_frame_host,
- const GURL& validated_url,
- bool is_error_page,
- bool is_iframe_srcdoc) {
- if (!render_frame_host->GetParent())
- BeforeUrlLoaded(validated_url);
-}
-
-void WebAuthFlow::DidFailProvisionalLoad(
- content::RenderFrameHost* render_frame_host,
- const GURL& validated_url,
- int error_code,
- const base::string16& error_description,
- bool was_ignored_by_handler) {
- TRACE_EVENT_ASYNC_STEP_PAST1("identity",
Michael Courage 2016/09/22 16:25:36 would be nice to keep the error tracing in the new
yzshen1 2016/09/22 18:07:52 I removed it because this doesn't have a correspon
- "WebAuthFlow",
- this,
- "DidFailProvisionalLoad",
- "error_code",
- error_code);
- if (delegate_)
- delegate_->OnAuthFlowFailure(LOAD_FAILED);
-}
-
void WebAuthFlow::DidGetRedirectForResourceRequest(
const content::ResourceRedirectDetails& details) {
BeforeUrlLoaded(details.new_url);
@@ -217,10 +194,20 @@ void WebAuthFlow::DidStopLoading() {
AfterUrlLoaded();
}
-void WebAuthFlow::DidNavigateMainFrame(
- const content::LoadCommittedDetails& details,
- const content::FrameNavigateParams& params) {
- if (delegate_ && details.http_status_code >= 400)
+void WebAuthFlow::DidStartNavigation(
+ content::NavigationHandle* navigation_handle) {
+ if (navigation_handle->IsInMainFrame())
+ BeforeUrlLoaded(navigation_handle->GetURL());
yzshen1 2016/09/16 22:32:44 One question: It seems the original code doesn't c
clamy 2016/09/19 10:02:54 It is possible to have 2 navigation sin the main f
yzshen1 2016/09/19 15:32:56 Thanks for the info! I will also wait for the WebA
Michael Courage 2016/09/19 19:11:43 At the time I wrote this code I didn't have a grea
+}
+
+void WebAuthFlow::DidFinishNavigation(
+ content::NavigationHandle* navigation_handle) {
+ bool failed =
+ navigation_handle->GetNetErrorCode() != net::OK ||
clamy 2016/09/19 10:02:54 This seems like it would trigger for a subframe na
yzshen1 2016/09/19 15:32:56 It seems this is what the original code did. But w
+ (navigation_handle->IsInMainFrame() &&
+ navigation_handle->GetResponseHeaders()->response_code() >= 400);
+
+ if (failed && delegate_)
delegate_->OnAuthFlowFailure(LOAD_FAILED);
}
« no previous file with comments | « chrome/browser/extensions/api/identity/web_auth_flow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698