| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/extensions/test_extension_system.h" | 26 #include "chrome/browser/extensions/test_extension_system.h" |
| 27 #include "chrome/browser/history/history_service.h" | 27 #include "chrome/browser/history/history_service.h" |
| 28 #include "chrome/browser/history/history_service_factory.h" | 28 #include "chrome/browser/history/history_service_factory.h" |
| 29 #include "chrome/browser/prefs/browser_prefs.h" | 29 #include "chrome/browser/prefs/browser_prefs.h" |
| 30 #include "chrome/common/extensions/extension_constants.h" | 30 #include "chrome/common/extensions/extension_constants.h" |
| 31 #include "chrome/test/base/testing_pref_service_syncable.h" | 31 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 32 #include "chrome/test/base/testing_profile.h" | 32 #include "chrome/test/base/testing_profile.h" |
| 33 #include "components/user_prefs/pref_registry_syncable.h" | 33 #include "components/user_prefs/pref_registry_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/browser/extension_prefs.h" |
| 36 #include "extensions/common/extension.h" | 37 #include "extensions/common/extension.h" |
| 37 #include "extensions/common/manifest_constants.h" | 38 #include "extensions/common/manifest_constants.h" |
| 38 #include "extensions/common/permissions/permission_set.h" | 39 #include "extensions/common/permissions/permission_set.h" |
| 39 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
| 40 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
| 41 | 42 |
| 42 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
| 43 #include "chrome/browser/chromeos/login/user_manager.h" | 44 #include "chrome/browser/chromeos/login/user_manager.h" |
| 44 #include "chrome/browser/chromeos/settings/cros_settings.h" | 45 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 45 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 46 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Extensions) { | 195 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Extensions) { |
| 195 ExtensionService* extensions = | 196 ExtensionService* extensions = |
| 196 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); | 197 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); |
| 197 ASSERT_TRUE(extensions); | 198 ASSERT_TRUE(extensions); |
| 198 | 199 |
| 199 // Profile is new but has synced extensions. | 200 // Profile is new but has synced extensions. |
| 200 | 201 |
| 201 // (The web store doesn't count.) | 202 // (The web store doesn't count.) |
| 202 scoped_refptr<extensions::Extension> webstore = | 203 scoped_refptr<extensions::Extension> webstore = |
| 203 CreateExtension("web store", extension_misc::kWebStoreAppId); | 204 CreateExtension("web store", extension_misc::kWebStoreAppId); |
| 204 extensions->extension_prefs()->AddGrantedPermissions( | 205 extensions::ExtensionPrefs::Get(profile_.get())->AddGrantedPermissions( |
| 205 webstore->id(), make_scoped_refptr(new extensions::PermissionSet).get()); | 206 webstore->id(), make_scoped_refptr(new extensions::PermissionSet).get()); |
| 206 extensions->AddExtension(webstore.get()); | 207 extensions->AddExtension(webstore.get()); |
| 207 EXPECT_FALSE(GetCallbackResult( | 208 EXPECT_FALSE(GetCallbackResult( |
| 208 base::Bind(&ui::CheckShouldPromptForNewProfile, profile_.get()))); | 209 base::Bind(&ui::CheckShouldPromptForNewProfile, profile_.get()))); |
| 209 | 210 |
| 210 scoped_refptr<extensions::Extension> extension = | 211 scoped_refptr<extensions::Extension> extension = |
| 211 CreateExtension("foo", std::string()); | 212 CreateExtension("foo", std::string()); |
| 212 extensions->extension_prefs()->AddGrantedPermissions( | 213 extensions::ExtensionPrefs::Get(profile_.get())->AddGrantedPermissions( |
| 213 extension->id(), make_scoped_refptr(new extensions::PermissionSet).get()); | 214 extension->id(), make_scoped_refptr(new extensions::PermissionSet).get()); |
| 214 extensions->AddExtension(extension.get()); | 215 extensions->AddExtension(extension.get()); |
| 215 EXPECT_TRUE(GetCallbackResult( | 216 EXPECT_TRUE(GetCallbackResult( |
| 216 base::Bind(&ui::CheckShouldPromptForNewProfile, profile_.get()))); | 217 base::Bind(&ui::CheckShouldPromptForNewProfile, profile_.get()))); |
| 217 } | 218 } |
| 218 | 219 |
| 219 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_History) { | 220 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_History) { |
| 220 HistoryService* history = HistoryServiceFactory::GetForProfile( | 221 HistoryService* history = HistoryServiceFactory::GetForProfile( |
| 221 profile_.get(), | 222 profile_.get(), |
| 222 Profile::EXPLICIT_ACCESS); | 223 Profile::EXPLICIT_ACCESS); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 260 |
| 260 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { | 261 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { |
| 261 // Browser has been shut down since profile was created. | 262 // Browser has been shut down since profile was created. |
| 262 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); | 263 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); |
| 263 EXPECT_TRUE( | 264 EXPECT_TRUE( |
| 264 GetCallbackResult( | 265 GetCallbackResult( |
| 265 base::Bind( | 266 base::Bind( |
| 266 &ui::CheckShouldPromptForNewProfile, | 267 &ui::CheckShouldPromptForNewProfile, |
| 267 profile_.get()))); | 268 profile_.get()))); |
| 268 } | 269 } |
| OLD | NEW |