summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/api/sync/DEPS3
-rw-r--r--chrome/browser/api/sync/OWNERS8
-rw-r--r--chrome/browser/api/sync/profile_sync_service_base.h47
-rw-r--r--chrome/browser/api/sync/profile_sync_service_observer.h (renamed from chrome/browser/sync/profile_sync_service_observer.h)6
-rw-r--r--chrome/browser/autofill/DEPS14
-rw-r--r--chrome/browser/autofill/autofill_external_delegate_unittest.cc14
-rw-r--r--chrome/browser/autofill/autofill_manager.cc31
-rw-r--r--chrome/browser/autofill/autofill_manager.h2
-rw-r--r--chrome/browser/autofill/autofill_manager_delegate.h13
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc13
-rw-r--r--chrome/browser/autofill/autofill_metrics_unittest.cc14
-rw-r--r--chrome/browser/autofill/personal_data_manager.cc23
-rw-r--r--chrome/browser/autofill/personal_data_manager.h6
-rw-r--r--chrome/browser/chromeos/login/user_manager_impl.h2
-rw-r--r--chrome/browser/extensions/app_notify_channel_ui_impl.h2
-rw-r--r--chrome/browser/signin/signin_tracker.h2
-rw-r--r--chrome/browser/sync/profile_sync_service.h38
-rw-r--r--chrome/browser/sync/profile_sync_service_factory.cc7
-rw-r--r--chrome/browser/sync/profile_sync_service_harness.h2
-rw-r--r--chrome/browser/sync/profile_sync_test_util.h2
-rw-r--r--chrome/browser/sync/sync_global_error.cc2
-rw-r--r--chrome/browser/sync/sync_global_error.h2
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.h2
-rw-r--r--chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc10
-rw-r--r--chrome/browser/ui/autofill/tab_autofill_manager_delegate.h2
-rw-r--r--chrome/browser/ui/browser_command_controller.h2
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.h2
27 files changed, 167 insertions, 104 deletions
diff --git a/chrome/browser/api/sync/DEPS b/chrome/browser/api/sync/DEPS
new file mode 100644
index 0000000..cc48df1
--- /dev/null
+++ b/chrome/browser/api/sync/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+sync/internal_api/public",
+]
diff --git a/chrome/browser/api/sync/OWNERS b/chrome/browser/api/sync/OWNERS
new file mode 100644
index 0000000..033e1f6
--- /dev/null
+++ b/chrome/browser/api/sync/OWNERS
@@ -0,0 +1,8 @@
+akalin@chromium.org
+atwilson@chromium.org
+lipalani@chromium.org
+nick@chromium.org
+rlarocque@chromium.org
+rsimha@chromium.org
+tim@chromium.org
+zea@chromium.org
diff --git a/chrome/browser/api/sync/profile_sync_service_base.h b/chrome/browser/api/sync/profile_sync_service_base.h
new file mode 100644
index 0000000..60fd40d
--- /dev/null
+++ b/chrome/browser/api/sync/profile_sync_service_base.h
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_API_SYNC_PROFILE_SYNC_SERVICE_BASE_H_
+#define CHROME_BROWSER_API_SYNC_PROFILE_SYNC_SERVICE_BASE_H_
+
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
+#include "sync/internal_api/public/base/model_type.h"
+
+namespace content {
+class BrowserContext;
+}
+
+// API for ProfileSyncService.
+class ProfileSyncServiceBase {
+ public:
+ // Retrieve the sync service to use in the given context.
+ // Returns NULL if sync is not enabled for the context.
+ static ProfileSyncServiceBase* ForContext(content::BrowserContext* context);
+
+ typedef ProfileSyncServiceObserver Observer;
+
+ virtual ~ProfileSyncServiceBase() {}
+
+ // Whether sync is enabled by user or not.
+ virtual bool HasSyncSetupCompleted() const = 0;
+
+ // Returns whether processing changes is allowed. Check this before doing
+ // any model-modifying operations.
+ virtual bool ShouldPushChanges() = 0;
+
+ // Get the set of currently enabled data types (as chosen or
+ // configured by the user). See class comment on ProfileSyncService
+ // for more on what it means for a datatype to be Preferred.
+ virtual syncer::ModelTypeSet GetPreferredDataTypes() const = 0;
+
+ // Adds/removes an observer. ProfileSyncServiceBase does not take
+ // ownership of the observer.
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
+
+ // Returns true if |observer| has already been added as an observer.
+ virtual bool HasObserver(Observer* observer) const = 0;
+};
+
+#endif // CHROME_BROWSER_API_SYNC_PROFILE_SYNC_SERVICE_BASE_H_
diff --git a/chrome/browser/sync/profile_sync_service_observer.h b/chrome/browser/api/sync/profile_sync_service_observer.h
index de8c997..8e1d4f9 100644
--- a/chrome/browser/sync/profile_sync_service_observer.h
+++ b/chrome/browser/api/sync/profile_sync_service_observer.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_OBSERVER_H_
-#define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_OBSERVER_H_
+#ifndef CHROME_BROWSER_API_SYNC_PROFILE_SYNC_SERVICE_OBSERVER_H_
+#define CHROME_BROWSER_API_SYNC_PROFILE_SYNC_SERVICE_OBSERVER_H_
// Various UI components such as the New Tab page can be driven by observing
// the ProfileSyncService through this interface.
@@ -20,4 +20,4 @@ class ProfileSyncServiceObserver {
virtual ~ProfileSyncServiceObserver() { }
};
-#endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_OBSERVER_H_
+#endif // CHROME_BROWSER_API_SYNC_PROFILE_SYNC_SERVICE_OBSERVER_H_
diff --git a/chrome/browser/autofill/DEPS b/chrome/browser/autofill/DEPS
index 98ff28a..f0c5287 100644
--- a/chrome/browser/autofill/DEPS
+++ b/chrome/browser/autofill/DEPS
@@ -15,9 +15,6 @@ include_rules = [
# Do not add to the list of temporarily-allowed dependencies below,
# and please do not introduce more #includes of these files.
- # Can go once ProfileSyncService is converted.
- "!chrome/browser/profiles/profile.h",
-
# Moving to api
"!chrome/browser/profiles/profile_keyed_service.h",
@@ -25,11 +22,6 @@ include_rules = [
"!chrome/browser/profiles/profile_dependency_manager.h",
"!chrome/browser/profiles/profile_keyed_service_factory.h",
- # Needs abstract base.
- "!chrome/browser/sync/profile_sync_service.h",
- "!chrome/browser/sync/profile_sync_service_factory.h",
- "!chrome/browser/sync/profile_sync_service_observer.h",
-
"!chrome/browser/ui/tab_contents/tab_contents.h",
# Do not add to the list of temporarily-allowed dependencies above,
@@ -46,6 +38,9 @@ specific_include_rules = {
# and please do not introduce more #includes of these files.
'.*_[a-z]*test\.cc': [
"!chrome/browser/password_manager/encryptor.h",
+ "!chrome/browser/profiles/profile.h",
+ "!chrome/browser/sync/profile_sync_service.h",
+ "!chrome/browser/sync/profile_sync_service_factory.h",
"!chrome/browser/translate/translate_infobar_delegate.h",
"!chrome/browser/translate/translate_manager.h",
"!chrome/browser/webdata/autofill_web_data_service_impl.h",
@@ -59,9 +54,10 @@ specific_include_rules = {
"!chrome/browser/ui/tab_contents/test_tab_contents.h",
],
- # TODO(joi): Get rid of the need for this, e.g. by moving
+ # TODO(joi): Get rid of the need for this by moving
# PersonalDataManagerFactory to chrome/browser/configuration.
'personal_data_manager_factory\.cc': [
+ "!chrome/browser/profiles/profile.h",
"!chrome/browser/webdata/web_data_service_factory.h",
],
}
diff --git a/chrome/browser/autofill/autofill_external_delegate_unittest.cc b/chrome/browser/autofill/autofill_external_delegate_unittest.cc
index 86ae8ee..58451f7 100644
--- a/chrome/browser/autofill/autofill_external_delegate_unittest.cc
+++ b/chrome/browser/autofill/autofill_external_delegate_unittest.cc
@@ -63,11 +63,11 @@ class MockAutofillExternalDelegate : public TestAutofillExternalDelegate {
class MockAutofillManager : public AutofillManager {
public:
- explicit MockAutofillManager(TabContents* tab_contents)
+ explicit MockAutofillManager(autofill::AutofillManagerDelegate* delegate,
+ TabContents* tab_contents)
// Force to use the constructor designated for unit test, but we don't
// really need personal_data in this test so we pass a NULL pointer.
- : AutofillManager(&delegate_, tab_contents, NULL),
- delegate_(tab_contents) {
+ : AutofillManager(delegate, tab_contents, NULL) {
}
MOCK_METHOD4(OnFillAutofillFormData,
@@ -78,9 +78,6 @@ class MockAutofillManager : public AutofillManager {
protected:
virtual ~MockAutofillManager() {}
-
- private:
- TabAutofillManagerDelegate delegate_;
};
} // namespace
@@ -93,7 +90,9 @@ class AutofillExternalDelegateUnitTest : public TabContentsTestHarness {
virtual void SetUp() OVERRIDE {
TabContentsTestHarness::SetUp();
- autofill_manager_ = new MockAutofillManager(tab_contents());
+ manager_delegate_.reset(new TabAutofillManagerDelegate(tab_contents()));
+ autofill_manager_ = new MockAutofillManager(manager_delegate_.get(),
+ tab_contents());
external_delegate_.reset(new MockAutofillExternalDelegate(
tab_contents(),
autofill_manager_));
@@ -116,6 +115,7 @@ class AutofillExternalDelegateUnitTest : public TabContentsTestHarness {
external_delegate_->OnQuery(query_id, form, field, bounds, false);
}
+ scoped_ptr<TabAutofillManagerDelegate> manager_delegate_;
scoped_refptr<MockAutofillManager> autofill_manager_;
scoped_ptr<MockAutofillExternalDelegate> external_delegate_;
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 19afdf2..ba46c7b 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -20,6 +20,8 @@
#include "base/threading/sequenced_worker_pool.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/api/infobars/infobar_service.h"
+#include "chrome/browser/api/prefs/pref_service_base.h"
+#include "chrome/browser/api/sync/profile_sync_service_base.h"
#include "chrome/browser/autofill/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
@@ -36,10 +38,6 @@
#include "chrome/browser/autofill/phone_number.h"
#include "chrome/browser/autofill/phone_number_i18n.h"
#include "chrome/browser/autofill/select_control_handler.h"
-#include "chrome/browser/api/prefs/pref_service_base.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/autofill_messages.h"
#include "chrome/common/chrome_notification_types.h"
@@ -193,7 +191,7 @@ AutofillManager::AutofillManager(autofill::AutofillManagerDelegate* delegate,
external_delegate_(NULL) {
// |personal_data_| is NULL when using test-enabled WebContents.
personal_data_ = PersonalDataManagerFactory::GetForProfile(
- tab_contents_->profile()->GetOriginalProfile());
+ delegate->GetOriginalProfile());
RegisterWithSyncService();
registrar_.Init(manager_delegate_->GetPrefs());
registrar_.Add(prefs::kPasswordGenerationEnabled, this);
@@ -231,10 +229,9 @@ void AutofillManager::RegisterUserPrefs(PrefServiceBase* prefs) {
}
void AutofillManager::RegisterWithSyncService() {
- ProfileSyncService* temp_sync_service =
- ProfileSyncServiceFactory::GetForProfile(tab_contents_->profile());
- if (temp_sync_service)
- temp_sync_service->AddObserver(this);
+ ProfileSyncServiceBase* service = manager_delegate_->GetProfileSyncService();
+ if (service)
+ service->AddObserver(this);
}
void AutofillManager::SendPasswordGenerationStateToRenderer(
@@ -250,8 +247,7 @@ void AutofillManager::SendPasswordGenerationStateToRenderer(
void AutofillManager::UpdatePasswordGenerationState(
content::RenderViewHost* host,
bool new_renderer) {
- ProfileSyncService* service = ProfileSyncServiceFactory::GetForProfile(
- tab_contents_->profile());
+ ProfileSyncServiceBase* service = manager_delegate_->GetProfileSyncService();
bool password_sync_enabled = false;
if (service) {
@@ -290,13 +286,10 @@ void AutofillManager::Observe(
DCHECK(prefs::kPasswordGenerationEnabled == *pref);
UpdatePasswordGenerationState(web_contents()->GetRenderViewHost(), false);
} else if (type == chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED) {
- if (ProfileSyncServiceFactory::HasProfileSyncService(
- tab_contents_->profile())) {
- ProfileSyncService* service = ProfileSyncServiceFactory::GetForProfile(
- tab_contents_->profile());
- if (service->HasObserver(this))
- service->RemoveObserver(this);
- }
+ ProfileSyncServiceBase* service =
+ manager_delegate_->GetProfileSyncService();
+ if (service != NULL && service->HasObserver(this))
+ service->RemoveObserver(this);
} else {
NOTREACHED();
}
@@ -896,7 +889,7 @@ AutofillManager::AutofillManager(autofill::AutofillManagerDelegate* delegate,
manager_delegate_(delegate),
tab_contents_(tab_contents),
personal_data_(personal_data),
- download_manager_(tab_contents->profile(), this),
+ download_manager_(delegate->GetBrowserContext(), this),
disable_download_manager_requests_(true),
metric_logger_(new AutofillMetrics),
has_logged_autofill_enabled_(false),
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index eb46bf9..57af9b3 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -20,10 +20,10 @@
#include "base/string16.h"
#include "base/time.h"
#include "chrome/browser/api/prefs/pref_change_registrar.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/autofill/autofill_download.h"
#include "chrome/browser/autofill/field_types.h"
#include "chrome/browser/autofill/form_structure.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
diff --git a/chrome/browser/autofill/autofill_manager_delegate.h b/chrome/browser/autofill/autofill_manager_delegate.h
index 915354b..dda8bfe 100644
--- a/chrome/browser/autofill/autofill_manager_delegate.h
+++ b/chrome/browser/autofill/autofill_manager_delegate.h
@@ -25,6 +25,8 @@ struct PasswordForm;
class InfoBarService;
class PrefServiceBase;
+class Profile;
+class ProfileSyncServiceBase;
namespace autofill {
@@ -40,19 +42,26 @@ class AutofillManagerDelegate {
public:
virtual ~AutofillManagerDelegate() {}
- // Gets the BrowserContext the AutofillManager is in.
+ // Gets the BrowserContext associated with the delegate.
virtual content::BrowserContext* GetBrowserContext() const = 0;
- // Gets the BrowserContext the AutofillManager is in, or if in an
+ // Gets the BrowserContext associated with the delegate, or if in an
// incognito mode, the associated (original) BrowserContext.
virtual content::BrowserContext* GetOriginalBrowserContext() const = 0;
+ // TODO(joi): Remove, this is temporary.
+ virtual Profile* GetOriginalProfile() const = 0;
+
// Gets the infobar service associated with the delegate.
virtual InfoBarService* GetInfoBarService() = 0;
// Gets the preferences associated with the delegate.
virtual PrefServiceBase* GetPrefs() = 0;
+ // Gets the profile sync service associated with the delegate. Will
+ // be NULL if sync is not enabled.
+ virtual ProfileSyncServiceBase* GetProfileSyncService() = 0;
+
// Returns true if saving passwords is currently enabled for the
// delegate.
virtual bool IsSavingPasswordsEnabled() const = 0;
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 1f1347f..01301d5 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -441,10 +441,10 @@ void ExpectFilledCreditCardYearMonthWithYearMonth(int page_id,
class TestAutofillManager : public AutofillManager {
public:
- TestAutofillManager(TabContents* tab_contents,
+ TestAutofillManager(autofill::AutofillManagerDelegate* delegate,
+ TabContents* tab_contents,
TestPersonalDataManager* personal_data)
- : AutofillManager(&delegate_, tab_contents, personal_data),
- delegate_(tab_contents),
+ : AutofillManager(delegate, tab_contents, personal_data),
personal_data_(personal_data),
autofill_enabled_(true),
did_finish_async_form_submit_(false),
@@ -565,8 +565,6 @@ class TestAutofillManager : public AutofillManager {
// AutofillManager is ref counted.
virtual ~TestAutofillManager() {}
- TabAutofillManagerDelegate delegate_;
-
// Weak reference.
TestPersonalDataManager* personal_data_;
@@ -607,7 +605,9 @@ class AutofillManagerTest : public TabContentsTestHarness {
profile, TestPersonalDataManager::Build);
TabContentsTestHarness::SetUp();
- autofill_manager_ = new TestAutofillManager(tab_contents(),
+ manager_delegate_.reset(new TabAutofillManagerDelegate(tab_contents()));
+ autofill_manager_ = new TestAutofillManager(manager_delegate_.get(),
+ tab_contents(),
&personal_data_);
file_thread_.Start();
@@ -712,6 +712,7 @@ class AutofillManagerTest : public TabContentsTestHarness {
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
+ scoped_ptr<TabAutofillManagerDelegate> manager_delegate_;
scoped_refptr<TestAutofillManager> autofill_manager_;
TestPersonalDataManager personal_data_;
diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc
index efcdff4..71256eb 100644
--- a/chrome/browser/autofill/autofill_metrics_unittest.cc
+++ b/chrome/browser/autofill/autofill_metrics_unittest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
#include "chrome/browser/autofill/autofill_common_test.h"
#include "chrome/browser/autofill/autofill_manager.h"
+#include "chrome/browser/autofill/autofill_manager_delegate.h"
#include "chrome/browser/autofill/autofill_metrics.h"
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
@@ -173,10 +174,10 @@ class TestFormStructure : public FormStructure {
class TestAutofillManager : public AutofillManager {
public:
- TestAutofillManager(TabContents* tab_contents,
+ TestAutofillManager(autofill::AutofillManagerDelegate* manager_delegate,
+ TabContents* tab_contents,
TestPersonalDataManager* personal_manager)
- : AutofillManager(&autofill_delegate_, tab_contents, personal_manager),
- autofill_delegate_(tab_contents),
+ : AutofillManager(manager_delegate, tab_contents, personal_manager),
autofill_enabled_(true),
did_finish_async_form_submit_(false),
message_loop_is_running_(false) {
@@ -247,8 +248,6 @@ class TestAutofillManager : public AutofillManager {
// AutofillManager is ref counted.
virtual ~TestAutofillManager() {}
- TabAutofillManagerDelegate autofill_delegate_;
-
bool autofill_enabled_;
bool did_finish_async_form_submit_;
bool message_loop_is_running_;
@@ -274,6 +273,7 @@ class AutofillMetricsTest : public TabContentsTestHarness {
content::TestBrowserThread file_thread_;
scoped_refptr<TestAutofillManager> autofill_manager_;
+ scoped_ptr<TabAutofillManagerDelegate> manager_delegate_;
TestPersonalDataManager personal_data_;
private:
@@ -299,7 +299,9 @@ void AutofillMetricsTest::SetUp() {
profile, NULL);
TabContentsTestHarness::SetUp();
- autofill_manager_ = new TestAutofillManager(tab_contents(),
+ manager_delegate_.reset(new TabAutofillManagerDelegate(tab_contents()));
+ autofill_manager_ = new TestAutofillManager(manager_delegate_.get(),
+ tab_contents(),
&personal_data_);
file_thread_.Start();
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index d15b85f..9be39c1 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -10,6 +10,9 @@
#include "base/logging.h"
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/api/prefs/pref_service_base.h"
+#include "chrome/browser/api/sync/profile_sync_service_base.h"
+#include "chrome/browser/api/webdata/autofill_web_data_service.h"
#include "chrome/browser/autofill/autofill-inl.h"
#include "chrome/browser/autofill/autofill_field.h"
#include "chrome/browser/autofill/autofill_metrics.h"
@@ -19,12 +22,9 @@
#include "chrome/browser/autofill/phone_number.h"
#include "chrome/browser/autofill/phone_number_i18n.h"
#include "chrome/browser/autofill/select_control_handler.h"
-#include "chrome/browser/api/prefs/pref_service_base.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_source.h"
@@ -166,9 +166,8 @@ void PersonalDataManager::OnWebDataServiceRequestDone(
// As all Autofill data is ready, the Autocomplete data is ready as well.
// If sync is not set, cull older entries of the autocomplete. Otherwise,
// the entries will be culled when sync is connected.
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- static_cast<Profile*>(browser_context_));
+ ProfileSyncServiceBase* sync_service =
+ ProfileSyncServiceBase::ForContext(browser_context_);
if (sync_service && (!sync_service->HasSyncSetupCompleted() ||
!PrefServiceBase::ForContext(
browser_context_)->GetBoolean(
@@ -208,9 +207,8 @@ void PersonalDataManager::OnStateChanged() {
return;
}
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- static_cast<Profile*>(browser_context_));
+ ProfileSyncServiceBase* sync_service =
+ ProfileSyncServiceBase::ForContext(browser_context_);
if (!sync_service)
return;
@@ -924,9 +922,8 @@ void PersonalDataManager::EmptyMigrationTrash() {
return;
}
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- static_cast<Profile*>(browser_context_));
+ ProfileSyncServiceBase* sync_service =
+ ProfileSyncServiceBase::ForContext(browser_context_);
if (!sync_service)
return;
diff --git a/chrome/browser/autofill/personal_data_manager.h b/chrome/browser/autofill/personal_data_manager.h
index 8d26f29..4530262 100644
--- a/chrome/browser/autofill/personal_data_manager.h
+++ b/chrome/browser/autofill/personal_data_manager.h
@@ -13,14 +13,12 @@
#include "base/memory/scoped_vector.h"
#include "base/observer_list.h"
#include "base/string16.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
+#include "chrome/browser/api/webdata/web_data_service_consumer.h"
#include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/autofill/credit_card.h"
#include "chrome/browser/autofill/field_types.h"
-#include "chrome/browser/api/webdata/autofill_web_data_service.h"
-#include "chrome/browser/api/webdata/web_data_service_consumer.h"
-
#include "chrome/browser/profiles/profile_keyed_service.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
diff --git a/chrome/browser/chromeos/login/user_manager_impl.h b/chrome/browser/chromeos/login/user_manager_impl.h
index 3aec437..10cf895 100644
--- a/chrome/browser/chromeos/login/user_manager_impl.h
+++ b/chrome/browser/chromeos/login/user_manager_impl.h
@@ -16,13 +16,13 @@
#include "base/synchronization/lock.h"
#include "base/time.h"
#include "base/timer.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_image_loader.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wallpaper_manager.h"
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#include "chrome/browser/profiles/profile_downloader_delegate.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/gfx/image/image_skia.h"
diff --git a/chrome/browser/extensions/app_notify_channel_ui_impl.h b/chrome/browser/extensions/app_notify_channel_ui_impl.h
index bd4250d..128ebba 100644
--- a/chrome/browser/extensions/app_notify_channel_ui_impl.h
+++ b/chrome/browser/extensions/app_notify_channel_ui_impl.h
@@ -9,8 +9,8 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/extensions/app_notify_channel_ui.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
class Profile;
class TabContents;
diff --git a/chrome/browser/signin/signin_tracker.h b/chrome/browser/signin/signin_tracker.h
index 7948b94..54105ae 100644
--- a/chrome/browser/signin/signin_tracker.h
+++ b/chrome/browser/signin/signin_tracker.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_SIGNIN_SIGNIN_TRACKER_H_
#define CHROME_BROWSER_SIGNIN_SIGNIN_TRACKER_H_
-#include "chrome/browser/sync/profile_sync_service_observer.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_types.h"
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 3aee598..17e9a63 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -18,6 +18,8 @@
#include "base/string16.h"
#include "base/time.h"
#include "base/timer.h"
+#include "chrome/browser/api/sync/profile_sync_service_base.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/browser/sync/backend_unrecoverable_error_handler.h"
#include "chrome/browser/sync/failed_datatypes_handler.h"
@@ -27,7 +29,6 @@
#include "chrome/browser/sync/glue/sync_backend_host.h"
#include "chrome/browser/sync/invalidation_frontend.h"
#include "chrome/browser/sync/invalidations/invalidator_storage.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/sync/sync_prefs.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -149,7 +150,8 @@ class EncryptedData;
// tell the sync engine that setup is completed and it can begin downloading
// data from the sync server.
//
-class ProfileSyncService : public browser_sync::SyncFrontend,
+class ProfileSyncService : public ProfileSyncServiceBase,
+ public browser_sync::SyncFrontend,
public browser_sync::SyncPrefObserver,
public browser_sync::DataTypeManagerObserver,
public syncer::UnrecoverableErrorHandler,
@@ -157,7 +159,6 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
public ProfileKeyedService,
public InvalidationFrontend {
public:
- typedef ProfileSyncServiceObserver Observer;
typedef browser_sync::SyncBackendHost::Status Status;
enum SyncEventCodes {
@@ -221,6 +222,16 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// class is constructed.
void Initialize();
+ virtual void SetSyncSetupCompleted();
+
+ // ProfileSyncServiceBase implementation.
+ virtual bool HasSyncSetupCompleted() const OVERRIDE;
+ virtual bool ShouldPushChanges() OVERRIDE;
+ virtual syncer::ModelTypeSet GetPreferredDataTypes() const OVERRIDE;
+ virtual void AddObserver(Observer* observer) OVERRIDE;
+ virtual void RemoveObserver(Observer* observer) OVERRIDE;
+ virtual bool HasObserver(Observer* observer) const OVERRIDE;
+
void RegisterAuthNotifications();
// Returns true if sync is enabled/not suppressed and the user is logged in.
@@ -254,10 +265,6 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// Disables sync for user. Use ShowLoginDialog to enable.
virtual void DisableForUser();
- // Whether sync is enabled by user or not.
- virtual bool HasSyncSetupCompleted() const;
- virtual void SetSyncSetupCompleted();
-
// syncer::InvalidationHandler implementation (via SyncFrontend).
virtual void OnInvalidatorStateChange(
syncer::InvalidatorState state) OVERRIDE;
@@ -370,14 +377,6 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// The profile we are syncing for.
Profile* profile() const { return profile_; }
- // Adds/removes an observer. ProfileSyncService does not take ownership of
- // the observer.
- virtual void AddObserver(Observer* observer);
- virtual void RemoveObserver(Observer* observer);
-
- // Returns true if |observer| has already been added as an observer.
- bool HasObserver(Observer* observer) const;
-
// Returns a weak pointer to the service's JsController.
// Overrideable for testing purposes.
virtual base::WeakPtr<syncer::JsController> GetJsController();
@@ -468,11 +467,6 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
virtual void ChangePreferredDataTypes(
syncer::ModelTypeSet preferred_types);
- // Get the set of currently enabled data types (as chosen or configured by
- // the user). See class comment for more on what it means for a datatype
- // to be Preferred.
- virtual syncer::ModelTypeSet GetPreferredDataTypes() const;
-
// Gets the set of all data types that could be allowed (the set that
// should be advertised to the user). These will typically only change
// via a command-line option. See class comment for more on what it means
@@ -527,10 +521,6 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// Returns true if the syncer is waiting for new datatypes to be encrypted.
virtual bool encryption_pending() const;
- // Returns whether processing changes is allowed. Check this before doing
- // any model-modifying operations.
- bool ShouldPushChanges();
-
const GURL& sync_service_url() const { return sync_service_url_; }
bool auto_start_enabled() const { return auto_start_enabled_; }
SigninManager* signin() const { return signin_; }
diff --git a/chrome/browser/sync/profile_sync_service_factory.cc b/chrome/browser/sync/profile_sync_service_factory.cc
index 5bddce8..636cf06 100644
--- a/chrome/browser/sync/profile_sync_service_factory.cc
+++ b/chrome/browser/sync/profile_sync_service_factory.cc
@@ -41,6 +41,13 @@ ProfileSyncService* ProfileSyncServiceFactory::GetForProfile(
GetInstance()->GetServiceForProfile(profile, true));
}
+// static
+ProfileSyncServiceBase* ProfileSyncServiceBase::ForContext(
+ content::BrowserContext* context) {
+ return ProfileSyncServiceFactory::GetForProfile(
+ static_cast<Profile*>(context));
+}
+
ProfileSyncServiceFactory::ProfileSyncServiceFactory()
: ProfileKeyedServiceFactory("ProfileSyncService",
ProfileDependencyManager::GetInstance()) {
diff --git a/chrome/browser/sync/profile_sync_service_harness.h b/chrome/browser/sync/profile_sync_service_harness.h
index 529ee2b..380abb6 100644
--- a/chrome/browser/sync/profile_sync_service_harness.h
+++ b/chrome/browser/sync/profile_sync_service_harness.h
@@ -10,9 +10,9 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/sync/backend_migrator.h"
#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/sync/retry_verifier.h"
#include "sync/internal_api/public/base/model_type.h"
diff --git a/chrome/browser/sync/profile_sync_test_util.h b/chrome/browser/sync/profile_sync_test_util.h
index 509bcf5..a9e2dd5 100644
--- a/chrome/browser/sync/profile_sync_test_util.h
+++ b/chrome/browser/sync/profile_sync_test_util.h
@@ -10,7 +10,7 @@
#include "base/memory/ref_counted.h"
#include "base/message_loop.h"
#include "base/synchronization/waitable_event.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
diff --git a/chrome/browser/sync/sync_global_error.cc b/chrome/browser/sync/sync_global_error.cc
index 7c4f143..1043719 100644
--- a/chrome/browser/sync/sync_global_error.cc
+++ b/chrome/browser/sync/sync_global_error.cc
@@ -5,8 +5,8 @@
#include "chrome/browser/sync/sync_global_error.h"
#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
diff --git a/chrome/browser/sync/sync_global_error.h b/chrome/browser/sync/sync_global_error.h
index b0c2a45..7be44d8 100644
--- a/chrome/browser/sync/sync_global_error.h
+++ b/chrome/browser/sync/sync_global_error.h
@@ -7,7 +7,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/ui/global_error/global_error.h"
class ProfileSyncService;
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
index 31908ca..d022c2e 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
@@ -19,8 +19,8 @@
#include "base/memory/scoped_ptr.h"
#include "base/timer.h"
#include "chrome/browser/api/prefs/pref_change_registrar.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/extensions/extension_prefs.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/aura/window_observer.h"
diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc
index 3562ea7..6ee181e 100644
--- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc
+++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc
@@ -10,6 +10,8 @@
#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
@@ -33,6 +35,10 @@ TabAutofillManagerDelegate::GetOriginalBrowserContext() const {
return tab_->profile()->GetOriginalProfile();
}
+Profile* TabAutofillManagerDelegate::GetOriginalProfile() const {
+ return tab_->profile()->GetOriginalProfile();
+}
+
InfoBarService* TabAutofillManagerDelegate::GetInfoBarService() {
return tab_->infobar_tab_helper();
}
@@ -41,6 +47,10 @@ PrefServiceBase* TabAutofillManagerDelegate::GetPrefs() {
return tab_->profile()->GetPrefs();
}
+ProfileSyncServiceBase* TabAutofillManagerDelegate::GetProfileSyncService() {
+ return ProfileSyncServiceFactory::GetForProfile(tab_->profile());
+}
+
bool TabAutofillManagerDelegate::IsSavingPasswordsEnabled() const {
return tab_->password_manager()->IsSavingEnabled();
}
diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h
index d0f385f..1043ea1 100644
--- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h
+++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.h
@@ -19,8 +19,10 @@ class TabAutofillManagerDelegate : public autofill::AutofillManagerDelegate {
virtual content::BrowserContext* GetBrowserContext() const OVERRIDE;
virtual content::BrowserContext* GetOriginalBrowserContext() const OVERRIDE;
+ virtual Profile* GetOriginalProfile() const OVERRIDE;
virtual InfoBarService* GetInfoBarService() OVERRIDE;
virtual PrefServiceBase* GetPrefs() OVERRIDE;
+ virtual ProfileSyncServiceBase* GetProfileSyncService() OVERRIDE;
virtual bool IsSavingPasswordsEnabled() const OVERRIDE;
virtual void ShowAutofillSettings() OVERRIDE;
virtual void ShowPasswordGenerationBubble(
diff --git a/chrome/browser/ui/browser_command_controller.h b/chrome/browser/ui/browser_command_controller.h
index 00400a3..5ec5e0b 100644
--- a/chrome/browser/ui/browser_command_controller.h
+++ b/chrome/browser/ui/browser_command_controller.h
@@ -6,9 +6,9 @@
#define CHROME_BROWSER_UI_BROWSER_COMMAND_CONTROLLER_H_
#include "chrome/browser/api/prefs/pref_change_registrar.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/sessions/tab_restore_service_observer.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.h b/chrome/browser/ui/webui/options/browser_options_handler.h
index c8ded33..44c6e5f 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.h
+++ b/chrome/browser/ui/webui/options/browser_options_handler.h
@@ -9,11 +9,11 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/api/prefs/pref_member.h"
+#include "chrome/browser/api/sync/profile_sync_service_observer.h"
#include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_observer.h"
#include "chrome/browser/shell_integration.h"
-#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/ui/webui/options/options_ui.h"
#include "ui/base/dialogs/select_file_dialog.h"
#include "ui/base/models/table_model_observer.h"