summaryrefslogtreecommitdiffstats
path: root/ios
diff options
context:
space:
mode:
authorvabr <vabr@chromium.org>2015-12-15 05:07:28 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-15 13:08:12 +0000
commit15d555b0c2cdaea6f66bc71300d166bf19ae8242 (patch)
treec964a3b40392fbde74fba11132867c6f11dbd09a /ios
parent968329336ac2207611a7f9fb50883646f7023110 (diff)
downloadchromium_src-15d555b0c2cdaea6f66bc71300d166bf19ae8242.zip
chromium_src-15d555b0c2cdaea6f66bc71300d166bf19ae8242.tar.gz
chromium_src-15d555b0c2cdaea6f66bc71300d166bf19ae8242.tar.bz2
Reland: Port iOS to use IOSChromeProfileSyncServiceFactory
This CL switches from using ProfileSyncServiceFactory to IOSChromeProfileSyncServiceFactory in ios. The CL is a relanding of https://codereview.chromium.org/1522993002/. Patch set 1 here is patch set 1 from that CL, which got reverted in https://codereview.chromium.org/1522363002/. Patch set 2 here is the fix. TBR=sdefresne@chromium.org BUG=565305 Review URL: https://codereview.chromium.org/1525043003 Cr-Commit-Position: refs/heads/master@{#365235}
Diffstat (limited to 'ios')
-rw-r--r--ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.cc6
-rw-r--r--ios/chrome/browser/browser_state/bookmark_model_loaded_observer.cc4
-rw-r--r--ios/chrome/browser/history/web_history_service_factory.cc8
-rw-r--r--ios/chrome/browser/passwords/ios_chrome_password_store_factory.cc5
-rw-r--r--ios/chrome/browser/sync/glue/sync_start_util.cc6
-rw-r--r--ios/chrome/browser/sync/ios_chrome_sync_client.cc16
-rw-r--r--ios/chrome/browser/sync/sync_setup_service_factory.cc8
-rw-r--r--ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc5
-rw-r--r--ios/public/provider/chrome/browser/keyed_service_provider.cc1
-rw-r--r--ios/public/provider/chrome/browser/keyed_service_provider.h16
-rw-r--r--ios/public/test/test_keyed_service_provider.cc16
-rw-r--r--ios/public/test/test_keyed_service_provider.h7
12 files changed, 28 insertions, 70 deletions
diff --git a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.cc b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.cc
index a40bc52..dd70a62 100644
--- a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.cc
+++ b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.cc
@@ -7,6 +7,7 @@
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
+#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/history/core/browser/history_service.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/omnibox/browser/autocomplete_classifier.h"
@@ -20,8 +21,8 @@
#include "ios/chrome/browser/history/top_sites_factory.h"
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
-#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
AutocompleteProviderClientImpl::AutocompleteProviderClientImpl(
ios::ChromeBrowserState* browser_state)
@@ -138,8 +139,7 @@ bool AutocompleteProviderClientImpl::BookmarkBarIsVisible() const {
bool AutocompleteProviderClientImpl::TabSyncEnabledAndUnencrypted() const {
return sync_driver::IsTabSyncEnabledAndUnencrypted(
- ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
- browser_state_),
+ IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state_),
browser_state_->GetPrefs());
}
diff --git a/ios/chrome/browser/browser_state/bookmark_model_loaded_observer.cc b/ios/chrome/browser/browser_state/bookmark_model_loaded_observer.cc
index 21ec9c4..8be019d 100644
--- a/ios/chrome/browser/browser_state/bookmark_model_loaded_observer.cc
+++ b/ios/chrome/browser/browser_state/bookmark_model_loaded_observer.cc
@@ -5,7 +5,7 @@
#include "ios/chrome/browser/browser_state/bookmark_model_loaded_observer.h"
#include "components/bookmarks/browser/bookmark_model.h"
-#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
BookmarkModelLoadedObserver::BookmarkModelLoadedObserver(
ios::ChromeBrowserState* browser_state)
@@ -17,7 +17,7 @@ void BookmarkModelLoadedObserver::BookmarkModelLoaded(
bookmarks::BookmarkModel* model,
bool ids_reassigned) {
// Causes lazy-load if sync is enabled.
- ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(browser_state_);
+ IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state_);
model->RemoveObserver(this);
delete this;
}
diff --git a/ios/chrome/browser/history/web_history_service_factory.cc b/ios/chrome/browser/history/web_history_service_factory.cc
index aee3a49..27c1ddb 100644
--- a/ios/chrome/browser/history/web_history_service_factory.cc
+++ b/ios/chrome/browser/history/web_history_service_factory.cc
@@ -6,6 +6,7 @@
#include "base/memory/singleton.h"
#include "base/prefs/pref_service.h"
+#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/history/core/browser/web_history_service.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
@@ -13,8 +14,8 @@
#include "components/sync_driver/sync_service.h"
#include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
#include "ios/chrome/browser/signin/signin_manager_factory.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
-#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "net/url_request/url_request_context_getter.h"
namespace ios {
@@ -24,7 +25,7 @@ namespace {
// false otherwise.
bool IsHistorySyncEnabled(ios::ChromeBrowserState* browser_state) {
sync_driver::SyncService* sync_service =
- GetKeyedServiceProvider()->GetSyncServiceForBrowserState(browser_state);
+ IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state);
return sync_service && sync_service->IsSyncActive() &&
sync_service->GetActiveDataTypes().Has(
syncer::HISTORY_DELETE_DIRECTIVES);
@@ -53,8 +54,7 @@ WebHistoryServiceFactory::WebHistoryServiceFactory()
: BrowserStateKeyedServiceFactory(
"WebHistoryService",
BrowserStateDependencyManager::GetInstance()) {
- ios::KeyedServiceProvider* provider = ios::GetKeyedServiceProvider();
- DependsOn(provider->GetSyncServiceFactory());
+ DependsOn(IOSChromeProfileSyncServiceFactory::GetInstance());
DependsOn(OAuth2TokenServiceFactory::GetInstance());
DependsOn(ios::SigninManagerFactory::GetInstance());
}
diff --git a/ios/chrome/browser/passwords/ios_chrome_password_store_factory.cc b/ios/chrome/browser/passwords/ios_chrome_password_store_factory.cc
index fe82ae7..259e28d 100644
--- a/ios/chrome/browser/passwords/ios_chrome_password_store_factory.cc
+++ b/ios/chrome/browser/passwords/ios_chrome_password_store_factory.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/memory/singleton.h"
+#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/password_manager/core/browser/affiliated_match_helper.h"
@@ -17,9 +18,9 @@
#include "components/sync_driver/sync_service.h"
#include "ios/chrome/browser/browser_state/browser_state_otr_helper.h"
#include "ios/chrome/browser/sync/glue/sync_start_util.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/browser/web_data_service_factory.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
-#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "ios/web/public/web_thread.h"
// static
@@ -48,7 +49,7 @@ void IOSChromePasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged(
scoped_refptr<password_manager::PasswordStore> password_store =
GetForBrowserState(browser_state, ServiceAccessType::EXPLICIT_ACCESS);
sync_driver::SyncService* sync_service =
- ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserStateIfExists(
+ IOSChromeProfileSyncServiceFactory::GetForBrowserStateIfExists(
browser_state);
net::URLRequestContextGetter* request_context_getter =
browser_state->GetRequestContext();
diff --git a/ios/chrome/browser/sync/glue/sync_start_util.cc b/ios/chrome/browser/sync/glue/sync_start_util.cc
index 22123a3..0ac61b9 100644
--- a/ios/chrome/browser/sync/glue/sync_start_util.cc
+++ b/ios/chrome/browser/sync/glue/sync_start_util.cc
@@ -7,11 +7,12 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/location.h"
+#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/sync_driver/sync_service.h"
#include "ios/chrome/browser/application_context.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state_manager.h"
-#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "ios/web/public/web_thread.h"
namespace ios {
@@ -35,8 +36,7 @@ void StartSyncOnUIThread(const base::FilePath& browser_state_path,
}
sync_driver::SyncService* sync_service =
- ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
- browser_state);
+ IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state);
if (!sync_service) {
DVLOG(2) << "No SyncService for browser state, can't start sync.";
return;
diff --git a/ios/chrome/browser/sync/ios_chrome_sync_client.cc b/ios/chrome/browser/sync/ios_chrome_sync_client.cc
index e683c48..ea64a82 100644
--- a/ios/chrome/browser/sync/ios_chrome_sync_client.cc
+++ b/ios/chrome/browser/sync/ios_chrome_sync_client.cc
@@ -45,13 +45,13 @@
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
#include "ios/chrome/browser/sync/glue/sync_start_util.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/sessions/ios_chrome_local_session_event_router.h"
#include "ios/chrome/browser/undo/bookmark_undo_service_factory.h"
#include "ios/chrome/browser/web_data_service_factory.h"
#include "ios/chrome/common/channel_info.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
-#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "ios/web/public/web_thread.h"
#include "sync/internal_api/public/engine/passive_model_worker.h"
#include "sync/util/extensions_activity.h"
@@ -248,9 +248,8 @@ base::WeakPtr<syncer::SyncableService>
IOSChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
switch (type) {
case syncer::DEVICE_INFO:
- return static_cast<ProfileSyncService*>(
- ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
- browser_state_))
+ return IOSChromeProfileSyncServiceFactory::GetForBrowserState(
+ browser_state_)
->GetDeviceInfoSyncableService()
->AsWeakPtr();
case syncer::PREFERENCES:
@@ -294,9 +293,7 @@ IOSChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
case syncer::FAVICON_IMAGES:
case syncer::FAVICON_TRACKING: {
browser_sync::FaviconCache* favicons =
- static_cast<ProfileSyncService*>(
- ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
- browser_state_))
+ IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state_)
->GetFaviconCache();
return favicons ? favicons->AsWeakPtr()
: base::WeakPtr<syncer::SyncableService>();
@@ -310,9 +307,8 @@ IOSChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
return base::WeakPtr<syncer::SyncableService>();
}
case syncer::SESSIONS: {
- return static_cast<ProfileSyncService*>(
- ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
- browser_state_))
+ return IOSChromeProfileSyncServiceFactory::GetForBrowserState(
+ browser_state_)
->GetSessionsSyncableService()
->AsWeakPtr();
}
diff --git a/ios/chrome/browser/sync/sync_setup_service_factory.cc b/ios/chrome/browser/sync/sync_setup_service_factory.cc
index 89ae6aa..56ce86f 100644
--- a/ios/chrome/browser/sync/sync_setup_service_factory.cc
+++ b/ios/chrome/browser/sync/sync_setup_service_factory.cc
@@ -5,10 +5,11 @@
#include "ios/chrome/browser/sync/sync_setup_service_factory.h"
#include "base/memory/singleton.h"
+#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/sync_setup_service.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
-#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
// static
SyncSetupService* SyncSetupServiceFactory::GetForBrowserState(
@@ -33,7 +34,7 @@ SyncSetupServiceFactory::SyncSetupServiceFactory()
: BrowserStateKeyedServiceFactory(
"SyncSetupService",
BrowserStateDependencyManager::GetInstance()) {
- DependsOn(ios::GetKeyedServiceProvider()->GetSyncServiceFactory());
+ DependsOn(IOSChromeProfileSyncServiceFactory::GetInstance());
}
SyncSetupServiceFactory::~SyncSetupServiceFactory() {
@@ -44,7 +45,6 @@ scoped_ptr<KeyedService> SyncSetupServiceFactory::BuildServiceInstanceFor(
ios::ChromeBrowserState* browser_state =
ios::ChromeBrowserState::FromBrowserState(context);
return make_scoped_ptr(new SyncSetupService(
- ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
- browser_state),
+ IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state),
browser_state->GetPrefs()));
}
diff --git a/ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc b/ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
index 354f7d8..7bc997a 100644
--- a/ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
+++ b/ios/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
@@ -7,13 +7,14 @@
#include <vector>
#include "base/logging.h"
+#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/about_sync_util.h"
#include "components/sync_driver/sync_service.h"
#include "ios/chrome/browser/signin/signin_manager_factory.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/common/channel_info.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
-#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "ios/public/provider/web/web_ui_ios.h"
#include "ios/web/public/web_thread.h"
#include "sync/internal_api/public/events/protocol_event.h"
@@ -231,6 +232,6 @@ void SyncInternalsMessageHandler::SendAboutInfo() {
sync_driver::SyncService* SyncInternalsMessageHandler::GetSyncService() {
ios::ChromeBrowserState* browser_state =
ios::ChromeBrowserState::FromWebUIIOS(web_ui());
- return ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
+ return IOSChromeProfileSyncServiceFactory::GetForBrowserState(
browser_state->GetOriginalChromeBrowserState());
}
diff --git a/ios/public/provider/chrome/browser/keyed_service_provider.cc b/ios/public/provider/chrome/browser/keyed_service_provider.cc
index 0048210..f112f4e 100644
--- a/ios/public/provider/chrome/browser/keyed_service_provider.cc
+++ b/ios/public/provider/chrome/browser/keyed_service_provider.cc
@@ -29,7 +29,6 @@ KeyedServiceProvider::~KeyedServiceProvider() {
}
void KeyedServiceProvider::AssertKeyedFactoriesBuilt() {
- GetSyncServiceFactory();
}
} // namespace ios
diff --git a/ios/public/provider/chrome/browser/keyed_service_provider.h b/ios/public/provider/chrome/browser/keyed_service_provider.h
index 13bd7f3..141bf15 100644
--- a/ios/public/provider/chrome/browser/keyed_service_provider.h
+++ b/ios/public/provider/chrome/browser/keyed_service_provider.h
@@ -10,10 +10,6 @@
class KeyedServiceBaseFactory;
enum class ServiceAccessType;
-namespace sync_driver {
-class SyncService;
-}
-
namespace ios {
class ChromeBrowserState;
@@ -35,18 +31,6 @@ class KeyedServiceProvider {
// correct.
void AssertKeyedFactoriesBuilt();
- // Returns the sync_driver::SyncService factory for dependencies.
- virtual KeyedServiceBaseFactory* GetSyncServiceFactory() = 0;
-
- // Returns an instance of sync_driver::SyncService tied to |browser_state|.
- virtual sync_driver::SyncService* GetSyncServiceForBrowserState(
- ChromeBrowserState* browser_state) = 0;
-
- // Returns an instance of sync_driver::SyncService tied to |browser_state| if
- // there is one created already.
- virtual sync_driver::SyncService* GetSyncServiceForBrowserStateIfExists(
- ChromeBrowserState* browser_state) = 0;
-
private:
DISALLOW_COPY_AND_ASSIGN(KeyedServiceProvider);
};
diff --git a/ios/public/test/test_keyed_service_provider.cc b/ios/public/test/test_keyed_service_provider.cc
index 030eff8c..2d70204 100644
--- a/ios/public/test/test_keyed_service_provider.cc
+++ b/ios/public/test/test_keyed_service_provider.cc
@@ -66,20 +66,4 @@ TestKeyedServiceProvider::TestKeyedServiceProvider() {
TestKeyedServiceProvider::~TestKeyedServiceProvider() {
}
-KeyedServiceBaseFactory* TestKeyedServiceProvider::GetSyncServiceFactory() {
- return FakeSyncServiceFactory::GetInstance();
-}
-
-sync_driver::SyncService*
-TestKeyedServiceProvider::GetSyncServiceForBrowserState(
- ChromeBrowserState* browser_state) {
- return FakeSyncServiceFactory::GetForBrowserState(browser_state);
-}
-
-sync_driver::SyncService*
-TestKeyedServiceProvider::GetSyncServiceForBrowserStateIfExists(
- ChromeBrowserState* browser_state) {
- return FakeSyncServiceFactory::GetForBrowserStateIfExists(browser_state);
-}
-
} // namespace ios
diff --git a/ios/public/test/test_keyed_service_provider.h b/ios/public/test/test_keyed_service_provider.h
index 9a34fd1..69859b1 100644
--- a/ios/public/test/test_keyed_service_provider.h
+++ b/ios/public/test/test_keyed_service_provider.h
@@ -15,13 +15,6 @@ class TestKeyedServiceProvider : public KeyedServiceProvider {
TestKeyedServiceProvider();
~TestKeyedServiceProvider() override;
- // KeyedServiceProvider implementation:
- KeyedServiceBaseFactory* GetSyncServiceFactory() override;
- sync_driver::SyncService* GetSyncServiceForBrowserState(
- ChromeBrowserState* browser_state) override;
- sync_driver::SyncService* GetSyncServiceForBrowserStateIfExists(
- ChromeBrowserState* browser_state) override;
-
private:
DISALLOW_COPY_AND_ASSIGN(TestKeyedServiceProvider);
};