Commit 62c45457 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[Creation flow] Open external links in a popup

This CL addresses opening external links in the sign-in flow for profile
creation. Because there is no browser window in this step, all such
links are open in a new browser popup window.

Bug: 1126913
Change-Id: Ib7c137bbda1e1ad7cc0e1291b0a5e8a3468aa806
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485056
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818799}
parent 189207a6
......@@ -22,6 +22,8 @@
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/views/profiles/profile_picker_view_sync_delegate.h"
#include "chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.h"
#include "chrome/browser/ui/webui/signin/profile_picker_ui.h"
......@@ -350,6 +352,25 @@ bool ProfilePickerView::HandleContextMenu(
return true;
}
void ProfilePickerView::AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
DCHECK(signed_in_profile_being_created_)
<< "Opening new tabs should only happen within GAIA signin";
NavigateParams params(signed_in_profile_being_created_, target_url,
ui::PAGE_TRANSITION_LINK);
// Open all links as new popups.
params.disposition = WindowOpenDisposition::NEW_POPUP;
params.contents_to_insert = std::move(new_contents);
params.window_bounds = initial_rect;
Navigate(&params);
}
void ProfilePickerView::OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) {
DCHECK(!account_info.IsEmpty());
......
......@@ -76,6 +76,13 @@ class ProfilePickerView : public views::DialogDelegateView,
// content::WebContentsDelegate:
bool HandleContextMenu(content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params) override;
void AddNewContents(content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) override;
// IdentityManager::Observer:
void OnRefreshTokenUpdatedForAccount(
......
......@@ -440,6 +440,43 @@ IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
kProfileColor);
}
IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
CreateSignedInProfileOpenLink) {
ASSERT_EQ(1u, BrowserList::GetInstance()->size());
ProfilePicker::Show(ProfilePicker::EntryPoint::kProfileMenuAddNewProfile);
WaitForNewWebView();
// Simulate a click on the signin button.
base::MockCallback<base::OnceClosure> switch_failure_callback;
EXPECT_CALL(switch_failure_callback, Run()).Times(0);
ProfilePicker::SwitchToSignIn(kProfileColor, switch_failure_callback.Get());
// The DICE navigation happens in a new web view (for the profile being
// created), wait for it.
WaitForNewWebView();
FirstVisuallyNonEmptyPaintObserver(
web_contents(), GaiaUrls::GetInstance()->signin_chrome_sync_dice())
.Wait();
// Simulate clicking on a link that opens in a new window.
const GURL kURL("https://foo.google.com");
EXPECT_TRUE(ExecuteScript(web_contents(),
"var link = document.createElement('a');"
"link.href = '" +
kURL.spec() +
"';"
"link.target = '_blank';"
"document.body.appendChild(link);"
"link.click();"));
// A new pppup browser is displayed (with the specified URL).
Browser* new_browser = BrowserAddedWaiter(2u).Wait();
EXPECT_EQ(new_browser->type(), Browser::TYPE_POPUP);
FirstVisuallyNonEmptyPaintObserver(
new_browser->tab_strip_model()->GetActiveWebContents(), kURL)
.Wait();
}
IN_PROC_BROWSER_TEST_F(ProfilePickerCreationFlowBrowserTest,
CreateSignedInProfileSigninAlreadyExists) {
ASSERT_EQ(1u, BrowserList::GetInstance()->size());
......
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