diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-04 12:37:11 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-04 12:37:11 +0000 |
commit | 6599238f5d69edbdb563ce53591d8de62ea265f7 (patch) | |
tree | d46085a24028cb0fd985a48daba7c8c3212924e5 | |
parent | 93e8e2cc11a6007af1ee5176c637dc3de8699500 (diff) | |
download | chromium_src-6599238f5d69edbdb563ce53591d8de62ea265f7.zip chromium_src-6599238f5d69edbdb563ce53591d8de62ea265f7.tar.gz chromium_src-6599238f5d69edbdb563ce53591d8de62ea265f7.tar.bz2 |
rAc: don't open sign in continue url in new tab
BUG=326882,331127
TEST=rac sign in works
Review URL: https://codereview.chromium.org/123363002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243030 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 33 insertions, 22 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc index ede64d7..1cd3bf0 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc @@ -29,6 +29,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" #include "components/autofill/content/browser/wallet/mock_wallet_client.h" +#include "components/autofill/content/browser/wallet/wallet_service_url.h" #include "components/autofill/content/browser/wallet/wallet_test_util.h" #include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_test_utils.h" @@ -130,10 +131,6 @@ class TestAutofillDialogController : public AutofillDialogControllerImpl { return GURL(chrome::kChromeUIVersionURL); } - GURL SignInContinueUrl() const { - return GURL(content::kAboutBlankURL); - } - virtual void ViewClosed() OVERRIDE { message_loop_runner_->Quit(); AutofillDialogControllerImpl::ViewClosed(); @@ -221,7 +218,7 @@ class TestAutofillDialogController : public AutofillDialogControllerImpl { virtual bool IsSignInContinueUrl(const GURL& url, size_t* user_index) const OVERRIDE { *user_index = sign_in_user_index_; - return url == SignInContinueUrl(); + return url == wallet::GetSignInContinueUrl(); } private: @@ -1086,7 +1083,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, SimulateSuccessfulSignIn) { sign_in_page_observer.Wait(); NavEntryCommittedObserver continue_page_observer( - controller()->SignInContinueUrl(), + wallet::GetSignInContinueUrl(), content::NotificationService::AllSources()); EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); @@ -1095,11 +1092,12 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, SimulateSuccessfulSignIn) { controller()->AccountChooserModelForTesting(); EXPECT_FALSE(account_chooser_model->WalletIsSelected()); - sign_in_contents->GetController().LoadURL( - controller()->SignInContinueUrl(), - content::Referrer(), - content::PAGE_TRANSITION_FORM_SUBMIT, - std::string()); + content::OpenURLParams params(wallet::GetSignInContinueUrl(), + content::Referrer(), + CURRENT_TAB, + content::PAGE_TRANSITION_LINK, + true); + sign_in_contents->GetDelegate()->OpenURLFromTab(sign_in_contents, params); EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems()); continue_page_observer.Wait(); @@ -1146,7 +1144,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddAccount) { sign_in_page_observer.Wait(); NavEntryCommittedObserver continue_page_observer( - controller()->SignInContinueUrl(), + wallet::GetSignInContinueUrl(), content::NotificationService::AllSources()); EXPECT_EQ(sign_in_contents->GetURL(), controller()->SignInUrl()); @@ -1155,11 +1153,12 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddAccount) { // User signs into new account, account 3. controller()->set_sign_in_user_index(3U); - sign_in_contents->GetController().LoadURL( - controller()->SignInContinueUrl(), - content::Referrer(), - content::PAGE_TRANSITION_FORM_SUBMIT, - std::string()); + content::OpenURLParams params(wallet::GetSignInContinueUrl(), + content::Referrer(), + CURRENT_TAB, + content::PAGE_TRANSITION_LINK, + true); + sign_in_contents->GetDelegate()->OpenURLFromTab(sign_in_contents, params); EXPECT_CALL(*controller()->GetTestingWalletClient(), GetWalletItems()); continue_page_observer.Wait(); diff --git a/chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.cc b/chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.cc index 8770633..987a0a8 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.cc @@ -21,8 +21,7 @@ using content::OpenURLParams; // Signals if |params| require opening inside the current WebContents. bool IsInPageTransition(const OpenURLParams& params) { - return params.transition == content::PAGE_TRANSITION_LINK && - params.disposition == CURRENT_TAB; + return params.disposition == CURRENT_TAB; } // Indicates if the open action specified by |params| should happen in the diff --git a/components/autofill/content/browser/wallet/wallet_service_url.cc b/components/autofill/content/browser/wallet/wallet_service_url.cc index c539763..75c6d09 100644 --- a/components/autofill/content/browser/wallet/wallet_service_url.cc +++ b/components/autofill/content/browser/wallet/wallet_service_url.cc @@ -10,8 +10,11 @@ #include "base/format_macros.h" #include "base/metrics/field_trial.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "base/strings/utf_string_conversions.h" #include "components/autofill/core/common/autofill_switches.h" +#include "content/public/common/url_constants.h" #include "google_apis/gaia/gaia_urls.h" #include "net/base/url_util.h" #include "url/gurl.h" @@ -154,8 +157,8 @@ GURL GetSignInContinueUrl() { } bool IsSignInContinueUrl(const GURL& url, size_t* user_index) { - GURL final_url = wallet::GetSignInContinueUrl(); - if (!url.SchemeIsSecure() || + GURL final_url = GetSignInContinueUrl(); + if (url.scheme() != final_url.scheme() || url.host() != final_url.host() || url.path() != final_url.path()) { return false; @@ -179,7 +182,12 @@ bool IsSignInContinueUrl(const GURL& url, size_t* user_index) { } bool IsSignInRelatedUrl(const GURL& url) { - return url.GetOrigin() == GetSignInUrl().GetOrigin(); + size_t unused; + return url.GetOrigin() == GetSignInUrl().GetOrigin() || + StartsWith(base::UTF8ToUTF16(url.GetOrigin().host()), + base::ASCIIToUTF16("accounts."), + false) || + IsSignInContinueUrl(url, &unused); } bool IsUsingProd() { diff --git a/components/autofill/content/browser/wallet/wallet_service_url_unittest.cc b/components/autofill/content/browser/wallet/wallet_service_url_unittest.cc index 4825263..60edb4f 100644 --- a/components/autofill/content/browser/wallet/wallet_service_url_unittest.cc +++ b/components/autofill/content/browser/wallet/wallet_service_url_unittest.cc @@ -98,6 +98,8 @@ TEST(WalletServiceUrl, IsUsingProd) { } TEST(WalletServiceUrl, IsSignInContinueUrl) { + EXPECT_TRUE(GetSignInContinueUrl().SchemeIsSecure()); + CommandLine* command_line = CommandLine::ForCurrentProcess(); command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1"); @@ -129,6 +131,9 @@ TEST(WalletServiceUrl, IsSignInContinueUrl) { TEST(WalletServiceUrl, IsSignInRelatedUrl) { EXPECT_TRUE(IsSignInRelatedUrl(GetSignInUrl())); + EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.youtube.com"))); + EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.youtube.com/"))); + EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.google.com"))); EXPECT_FALSE(IsSignInRelatedUrl(GURL("http://google.com"))); } |