| 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/sync/profile_signin_confirmation_helper.h" | 5 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "components/bookmarks/browser/bookmark_model.h" | 26 #include "components/bookmarks/browser/bookmark_model.h" |
| 27 #include "components/bookmarks/test/bookmark_test_helpers.h" | 27 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 28 #include "components/history/core/browser/history_service.h" | 28 #include "components/history/core/browser/history_service.h" |
| 29 #include "components/pref_registry/pref_registry_syncable.h" | 29 #include "components/pref_registry/pref_registry_syncable.h" |
| 30 #include "components/prefs/pref_notifier_impl.h" | 30 #include "components/prefs/pref_notifier_impl.h" |
| 31 #include "components/prefs/pref_service.h" | 31 #include "components/prefs/pref_service.h" |
| 32 #include "components/prefs/testing_pref_service.h" | 32 #include "components/prefs/testing_pref_service.h" |
| 33 #include "components/sync_preferences/testing_pref_service_syncable.h" | 33 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 34 #include "content/public/test/test_browser_thread_bundle.h" | 34 #include "content/public/test/test_browser_thread_bundle.h" |
| 35 #include "content/public/test/test_utils.h" | 35 #include "content/public/test/test_utils.h" |
| 36 #include "extensions/features/features.h" |
| 36 #include "testing/gmock/include/gmock/gmock.h" | 37 #include "testing/gmock/include/gmock/gmock.h" |
| 37 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 38 | 39 |
| 39 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
| 40 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | 41 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
| 41 #include "chrome/browser/chromeos/settings/cros_settings.h" | 42 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 42 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 43 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 43 #endif | 44 #endif |
| 44 | 45 |
| 45 #if defined(ENABLE_EXTENSIONS) | 46 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 46 #include "chrome/browser/extensions/extension_service.h" | 47 #include "chrome/browser/extensions/extension_service.h" |
| 47 #include "chrome/browser/extensions/test_extension_system.h" | 48 #include "chrome/browser/extensions/test_extension_system.h" |
| 48 #include "chrome/common/extensions/extension_constants.h" | 49 #include "chrome/common/extensions/extension_constants.h" |
| 49 #include "extensions/browser/extension_prefs.h" | 50 #include "extensions/browser/extension_prefs.h" |
| 50 #include "extensions/common/constants.h" | 51 #include "extensions/common/constants.h" |
| 51 #include "extensions/common/extension.h" | 52 #include "extensions/common/extension.h" |
| 52 #include "extensions/common/manifest_constants.h" | 53 #include "extensions/common/manifest_constants.h" |
| 53 #include "extensions/common/permissions/permission_set.h" | 54 #include "extensions/common/permissions/permission_set.h" |
| 54 #endif | 55 #endif |
| 55 | 56 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 84 PrefReadError GetReadError() const override { return read_error_; } | 85 PrefReadError GetReadError() const override { return read_error_; } |
| 85 bool IsInitializationComplete() const override { return true; } | 86 bool IsInitializationComplete() const override { return true; } |
| 86 void set_read_error(PrefReadError read_error) { | 87 void set_read_error(PrefReadError read_error) { |
| 87 read_error_ = read_error; | 88 read_error_ = read_error; |
| 88 } | 89 } |
| 89 private: | 90 private: |
| 90 ~TestingPrefStoreWithCustomReadError() override {} | 91 ~TestingPrefStoreWithCustomReadError() override {} |
| 91 PrefReadError read_error_; | 92 PrefReadError read_error_; |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 #if defined(ENABLE_EXTENSIONS) | 95 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 95 #if defined(OS_WIN) | 96 #if defined(OS_WIN) |
| 96 const base::FilePath::CharType kExtensionFilePath[] = | 97 const base::FilePath::CharType kExtensionFilePath[] = |
| 97 FILE_PATH_LITERAL("c:\\foo"); | 98 FILE_PATH_LITERAL("c:\\foo"); |
| 98 #elif defined(OS_POSIX) | 99 #elif defined(OS_POSIX) |
| 99 const base::FilePath::CharType kExtensionFilePath[] = | 100 const base::FilePath::CharType kExtensionFilePath[] = |
| 100 FILE_PATH_LITERAL("/oo"); | 101 FILE_PATH_LITERAL("/oo"); |
| 101 #endif | 102 #endif |
| 102 | 103 |
| 103 static scoped_refptr<extensions::Extension> CreateExtension( | 104 static scoped_refptr<extensions::Extension> CreateExtension( |
| 104 const std::string& name, | 105 const std::string& name, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 chrome::RegisterUserProfilePrefs(pref_service->registry()); | 141 chrome::RegisterUserProfilePrefs(pref_service->registry()); |
| 141 builder.SetPrefService( | 142 builder.SetPrefService( |
| 142 base::WrapUnique<sync_preferences::PrefServiceSyncable>(pref_service)); | 143 base::WrapUnique<sync_preferences::PrefServiceSyncable>(pref_service)); |
| 143 profile_ = builder.Build(); | 144 profile_ = builder.Build(); |
| 144 | 145 |
| 145 // Initialize the services we check. | 146 // Initialize the services we check. |
| 146 profile_->CreateBookmarkModel(true); | 147 profile_->CreateBookmarkModel(true); |
| 147 model_ = BookmarkModelFactory::GetForBrowserContext(profile_.get()); | 148 model_ = BookmarkModelFactory::GetForBrowserContext(profile_.get()); |
| 148 bookmarks::test::WaitForBookmarkModelToLoad(model_); | 149 bookmarks::test::WaitForBookmarkModelToLoad(model_); |
| 149 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 150 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); |
| 150 #if defined(ENABLE_EXTENSIONS) | 151 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 151 extensions::TestExtensionSystem* system = | 152 extensions::TestExtensionSystem* system = |
| 152 static_cast<extensions::TestExtensionSystem*>( | 153 static_cast<extensions::TestExtensionSystem*>( |
| 153 extensions::ExtensionSystem::Get(profile_.get())); | 154 extensions::ExtensionSystem::Get(profile_.get())); |
| 154 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 155 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 155 system->CreateExtensionService(&command_line, | 156 system->CreateExtensionService(&command_line, |
| 156 base::FilePath(kExtensionFilePath), | 157 base::FilePath(kExtensionFilePath), |
| 157 false); | 158 false); |
| 158 #endif | 159 #endif |
| 159 } | 160 } |
| 160 | 161 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 model_->AddURL(model_->bookmark_bar_node(), 0, | 196 model_->AddURL(model_->bookmark_bar_node(), 0, |
| 196 base::string16(base::ASCIIToUTF16("foo")), | 197 base::string16(base::ASCIIToUTF16("foo")), |
| 197 GURL("http://foo.com")); | 198 GURL("http://foo.com")); |
| 198 EXPECT_TRUE( | 199 EXPECT_TRUE( |
| 199 GetCallbackResult( | 200 GetCallbackResult( |
| 200 base::Bind( | 201 base::Bind( |
| 201 &ui::CheckShouldPromptForNewProfile, | 202 &ui::CheckShouldPromptForNewProfile, |
| 202 profile_.get()))); | 203 profile_.get()))); |
| 203 } | 204 } |
| 204 | 205 |
| 205 #if defined(ENABLE_EXTENSIONS) | 206 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 206 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Extensions) { | 207 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Extensions) { |
| 207 ExtensionService* extensions = | 208 ExtensionService* extensions = |
| 208 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); | 209 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); |
| 209 ASSERT_TRUE(extensions); | 210 ASSERT_TRUE(extensions); |
| 210 | 211 |
| 211 // Profile is new but has synced extensions. | 212 // Profile is new but has synced extensions. |
| 212 | 213 |
| 213 // (The web store doesn't count.) | 214 // (The web store doesn't count.) |
| 214 scoped_refptr<extensions::Extension> webstore = | 215 scoped_refptr<extensions::Extension> webstore = |
| 215 CreateExtension("web store", | 216 CreateExtension("web store", |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 277 |
| 277 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { | 278 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { |
| 278 // Browser has been shut down since profile was created. | 279 // Browser has been shut down since profile was created. |
| 279 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); | 280 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); |
| 280 EXPECT_TRUE( | 281 EXPECT_TRUE( |
| 281 GetCallbackResult( | 282 GetCallbackResult( |
| 282 base::Bind( | 283 base::Bind( |
| 283 &ui::CheckShouldPromptForNewProfile, | 284 &ui::CheckShouldPromptForNewProfile, |
| 284 profile_.get()))); | 285 profile_.get()))); |
| 285 } | 286 } |
| OLD | NEW |