| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/basictypes.h" | 5 #include "base/basictypes.h" | 
| 6 #include "base/bind.h" | 6 #include "base/bind.h" | 
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" | 
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" | 
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" | 
| 10 #include "base/location.h" | 10 #include "base/location.h" | 
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" | 
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" | 
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" | 
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" | 
| 15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" | 
| 16 #include "base/values.h" | 16 #include "base/values.h" | 
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" | 
| 18 #include "chrome/browser/extensions/api/preferences_private/preferences_private_
     api.h" | 18 #include "chrome/browser/extensions/api/preferences_private/preferences_private_
     api.h" | 
| 19 #include "chrome/browser/extensions/extension_apitest.h" | 19 #include "chrome/browser/extensions/extension_apitest.h" | 
| 20 #include "chrome/browser/extensions/extension_function_test_utils.h" | 20 #include "chrome/browser/extensions/extension_function_test_utils.h" | 
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" | 
| 22 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" | 
| 23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 
| 24 #include "chrome/browser/sync/chrome_sync_client.h" | 24 #include "chrome/browser/sync/chrome_sync_client.h" | 
| 25 #include "chrome/browser/sync/profile_sync_service.h" | 25 #include "chrome/browser/sync/profile_sync_service.h" | 
| 26 #include "chrome/browser/sync/profile_sync_service_factory.h" | 26 #include "chrome/browser/sync/profile_sync_service_factory.h" | 
|  | 27 #include "chrome/browser/sync/profile_sync_test_util.h" | 
| 27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" | 
| 28 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" | 
| 29 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" | 
| 30 #include "chrome/test/base/testing_profile.h" | 31 #include "chrome/test/base/testing_profile.h" | 
| 31 #include "components/bookmarks/common/bookmark_constants.h" | 32 #include "components/bookmarks/common/bookmark_constants.h" | 
| 32 #include "components/sync_driver/signin_manager_wrapper.h" | 33 #include "components/sync_driver/signin_manager_wrapper.h" | 
| 33 #include "components/sync_driver/sync_api_component_factory_mock.h" | 34 #include "components/sync_driver/sync_api_component_factory_mock.h" | 
| 34 #include "components/sync_driver/sync_prefs.h" | 35 #include "components/sync_driver/sync_prefs.h" | 
| 35 #include "content/public/browser/browser_context.h" | 36 #include "content/public/browser/browser_context.h" | 
| 36 #include "extensions/test/extension_test_message_listener.h" | 37 #include "extensions/test/extension_test_message_listener.h" | 
| 37 | 38 | 
| 38 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) | 
| 39 #include "chromeos/chromeos_switches.h" | 40 #include "chromeos/chromeos_switches.h" | 
| 40 #endif | 41 #endif | 
| 41 | 42 | 
| 42 using extensions::PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction; | 43 using extensions::PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction; | 
| 43 | 44 | 
| 44 namespace { | 45 namespace { | 
| 45 | 46 | 
| 46 class FakeProfileSyncService : public ProfileSyncService { | 47 class FakeProfileSyncService : public ProfileSyncService { | 
| 47  public: | 48  public: | 
| 48   explicit FakeProfileSyncService(Profile* profile) | 49   explicit FakeProfileSyncService(Profile* profile) | 
| 49       : ProfileSyncService( | 50       : ProfileSyncService( | 
| 50             make_scoped_ptr(new browser_sync::ChromeSyncClient( | 51             make_scoped_ptr(new browser_sync::ChromeSyncClient( | 
| 51                 profile, | 52                 profile, | 
| 52                 make_scoped_ptr(new SyncApiComponentFactoryMock()))), | 53                 make_scoped_ptr(new SyncApiComponentFactoryMock()))), | 
| 53             profile, | 54             profile, | 
| 54             make_scoped_ptr<SigninManagerWrapper>(NULL), | 55             make_scoped_ptr<SigninManagerWrapper>(NULL), | 
| 55             ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 56             ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 
| 56             browser_sync::MANUAL_START), | 57             browser_sync::MANUAL_START, | 
|  | 58             base::Bind(&EmptyNetworkTimeUpdate)), | 
| 57         sync_initialized_(true), | 59         sync_initialized_(true), | 
| 58         initialized_state_violation_(false) {} | 60         initialized_state_violation_(false) {} | 
| 59 | 61 | 
| 60   ~FakeProfileSyncService() override {} | 62   ~FakeProfileSyncService() override {} | 
| 61 | 63 | 
| 62   static scoped_ptr<KeyedService> BuildFakeProfileSyncService( | 64   static scoped_ptr<KeyedService> BuildFakeProfileSyncService( | 
| 63       content::BrowserContext* context) { | 65       content::BrowserContext* context) { | 
| 64     return make_scoped_ptr( | 66     return make_scoped_ptr( | 
| 65         new FakeProfileSyncService(static_cast<Profile*>(context))); | 67         new FakeProfileSyncService(static_cast<Profile*>(context))); | 
| 66   } | 68   } | 
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 193 | 195 | 
| 194 // Verifies that we wait for the sync service to be ready before checking | 196 // Verifies that we wait for the sync service to be ready before checking | 
| 195 // encryption status. | 197 // encryption status. | 
| 196 IN_PROC_BROWSER_TEST_F(PreferencesPrivateApiTest, | 198 IN_PROC_BROWSER_TEST_F(PreferencesPrivateApiTest, | 
| 197                        GetSyncCategoriesWithoutPassphraseAsynchronous) { | 199                        GetSyncCategoriesWithoutPassphraseAsynchronous) { | 
| 198   service_->set_sync_initialized(false); | 200   service_->set_sync_initialized(false); | 
| 199   TestGetSyncCategoriesWithoutPassphraseFunction(); | 201   TestGetSyncCategoriesWithoutPassphraseFunction(); | 
| 200 } | 202 } | 
| 201 | 203 | 
| 202 }  // namespace | 204 }  // namespace | 
| OLD | NEW | 
|---|