OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/search/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( | 186 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( |
187 ChromeViewMsg_ChromeIdentityCheckResult::ID); | 187 ChromeViewMsg_ChromeIdentityCheckResult::ID); |
188 ASSERT_TRUE(message != NULL); | 188 ASSERT_TRUE(message != NULL); |
189 | 189 |
190 ChromeViewMsg_ChromeIdentityCheckResult::Param params; | 190 ChromeViewMsg_ChromeIdentityCheckResult::Param params; |
191 ChromeViewMsg_ChromeIdentityCheckResult::Read(message, ¶ms); | 191 ChromeViewMsg_ChromeIdentityCheckResult::Read(message, ¶ms); |
192 EXPECT_EQ(test_identity, get<0>(params)); | 192 EXPECT_EQ(test_identity, get<0>(params)); |
193 ASSERT_TRUE(get<1>(params)); | 193 ASSERT_TRUE(get<1>(params)); |
194 } | 194 } |
195 | 195 |
| 196 TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMatchSlightlyDifferentGmail) { |
| 197 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 198 CreateSigninManager(std::string("foobar123@gmail.com")); |
| 199 SearchTabHelper* search_tab_helper = |
| 200 SearchTabHelper::FromWebContents(web_contents()); |
| 201 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); |
| 202 |
| 203 // For gmail, canonicalization is done so that email addresses have a |
| 204 // standard form. |
| 205 const base::string16 test_identity = |
| 206 base::ASCIIToUTF16("Foo.Bar.123@gmail.com"); |
| 207 search_tab_helper->OnChromeIdentityCheck(test_identity); |
| 208 |
| 209 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( |
| 210 ChromeViewMsg_ChromeIdentityCheckResult::ID); |
| 211 ASSERT_TRUE(message != NULL); |
| 212 |
| 213 ChromeViewMsg_ChromeIdentityCheckResult::Param params; |
| 214 ChromeViewMsg_ChromeIdentityCheckResult::Read(message, ¶ms); |
| 215 EXPECT_EQ(test_identity, get<0>(params)); |
| 216 ASSERT_TRUE(get<1>(params)); |
| 217 } |
| 218 |
| 219 TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMatchSlightlyDifferentGmail2) { |
| 220 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 221 // |
| 222 CreateSigninManager(std::string("chrome.guy.7FOREVER")); |
| 223 SearchTabHelper* search_tab_helper = |
| 224 SearchTabHelper::FromWebContents(web_contents()); |
| 225 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); |
| 226 |
| 227 // For gmail/googlemail, canonicalization is done so that email addresses have |
| 228 // a standard form. |
| 229 const base::string16 test_identity = |
| 230 base::ASCIIToUTF16("chromeguy7forever@googlemail.com"); |
| 231 search_tab_helper->OnChromeIdentityCheck(test_identity); |
| 232 |
| 233 const IPC::Message* message = process()->sink().GetUniqueMessageMatching( |
| 234 ChromeViewMsg_ChromeIdentityCheckResult::ID); |
| 235 ASSERT_TRUE(message != NULL); |
| 236 |
| 237 ChromeViewMsg_ChromeIdentityCheckResult::Param params; |
| 238 ChromeViewMsg_ChromeIdentityCheckResult::Read(message, ¶ms); |
| 239 EXPECT_EQ(test_identity, get<0>(params)); |
| 240 ASSERT_TRUE(get<1>(params)); |
| 241 } |
| 242 |
196 TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMismatch) { | 243 TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMismatch) { |
197 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); | 244 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); |
198 CreateSigninManager(std::string("foo@bar.com")); | 245 CreateSigninManager(std::string("foo@bar.com")); |
199 SearchTabHelper* search_tab_helper = | 246 SearchTabHelper* search_tab_helper = |
200 SearchTabHelper::FromWebContents(web_contents()); | 247 SearchTabHelper::FromWebContents(web_contents()); |
201 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); | 248 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); |
202 | 249 |
203 const base::string16 test_identity = base::ASCIIToUTF16("bar@foo.com"); | 250 const base::string16 test_identity = base::ASCIIToUTF16("bar@foo.com"); |
204 search_tab_helper->OnChromeIdentityCheck(test_identity); | 251 search_tab_helper->OnChromeIdentityCheck(test_identity); |
205 | 252 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } | 518 } |
472 | 519 |
473 TEST_F(SearchTabHelperPrerenderTest, | 520 TEST_F(SearchTabHelperPrerenderTest, |
474 OnTabActivatedNoPrerenderIfOmniboxBlurred) { | 521 OnTabActivatedNoPrerenderIfOmniboxBlurred) { |
475 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false; | 522 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false; |
476 SearchTabHelper* search_tab_helper = | 523 SearchTabHelper* search_tab_helper = |
477 SearchTabHelper::FromWebContents(web_contents()); | 524 SearchTabHelper::FromWebContents(web_contents()); |
478 search_tab_helper->OnTabActivated(); | 525 search_tab_helper->OnTabActivated(); |
479 ASSERT_FALSE(IsInstantURLMarkedForPrerendering()); | 526 ASSERT_FALSE(IsInstantURLMarkedForPrerendering()); |
480 } | 527 } |
OLD | NEW |