summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r--chrome/browser/sync/glue/app_data_type_controller.cc110
-rw-r--r--chrome/browser/sync/glue/app_data_type_controller.h85
-rw-r--r--chrome/browser/sync/glue/extension_change_processor.cc3
-rw-r--r--chrome/browser/sync/glue/extension_change_processor.h3
-rw-r--r--chrome/browser/sync/glue/extension_data_type_controller.cc5
-rw-r--r--chrome/browser/sync/glue/extension_model_associator.cc12
-rw-r--r--chrome/browser/sync/glue/extension_model_associator.h5
-rw-r--r--chrome/browser/sync/glue/extension_sync_traits.cc41
-rw-r--r--chrome/browser/sync/glue/extension_sync_traits.h3
-rw-r--r--chrome/browser/sync/profile_sync_factory.h7
-rw-r--r--chrome/browser/sync/profile_sync_factory_impl.cc31
-rw-r--r--chrome/browser/sync/profile_sync_factory_impl.h4
-rw-r--r--chrome/browser/sync/profile_sync_factory_mock.h3
-rw-r--r--chrome/browser/sync/profile_sync_service.cc3
-rw-r--r--chrome/browser/sync/resources/choose_datatypes.html16
-rw-r--r--chrome/browser/sync/sync_setup_flow.cc10
-rw-r--r--chrome/browser/sync/sync_setup_wizard.cc2
-rw-r--r--chrome/browser/sync/sync_setup_wizard_unittest.cc7
18 files changed, 330 insertions, 20 deletions
diff --git a/chrome/browser/sync/glue/app_data_type_controller.cc b/chrome/browser/sync/glue/app_data_type_controller.cc
new file mode 100644
index 0000000..120c1e4
--- /dev/null
+++ b/chrome/browser/sync/glue/app_data_type_controller.cc
@@ -0,0 +1,110 @@
+// Copyright (c) 2010 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.
+
+#include "chrome/browser/sync/glue/app_data_type_controller.h"
+
+#include "base/histogram.h"
+#include "base/logging.h"
+#include "base/time.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/profile_sync_factory.h"
+#include "chrome/browser/sync/unrecoverable_error_handler.h"
+
+namespace browser_sync {
+
+AppDataTypeController::AppDataTypeController(
+ ProfileSyncFactory* profile_sync_factory,
+ Profile* profile,
+ ProfileSyncService* sync_service)
+ : profile_sync_factory_(profile_sync_factory),
+ profile_(profile),
+ sync_service_(sync_service),
+ state_(NOT_RUNNING) {
+ DCHECK(profile_sync_factory);
+ DCHECK(sync_service);
+}
+
+AppDataTypeController::~AppDataTypeController() {
+}
+
+void AppDataTypeController::Start(StartCallback* start_callback) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ DCHECK(start_callback);
+ if (state_ != NOT_RUNNING) {
+ start_callback->Run(BUSY);
+ delete start_callback;
+ return;
+ }
+
+ start_callback_.reset(start_callback);
+
+ profile_->InitExtensions();
+ ProfileSyncFactory::SyncComponents sync_components =
+ profile_sync_factory_->CreateAppSyncComponents(sync_service_,
+ this);
+ model_associator_.reset(sync_components.model_associator);
+ change_processor_.reset(sync_components.change_processor);
+
+ bool sync_has_nodes = false;
+ if (!model_associator_->SyncModelHasUserCreatedNodes(&sync_has_nodes)) {
+ StartFailed(UNRECOVERABLE_ERROR);
+ return;
+ }
+
+ base::TimeTicks start_time = base::TimeTicks::Now();
+ bool merge_success = model_associator_->AssociateModels();
+ UMA_HISTOGRAM_TIMES("Sync.AppAssociationTime",
+ base::TimeTicks::Now() - start_time);
+ if (!merge_success) {
+ StartFailed(ASSOCIATION_FAILED);
+ return;
+ }
+
+ sync_service_->ActivateDataType(this, change_processor_.get());
+ state_ = RUNNING;
+ FinishStart(!sync_has_nodes ? OK_FIRST_RUN : OK);
+}
+
+void AppDataTypeController::Stop() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+
+ if (change_processor_ != NULL)
+ sync_service_->DeactivateDataType(this, change_processor_.get());
+
+ if (model_associator_ != NULL)
+ model_associator_->DisassociateModels();
+
+ change_processor_.reset();
+ model_associator_.reset();
+ start_callback_.reset();
+
+ state_ = NOT_RUNNING;
+}
+
+void AppDataTypeController::OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ UMA_HISTOGRAM_COUNTS("Sync.AppRunFailures", 1);
+ sync_service_->OnUnrecoverableError(from_here, message);
+}
+
+void AppDataTypeController::FinishStart(StartResult result) {
+ start_callback_->Run(result);
+ start_callback_.reset();
+}
+
+void AppDataTypeController::StartFailed(StartResult result) {
+ model_associator_.reset();
+ change_processor_.reset();
+ start_callback_->Run(result);
+ start_callback_.reset();
+ UMA_HISTOGRAM_ENUMERATION("Sync.AppStartFailures",
+ result,
+ MAX_START_RESULT);
+}
+
+} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/app_data_type_controller.h b/chrome/browser/sync/glue/app_data_type_controller.h
new file mode 100644
index 0000000..e8797f4
--- /dev/null
+++ b/chrome/browser/sync/glue/app_data_type_controller.h
@@ -0,0 +1,85 @@
+// Copyright (c) 2010 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_SYNC_GLUE_APP_DATA_TYPE_CONTROLLER_H_
+#define CHROME_BROWSER_SYNC_GLUE_APP_DATA_TYPE_CONTROLLER_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/scoped_ptr.h"
+#include "chrome/browser/sync/glue/data_type_controller.h"
+
+class Profile;
+class ProfileSyncFactory;
+class ProfileSyncService;
+
+namespace browser_sync {
+
+class AssociatorInterface;
+class ChangeProcessor;
+
+class AppDataTypeController : public DataTypeController {
+ public:
+ AppDataTypeController(
+ ProfileSyncFactory* profile_sync_factory,
+ Profile* profile,
+ ProfileSyncService* sync_service);
+ virtual ~AppDataTypeController();
+
+ // DataTypeController implementation.
+ virtual void Start(StartCallback* start_callback);
+
+ virtual void Stop();
+
+ virtual bool enabled() {
+ return true;
+ }
+
+ virtual syncable::ModelType type() {
+ return syncable::APPS;
+ }
+
+ virtual browser_sync::ModelSafeGroup model_safe_group() {
+ return browser_sync::GROUP_UI;
+ }
+
+ virtual const char* name() const {
+ // For logging only.
+ return "app";
+ }
+
+ virtual State state() {
+ return state_;
+ }
+
+ // UnrecoverableErrorHandler interface.
+ virtual void OnUnrecoverableError(
+ const tracked_objects::Location& from_here,
+ const std::string& message);
+
+ private:
+ // Helper method to run the stashed start callback with a given result.
+ void FinishStart(StartResult result);
+
+ // Cleans up state and calls callback when start fails.
+ void StartFailed(StartResult result);
+
+ ProfileSyncFactory* profile_sync_factory_;
+ Profile* profile_;
+ ProfileSyncService* sync_service_;
+
+ State state_;
+
+ scoped_ptr<StartCallback> start_callback_;
+ scoped_ptr<AssociatorInterface> model_associator_;
+ scoped_ptr<ChangeProcessor> change_processor_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppDataTypeController);
+};
+
+} // namespace browser_sync
+
+#endif // CHROME_BROWSER_SYNC_GLUE_APP_DATA_TYPE_CONTROLLER_H_
diff --git a/chrome/browser/sync/glue/extension_change_processor.cc b/chrome/browser/sync/glue/extension_change_processor.cc
index 808bd27..589ebb2 100644
--- a/chrome/browser/sync/glue/extension_change_processor.cc
+++ b/chrome/browser/sync/glue/extension_change_processor.cc
@@ -21,9 +21,10 @@
namespace browser_sync {
ExtensionChangeProcessor::ExtensionChangeProcessor(
+ const ExtensionSyncTraits& traits,
UnrecoverableErrorHandler* error_handler)
: ChangeProcessor(error_handler),
- traits_(GetExtensionSyncTraits()),
+ traits_(traits),
profile_(NULL) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(error_handler);
diff --git a/chrome/browser/sync/glue/extension_change_processor.h b/chrome/browser/sync/glue/extension_change_processor.h
index b118904..89428fb 100644
--- a/chrome/browser/sync/glue/extension_change_processor.h
+++ b/chrome/browser/sync/glue/extension_change_processor.h
@@ -31,7 +31,8 @@ class ExtensionChangeProcessor : public ChangeProcessor,
public NotificationObserver {
public:
// Does not take ownership of |error_handler|.
- explicit ExtensionChangeProcessor(
+ ExtensionChangeProcessor(
+ const ExtensionSyncTraits& traits,
UnrecoverableErrorHandler* error_handler);
virtual ~ExtensionChangeProcessor();
diff --git a/chrome/browser/sync/glue/extension_data_type_controller.cc b/chrome/browser/sync/glue/extension_data_type_controller.cc
index c71ce3c..e0c92f3 100644
--- a/chrome/browser/sync/glue/extension_data_type_controller.cc
+++ b/chrome/browser/sync/glue/extension_data_type_controller.cc
@@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/sync/glue/extension_data_type_controller.h"
+
#include "base/histogram.h"
#include "base/logging.h"
#include "base/time.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/profile.h"
-#include "chrome/browser/sync/glue/extension_change_processor.h"
-#include "chrome/browser/sync/glue/extension_data_type_controller.h"
-#include "chrome/browser/sync/glue/extension_model_associator.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_factory.h"
#include "chrome/browser/sync/unrecoverable_error_handler.h"
diff --git a/chrome/browser/sync/glue/extension_model_associator.cc b/chrome/browser/sync/glue/extension_model_associator.cc
index cb2890f..a7b1c196 100644
--- a/chrome/browser/sync/glue/extension_model_associator.cc
+++ b/chrome/browser/sync/glue/extension_model_associator.cc
@@ -14,7 +14,8 @@
namespace browser_sync {
ExtensionModelAssociator::ExtensionModelAssociator(
- ProfileSyncService* sync_service) : sync_service_(sync_service) {
+ const ExtensionSyncTraits& traits, ProfileSyncService* sync_service)
+ : traits_(traits), sync_service_(sync_service) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
DCHECK(sync_service_);
}
@@ -25,13 +26,11 @@ ExtensionModelAssociator::~ExtensionModelAssociator() {
bool ExtensionModelAssociator::AssociateModels() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- const ExtensionSyncTraits traits = GetExtensionSyncTraits();
-
ExtensionDataMap extension_data_map;
- if (!SlurpExtensionData(traits, sync_service_, &extension_data_map)) {
+ if (!SlurpExtensionData(traits_, sync_service_, &extension_data_map)) {
return false;
}
- if (!FlushExtensionData(traits, extension_data_map, sync_service_)) {
+ if (!FlushExtensionData(traits_, extension_data_map, sync_service_)) {
return false;
}
@@ -46,8 +45,7 @@ bool ExtensionModelAssociator::DisassociateModels() {
bool ExtensionModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- const ExtensionSyncTraits traits = GetExtensionSyncTraits();
- return RootNodeHasChildren(traits.root_node_tag, sync_service_, has_nodes);
+ return RootNodeHasChildren(traits_.root_node_tag, sync_service_, has_nodes);
}
} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/extension_model_associator.h b/chrome/browser/sync/glue/extension_model_associator.h
index 134ccb5..0063d2d 100644
--- a/chrome/browser/sync/glue/extension_model_associator.h
+++ b/chrome/browser/sync/glue/extension_model_associator.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/basictypes.h"
+#include "chrome/browser/sync/glue/extension_sync_traits.h"
#include "chrome/browser/sync/glue/model_associator.h"
#include "chrome/browser/sync/syncable/model_type.h"
@@ -19,7 +20,8 @@ namespace browser_sync {
class ExtensionModelAssociator : public AssociatorInterface {
public:
// Does not take ownership of sync_service.
- explicit ExtensionModelAssociator(ProfileSyncService* sync_service);
+ ExtensionModelAssociator(const ExtensionSyncTraits& traits,
+ ProfileSyncService* sync_service);
virtual ~ExtensionModelAssociator();
// Used by profile_sync_test_util.h.
@@ -35,6 +37,7 @@ class ExtensionModelAssociator : public AssociatorInterface {
}
private:
+ const ExtensionSyncTraits traits_;
// Weak pointer. Always non-NULL.
ProfileSyncService* sync_service_;
diff --git a/chrome/browser/sync/glue/extension_sync_traits.cc b/chrome/browser/sync/glue/extension_sync_traits.cc
index 0673967..7ea54d3 100644
--- a/chrome/browser/sync/glue/extension_sync_traits.cc
+++ b/chrome/browser/sync/glue/extension_sync_traits.cc
@@ -6,6 +6,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/sync/engine/syncapi.h"
+#include "chrome/browser/sync/protocol/app_specifics.pb.h"
#include "chrome/browser/sync/protocol/extension_specifics.pb.h"
namespace browser_sync {
@@ -64,4 +65,44 @@ ExtensionSyncTraits GetExtensionSyncTraits() {
&GetExtensionSpecificsFromEntity);
}
+namespace {
+
+const sync_pb::ExtensionSpecifics& GetExtensionSpecificsOfApp(
+ const sync_api::BaseNode& node) {
+ return node.GetAppSpecifics().extension();
+}
+
+void SetExtensionSpecificsOfApp(
+ const sync_pb::ExtensionSpecifics& extension_specifics,
+ sync_api::WriteNode* node) {
+ node->SetTitle(UTF8ToWide(extension_specifics.name()));
+ sync_pb::AppSpecifics app_specifics;
+ *app_specifics.mutable_extension() = extension_specifics;
+ node->SetAppSpecifics(app_specifics);
+}
+
+bool GetExtensionSpecificsFromEntityOfApp(
+ const sync_pb::EntitySpecifics& entity_specifics,
+ sync_pb::ExtensionSpecifics* extension_specifics) {
+ if (!entity_specifics.HasExtension(sync_pb::app)) {
+ return false;
+ }
+ *extension_specifics =
+ entity_specifics.GetExtension(sync_pb::app).extension();
+ return true;
+}
+
+} // namespace
+
+ExtensionSyncTraits GetAppSyncTraits() {
+ ExtensionTypeSet allowed_extension_types;
+ allowed_extension_types.insert(APP);
+ return ExtensionSyncTraits(syncable::APPS,
+ "google_chrome_apps",
+ allowed_extension_types,
+ &GetExtensionSpecificsOfApp,
+ &SetExtensionSpecificsOfApp,
+ &GetExtensionSpecificsFromEntityOfApp);
+}
+
} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/extension_sync_traits.h b/chrome/browser/sync/glue/extension_sync_traits.h
index 7dd52d9..8179fb6 100644
--- a/chrome/browser/sync/glue/extension_sync_traits.h
+++ b/chrome/browser/sync/glue/extension_sync_traits.h
@@ -66,7 +66,8 @@ struct ExtensionSyncTraits {
// Gets traits for extensions sync.
ExtensionSyncTraits GetExtensionSyncTraits();
-// TODO(akalin): Write GetAppSyncTraits(), too.
+// Gets traits for apps sync.
+ExtensionSyncTraits GetAppSyncTraits();
} // namespace browser_sync
diff --git a/chrome/browser/sync/profile_sync_factory.h b/chrome/browser/sync/profile_sync_factory.h
index 1877bc9..dfeea8a 100644
--- a/chrome/browser/sync/profile_sync_factory.h
+++ b/chrome/browser/sync/profile_sync_factory.h
@@ -58,6 +58,13 @@ class ProfileSyncFactory {
const browser_sync::DataTypeController::TypeMap& controllers) = 0;
// Instantiates both a model associator and change processor for the
+ // app data type. The pointers in the return struct are
+ // owned by the caller.
+ virtual SyncComponents CreateAppSyncComponents(
+ ProfileSyncService* profile_sync_service,
+ browser_sync::UnrecoverableErrorHandler* error_handler) = 0;
+
+ // Instantiates both a model associator and change processor for the
// autofill data type. The pointers in the return struct are owned
// by the caller.
virtual SyncComponents CreateAutofillSyncComponents(
diff --git a/chrome/browser/sync/profile_sync_factory_impl.cc b/chrome/browser/sync/profile_sync_factory_impl.cc
index 8a0b293..eb3cca8 100644
--- a/chrome/browser/sync/profile_sync_factory_impl.cc
+++ b/chrome/browser/sync/profile_sync_factory_impl.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/sync/glue/app_data_type_controller.h"
#include "chrome/browser/sync/glue/autofill_change_processor.h"
#include "chrome/browser/sync/glue/autofill_data_type_controller.h"
#include "chrome/browser/sync/glue/autofill_model_associator.h"
@@ -16,6 +17,7 @@
#include "chrome/browser/sync/glue/extension_change_processor.h"
#include "chrome/browser/sync/glue/extension_data_type_controller.h"
#include "chrome/browser/sync/glue/extension_model_associator.h"
+#include "chrome/browser/sync/glue/extension_sync_traits.h"
#include "chrome/browser/sync/glue/password_change_processor.h"
#include "chrome/browser/sync/glue/password_data_type_controller.h"
#include "chrome/browser/sync/glue/password_model_associator.h"
@@ -34,6 +36,7 @@
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/chrome_switches.h"
+using browser_sync::AppDataTypeController;
using browser_sync::AutofillChangeProcessor;
using browser_sync::AutofillDataTypeController;
using browser_sync::AutofillModelAssociator;
@@ -71,6 +74,13 @@ ProfileSyncService* ProfileSyncFactoryImpl::CreateProfileSyncService() {
ProfileSyncService* pss = new ProfileSyncService(
this, profile_, browser_defaults::kBootstrapSyncAuthentication);
+ // App sync is disabled by default. Register only if
+ // explicitly enabled.
+ if (command_line_->HasSwitch(switches::kEnableSyncApps)) {
+ pss->RegisterDataTypeController(
+ new AppDataTypeController(this, profile_, pss));
+ }
+
// Autofill sync is enabled by default. Register unless explicitly
// disabled.
if (!command_line_->HasSwitch(switches::kDisableSyncAutofill)) {
@@ -129,6 +139,21 @@ DataTypeManager* ProfileSyncFactoryImpl::CreateDataTypeManager(
}
ProfileSyncFactory::SyncComponents
+ProfileSyncFactoryImpl::CreateAppSyncComponents(
+ ProfileSyncService* profile_sync_service,
+ UnrecoverableErrorHandler* error_handler) {
+ browser_sync::ExtensionSyncTraits traits = browser_sync::GetAppSyncTraits();
+ // For now we simply use extensions sync objects with the app sync
+ // traits. If apps become more than simply extensions, we may have
+ // to write our own apps model associator and/or change processor.
+ ExtensionModelAssociator* model_associator =
+ new ExtensionModelAssociator(traits, profile_sync_service);
+ ExtensionChangeProcessor* change_processor =
+ new ExtensionChangeProcessor(traits, error_handler);
+ return SyncComponents(model_associator, change_processor);
+}
+
+ProfileSyncFactory::SyncComponents
ProfileSyncFactoryImpl::CreateAutofillSyncComponents(
ProfileSyncService* profile_sync_service,
WebDatabase* web_database,
@@ -163,10 +188,12 @@ ProfileSyncFactory::SyncComponents
ProfileSyncFactoryImpl::CreateExtensionSyncComponents(
ProfileSyncService* profile_sync_service,
UnrecoverableErrorHandler* error_handler) {
+ browser_sync::ExtensionSyncTraits traits =
+ browser_sync::GetExtensionSyncTraits();
ExtensionModelAssociator* model_associator =
- new ExtensionModelAssociator(profile_sync_service);
+ new ExtensionModelAssociator(traits, profile_sync_service);
ExtensionChangeProcessor* change_processor =
- new ExtensionChangeProcessor(error_handler);
+ new ExtensionChangeProcessor(traits, error_handler);
return SyncComponents(model_associator, change_processor);
}
diff --git a/chrome/browser/sync/profile_sync_factory_impl.h b/chrome/browser/sync/profile_sync_factory_impl.h
index f9e8c15..58d39bb 100644
--- a/chrome/browser/sync/profile_sync_factory_impl.h
+++ b/chrome/browser/sync/profile_sync_factory_impl.h
@@ -24,6 +24,10 @@ class ProfileSyncFactoryImpl : public ProfileSyncFactory {
browser_sync::SyncBackendHost* backend,
const browser_sync::DataTypeController::TypeMap& controllers);
+ virtual SyncComponents CreateAppSyncComponents(
+ ProfileSyncService* profile_sync_service,
+ browser_sync::UnrecoverableErrorHandler* error_handler);
+
virtual SyncComponents CreateAutofillSyncComponents(
ProfileSyncService* profile_sync_service,
WebDatabase* web_database,
diff --git a/chrome/browser/sync/profile_sync_factory_mock.h b/chrome/browser/sync/profile_sync_factory_mock.h
index d7531dc..d0328c0 100644
--- a/chrome/browser/sync/profile_sync_factory_mock.h
+++ b/chrome/browser/sync/profile_sync_factory_mock.h
@@ -29,6 +29,9 @@ class ProfileSyncFactoryMock : public ProfileSyncFactory {
browser_sync::DataTypeManager*(
browser_sync::SyncBackendHost*,
const browser_sync::DataTypeController::TypeMap&));
+ MOCK_METHOD2(CreateAppSyncComponents,
+ SyncComponents(ProfileSyncService* profile_sync_service,
+ browser_sync::UnrecoverableErrorHandler* error_handler));
MOCK_METHOD4(CreateAutofillSyncComponents,
SyncComponents(
ProfileSyncService* profile_sync_service,
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 17fd252..f441f4d 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -239,6 +239,7 @@ void ProfileSyncService::RegisterPreferences() {
pref_service->RegisterBooleanPref(prefs::kSyncThemes, enable_by_default);
pref_service->RegisterBooleanPref(prefs::kSyncTypedUrls, enable_by_default);
pref_service->RegisterBooleanPref(prefs::kSyncExtensions, enable_by_default);
+ pref_service->RegisterBooleanPref(prefs::kSyncApps, enable_by_default);
pref_service->RegisterBooleanPref(prefs::kKeepEverythingSynced,
enable_by_default);
@@ -406,6 +407,8 @@ const char* ProfileSyncService::GetPrefNameForDataType(
return prefs::kSyncTypedUrls;
case syncable::EXTENSIONS:
return prefs::kSyncExtensions;
+ case syncable::APPS:
+ return prefs::kSyncApps;
default:
NOTREACHED();
return NULL;
diff --git a/chrome/browser/sync/resources/choose_datatypes.html b/chrome/browser/sync/resources/choose_datatypes.html
index 166334f..fa2e58a 100644
--- a/chrome/browser/sync/resources/choose_datatypes.html
+++ b/chrome/browser/sync/resources/choose_datatypes.html
@@ -173,6 +173,13 @@ html[os='mac'] input[type='submit'] {
} else {
document.getElementById("omniboxItem").className = "sync-item-hide";
}
+ if (args.appsRegistered) {
+ document.getElementById("appsCheckbox").checked =
+ args.syncApps;
+ document.getElementById("appsItem").className = "sync-item-show";
+ } else {
+ document.getElementById("appsItem").className = "sync-item-hide";
+ }
}
function setErrorState(args) {
@@ -256,7 +263,8 @@ html[os='mac'] input[type='submit'] {
"syncPasswords": syncAll || f.passwordsCheckbox.checked,
"syncAutofill": syncAll || f.autofillCheckbox.checked,
"syncExtensions": syncAll || f.extensionsCheckbox.checked,
- "syncTypedUrls": syncAll || f.typedUrlsCheckbox.checked
+ "syncTypedUrls": syncAll || f.typedUrlsCheckbox.checked,
+ "syncApps": syncAll || f.appsCheckbox.checked
});
chrome.send("ChooseDataTypes", [result]);
}
@@ -285,6 +293,12 @@ html[os='mac'] input[type='submit'] {
<div id="chooseDataTypesBody">
<label for="chooseDataTypesRadio" i18n-content="choosedatatypes" ></label>
<div>
+ <!-- Apps -->
+ <div class="sync-item-show" id="appsItem">
+ <input id="appsCheckbox" name="dataTypeCheckbox" type="checkbox">
+ <label id="appsCheckboxLabel" name="dataTypeLabel"
+ for="appsCheckbox" i18n-content="apps"></label>
+ </div>
<!-- Autofill -->
<div class="sync-item-show" id="autofillItem">
<input id="autofillCheckbox" name="dataTypeCheckbox" type="checkbox">
diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc
index d3b048f..1fecbad 100644
--- a/chrome/browser/sync/sync_setup_flow.cc
+++ b/chrome/browser/sync/sync_setup_flow.cc
@@ -112,6 +112,12 @@ static bool GetDataTypeChoiceData(const std::string& json,
if (sync_typed_urls)
data_types->insert(syncable::TYPED_URLS);
+ bool sync_apps;
+ if (!result->GetBoolean(L"syncApps", &sync_apps))
+ return false;
+ if (sync_apps)
+ data_types->insert(syncable::APPS);
+
return true;
}
@@ -353,6 +359,8 @@ void SyncSetupFlow::GetArgsForChooseDataTypes(ProfileSyncService* service,
registered_types.count(syncable::EXTENSIONS) > 0);
args->SetBoolean("typedUrlsRegistered",
registered_types.count(syncable::TYPED_URLS) > 0);
+ args->SetBoolean(L"appsRegistered",
+ registered_types.count(syncable::APPS) > 0);
args->SetBoolean("syncBookmarks",
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncBookmarks));
@@ -368,6 +376,8 @@ void SyncSetupFlow::GetArgsForChooseDataTypes(ProfileSyncService* service,
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncExtensions));
args->SetBoolean("syncTypedUrls",
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncTypedUrls));
+ args->SetBoolean(L"syncApps",
+ service->profile()->GetPrefs()->GetBoolean(prefs::kSyncApps));
}
void SyncSetupFlow::GetDOMMessageHandlers(
diff --git a/chrome/browser/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc
index 5a254dc..9998025 100644
--- a/chrome/browser/sync/sync_setup_wizard.cc
+++ b/chrome/browser/sync/sync_setup_wizard.cc
@@ -142,6 +142,8 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
l10n_util::GetString(IDS_SYNC_DATATYPE_EXTENSIONS));
localized_strings.SetString(L"typedurls",
l10n_util::GetString(IDS_SYNC_DATATYPE_TYPED_URLS));
+ localized_strings.SetString(L"apps",
+ l10n_util::GetString(IDS_SYNC_DATATYPE_APPS));
localized_strings.SetString(L"synczerodatatypeserror",
l10n_util::GetString(IDS_SYNC_ZERO_DATA_TYPES_ERROR));
localized_strings.SetString(L"setupabortederror",
diff --git a/chrome/browser/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc
index e784231..cc6ffb0 100644
--- a/chrome/browser/sync/sync_setup_wizard_unittest.cc
+++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc
@@ -306,11 +306,11 @@ TEST_F(SyncSetupWizardTest, ChooseDataTypesSetsPrefs) {
data_type_choices += "\"syncBookmarks\":true,\"syncPreferences\":true,";
data_type_choices += "\"syncThemes\":false,\"syncPasswords\":false,";
data_type_choices += "\"syncAutofill\":false,\"syncExtensions\":false,";
- data_type_choices += "\"syncTypedUrls\":true}";
+ data_type_choices += "\"syncTypedUrls\":true,\"syncApps\":true}";
data_type_choices_value.Append(new StringValue(data_type_choices));
- // Simulate the user choosing data types; bookmarks and prefs are on, the rest
- // are off.
+ // Simulate the user choosing data types; bookmarks, prefs, typed
+ // URLS, and apps are on, the rest are off.
test_window_->flow()->flow_handler_->HandleChooseDataTypes(
&data_type_choices_value);
EXPECT_TRUE(wizard_->IsVisible());
@@ -323,6 +323,7 @@ TEST_F(SyncSetupWizardTest, ChooseDataTypesSetsPrefs) {
EXPECT_EQ(service_->chosen_data_types_.count(syncable::AUTOFILL), 0U);
EXPECT_EQ(service_->chosen_data_types_.count(syncable::EXTENSIONS), 0U);
EXPECT_EQ(service_->chosen_data_types_.count(syncable::TYPED_URLS), 1U);
+ EXPECT_EQ(service_->chosen_data_types_.count(syncable::APPS), 1U);
test_window_->CloseDialog();
}