OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/content_settings/cookie_settings.h" | 8 #include "chrome/browser/content_settings/cookie_settings.h" |
9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
10 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 10 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/profiles/profile_info_cache.h" | 12 #include "chrome/browser/profiles/profile_info_cache.h" |
13 #include "chrome/browser/profiles/profile_io_data.h" | 13 #include "chrome/browser/profiles/profile_io_data.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/signin/fake_signin_manager.h" | 15 #include "chrome/browser/signin/fake_signin_manager.h" |
16 #include "chrome/browser/signin/signin_manager.h" | 16 #include "chrome/browser/signin/signin_manager.h" |
17 #include "chrome/browser/signin/signin_manager_factory.h" | 17 #include "chrome/browser/signin/signin_manager_factory.h" |
18 #include "chrome/browser/signin/signin_names_io_thread.h" | 18 #include "chrome/browser/signin/signin_names_io_thread.h" |
19 #include "chrome/browser/signin/signin_promo.h" | 19 #include "chrome/browser/signin/signin_promo.h" |
20 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
21 #include "chrome/browser/sync/profile_sync_service_mock.h" | 21 #include "chrome/browser/sync/profile_sync_service_mock.h" |
22 #include "chrome/browser/sync/test_profile_sync_service.h" | 22 #include "chrome/browser/sync/test_profile_sync_service.h" |
23 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 23 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 25 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
26 #include "chrome/test/base/testing_browser_process.h" | 26 #include "chrome/test/base/testing_browser_process.h" |
27 #include "chrome/test/base/testing_pref_service_syncable.h" | 27 #include "chrome/test/base/testing_pref_service_syncable.h" |
28 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
29 #include "chrome/test/base/testing_profile_manager.h" | 29 #include "chrome/test/base/testing_profile_manager.h" |
| 30 #include "components/autofill/core/common/password_form.h" |
30 #include "content/public/browser/browser_context.h" | 31 #include "content/public/browser/browser_context.h" |
31 #include "content/public/browser/navigation_details.h" | 32 #include "content/public/browser/navigation_details.h" |
32 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
33 #include "content/public/common/frame_navigate_params.h" | 34 #include "content/public/common/frame_navigate_params.h" |
34 #include "content/public/common/password_form.h" | |
35 #include "content/public/common/url_constants.h" | 35 #include "content/public/common/url_constants.h" |
36 #include "content/public/test/mock_render_process_host.h" | 36 #include "content/public/test/mock_render_process_host.h" |
37 #include "grit/chromium_strings.h" | 37 #include "grit/chromium_strings.h" |
38 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
39 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
40 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
41 | 41 |
42 using ::testing::_; | 42 using ::testing::_; |
43 using ::testing::AtLeast; | 43 using ::testing::AtLeast; |
44 using ::testing::Return; | 44 using ::testing::Return; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(true)); | 307 EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(true)); |
308 EXPECT_CALL(*sync_service, GetAuthError()). | 308 EXPECT_CALL(*sync_service, GetAuthError()). |
309 WillRepeatedly(::testing::ReturnRef(no_error_)); | 309 WillRepeatedly(::testing::ReturnRef(no_error_)); |
310 EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(false)); | 310 EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(false)); |
311 sync_service->Initialize(); | 311 sync_service->Initialize(); |
312 return sync_service; | 312 return sync_service; |
313 } | 313 } |
314 | 314 |
315 void OneClickSigninHelperTest::SubmitGAIAPassword( | 315 void OneClickSigninHelperTest::SubmitGAIAPassword( |
316 OneClickSigninHelper* helper) { | 316 OneClickSigninHelper* helper) { |
317 content::PasswordForm password_form; | 317 autofill::PasswordForm password_form; |
318 password_form.origin = GURL("https://accounts.google.com"); | 318 password_form.origin = GURL("https://accounts.google.com"); |
319 password_form.signon_realm = "https://accounts.google.com"; | 319 password_form.signon_realm = "https://accounts.google.com"; |
320 password_form.password_value = UTF8ToUTF16("password"); | 320 password_form.password_value = UTF8ToUTF16("password"); |
321 helper->PasswordSubmitted(password_form); | 321 helper->PasswordSubmitted(password_form); |
322 } | 322 } |
323 | 323 |
324 class OneClickSigninHelperIOTest : public OneClickSigninHelperTest { | 324 class OneClickSigninHelperIOTest : public OneClickSigninHelperTest { |
325 public: | 325 public: |
326 OneClickSigninHelperIOTest(); | 326 OneClickSigninHelperIOTest(); |
327 | 327 |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); | 869 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); |
870 | 870 |
871 // Simulate a policy disabling sync by writing kSyncManaged directly. | 871 // Simulate a policy disabling sync by writing kSyncManaged directly. |
872 // We should still offer to sign in the browser. | 872 // We should still offer to sign in the browser. |
873 profile()->GetTestingPrefService()->SetManagedPref( | 873 profile()->GetTestingPrefService()->SetManagedPref( |
874 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 874 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); |
875 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, | 875 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, |
876 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 876 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
877 valid_gaia_url_, std::string(), &request_, io_data.get())); | 877 valid_gaia_url_, std::string(), &request_, io_data.get())); |
878 } | 878 } |
OLD | NEW |