Commit bcc921ca authored by Alex Ilin's avatar Alex Ilin Committed by Commit Bot

[identity] Mirror settings in the extension consent flow

This CL enables Mirror for the extension consent flow:
- Makes the account settings dialog appear during the consent flow when
  Gaia passes a Mirror response header. This allows the user to modify
  the list of accounts on their device.
- Keeps the consent flow window opened when it happens. In the case
  the user don't want to modify their accounts, they could go back to
  the consent flow.

Bug: 1026237
Change-Id: I3cdd8bb868e7ec8b80f9cd59f45aee2d06616b1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144200Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Alex Ilin <alexilin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758789}
parent d0f2ec9f
......@@ -37,6 +37,7 @@
#include "extensions/browser/extension_system.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "url/gurl.h"
#include "url/url_constants.h"
......@@ -247,6 +248,13 @@ void WebAuthFlow::DidFinishNavigation(
// the web auth flow.
DCHECK_EQ(net::ERR_UNKNOWN_URL_SCHEME,
navigation_handle->GetNetErrorCode());
} else if (navigation_handle->GetResponseHeaders() &&
navigation_handle->GetResponseHeaders()->response_code() ==
net::HTTP_NO_CONTENT) {
// Navigation to no content URLs is aborted but shouldn't be treated as a
// failure.
// In particular, Gaia navigates to a no content page to pass Mirror
// response headers.
} else {
failed = true;
TRACE_EVENT_NESTABLE_ASYNC_INSTANT1(
......
......@@ -43,7 +43,7 @@ function loadAuthUrlAndShowWindow(url, win) {
windowId = win.id;
}
webview.executeScript({file: 'inject.js'});
});
}, {once: true});
}
chrome.runtime.onMessageExternal.addListener(function(
......
......@@ -29,6 +29,7 @@
#include "chrome/browser/signin/cookie_reminter_factory.h"
#include "chrome/browser/signin/dice_response_handler.h"
#include "chrome/browser/signin/dice_tab_helper.h"
#include "chrome/browser/signin/header_modification_delegate_impl.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/process_dice_header_delegate_impl.h"
#include "chrome/browser/tab_contents/tab_util.h"
......@@ -192,9 +193,19 @@ void ProcessMirrorHeader(
signin_metrics::LogAccountReconcilorStateOnGaiaResponse(
account_reconcilor->GetState());
bool should_ignore_guest_webview = true;
#if BUILDFLAG(ENABLE_EXTENSIONS)
// The mirror headers from some guest web views need to be processed.
should_ignore_guest_webview =
HeaderModificationDelegateImpl::ShouldIgnoreGuestWebViewRequest(
web_contents);
#endif
// Do not do anything if the navigation happened in the "background".
if (!chrome::FindBrowserWithWebContents(web_contents))
if (!chrome::FindBrowserWithWebContents(web_contents) &&
should_ignore_guest_webview) {
return;
}
// Record the service type.
UMA_HISTOGRAM_ENUMERATION("AccountManager.ManageAccountsServiceType",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment