Commit aa7599d5 authored by munjal@chromium.org's avatar munjal@chromium.org

Add a couple of notifications related settings to app/extensions sync:

- Whether notifications setup is done once already.
- Whether the user has disabled notifications.
Review URL: http://codereview.chromium.org/8399022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107692 0039d316-1c4b-4281-b951-d872f2087c98
parent b9ca82db
...@@ -45,6 +45,12 @@ const char kPrefVersion[] = "manifest.version"; ...@@ -45,6 +45,12 @@ const char kPrefVersion[] = "manifest.version";
// Indicates whether an extension is blacklisted. // Indicates whether an extension is blacklisted.
const char kPrefBlacklist[] = "blacklist"; const char kPrefBlacklist[] = "blacklist";
// Indicates whether the user has done app notifications setup or not.
const char kPrefAppNotificationSetup[] = "app_notif_setup";
// Indicates whether the user has disabled notifications or not.
const char kPrefAppNotificationDisbaled[] = "app_notif_disabled";
// Indicates whether the user has acknowledged various types of extensions. // Indicates whether the user has acknowledged various types of extensions.
const char kPrefExternalAcknowledged[] = "ack_external"; const char kPrefExternalAcknowledged[] = "ack_external";
const char kPrefBlacklistAcknowledged[] = "ack_blacklist"; const char kPrefBlacklistAcknowledged[] = "ack_blacklist";
...@@ -367,7 +373,7 @@ bool ExtensionPrefs::ReadBooleanFromPref( ...@@ -367,7 +373,7 @@ bool ExtensionPrefs::ReadBooleanFromPref(
} }
bool ExtensionPrefs::ReadExtensionPrefBoolean( bool ExtensionPrefs::ReadExtensionPrefBoolean(
const std::string& extension_id, const std::string& pref_key) { const std::string& extension_id, const std::string& pref_key) const {
const DictionaryValue* ext = GetExtensionPref(extension_id); const DictionaryValue* ext = GetExtensionPref(extension_id);
if (!ext) { if (!ext) {
// No such extension yet. // No such extension yet.
...@@ -586,6 +592,32 @@ bool ExtensionPrefs::SetAlertSystemFirstRun() { ...@@ -586,6 +592,32 @@ bool ExtensionPrefs::SetAlertSystemFirstRun() {
return false; return false;
} }
bool ExtensionPrefs::IsAppNotificationSetupDone(
const std::string& extension_id) const {
return ReadExtensionPrefBoolean(
extension_id, kPrefAppNotificationSetup);
}
void ExtensionPrefs::SetAppNotificationSetupDone(
const std::string& extension_id,
bool value) {
DCHECK(Extension::IdIsValid(extension_id));
UpdateExtensionPref(extension_id, kPrefAppNotificationSetup,
Value::CreateBooleanValue(value));
}
bool ExtensionPrefs::IsAppNotificationDisabled(
const std::string& extension_id) const {
return ReadExtensionPrefBoolean(extension_id, kPrefAppNotificationDisbaled);
}
void ExtensionPrefs::SetAppNotificationDisabled(
const std::string& extension_id, bool value) {
DCHECK(Extension::IdIsValid(extension_id));
UpdateExtensionPref(extension_id, kPrefAppNotificationDisbaled,
Value::CreateBooleanValue(value));
}
bool ExtensionPrefs::IsExtensionAllowedByPolicy( bool ExtensionPrefs::IsExtensionAllowedByPolicy(
const std::string& extension_id) { const std::string& extension_id) {
std::string string_value; std::string string_value;
......
...@@ -171,6 +171,15 @@ class ExtensionPrefs : public ExtensionContentSettingsStore::Observer { ...@@ -171,6 +171,15 @@ class ExtensionPrefs : public ExtensionContentSettingsStore::Observer {
// reset it. Don't call it unless you mean it! // reset it. Don't call it unless you mean it!
bool SetAlertSystemFirstRun(); bool SetAlertSystemFirstRun();
// Whether app notifications setup is done for the given app.
bool IsAppNotificationSetupDone(const std::string& extension_id) const;
void SetAppNotificationSetupDone(const std::string& extension_id,
bool value);
// Whether app notifications are disabled for the given app.
bool IsAppNotificationDisabled(const std::string& extension_id) const;
void SetAppNotificationDisabled(const std::string& extension_id, bool value);
// Is the extension with |extension_id| allowed by policy (checking both // Is the extension with |extension_id| allowed by policy (checking both
// whitelist and blacklist). // whitelist and blacklist).
bool IsExtensionAllowedByPolicy(const std::string& extension_id); bool IsExtensionAllowedByPolicy(const std::string& extension_id);
...@@ -429,7 +438,7 @@ class ExtensionPrefs : public ExtensionContentSettingsStore::Observer { ...@@ -429,7 +438,7 @@ class ExtensionPrefs : public ExtensionContentSettingsStore::Observer {
// Reads a boolean pref |pref_key| from extension with id |extension_id|. // Reads a boolean pref |pref_key| from extension with id |extension_id|.
bool ReadExtensionPrefBoolean(const std::string& extension_id, bool ReadExtensionPrefBoolean(const std::string& extension_id,
const std::string& pref_key); const std::string& pref_key) const;
// Reads an integer pref from |ext| with key |pref_key|. // Reads an integer pref from |ext| with key |pref_key|.
// Return false if the value does not exist. // Return false if the value does not exist.
......
...@@ -892,9 +892,12 @@ bool ExtensionService::UninstallExtension( ...@@ -892,9 +892,12 @@ bool ExtensionService::UninstallExtension(
SyncChange sync_change; SyncChange sync_change;
if (sync_bundle) { if (sync_bundle) {
ExtensionSyncData extension_sync_data(*extension, ExtensionSyncData extension_sync_data(
IsExtensionEnabled(extension_id), *extension,
IsIncognitoEnabled(extension_id)); IsExtensionEnabled(extension_id),
IsIncognitoEnabled(extension_id),
extension_prefs_->IsAppNotificationSetupDone(extension_id),
extension_prefs_->IsAppNotificationDisabled(extension_id));
sync_change = extension_sync_data.GetSyncChange(SyncChange::ACTION_DELETE); sync_change = extension_sync_data.GetSyncChange(SyncChange::ACTION_DELETE);
} }
...@@ -1733,9 +1736,12 @@ bool ExtensionService::SyncBundle::HasPendingExtensionId(const std::string& id) ...@@ -1733,9 +1736,12 @@ bool ExtensionService::SyncBundle::HasPendingExtensionId(const std::string& id)
void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
SyncBundle* sync_bundle = GetSyncBundleForExtension(extension); SyncBundle* sync_bundle = GetSyncBundleForExtension(extension);
if (sync_bundle) { if (sync_bundle) {
ExtensionSyncData extension_sync_data(extension, ExtensionSyncData extension_sync_data(
IsExtensionEnabled(extension.id()), extension,
IsIncognitoEnabled(extension.id())); IsExtensionEnabled(extension.id()),
IsIncognitoEnabled(extension.id()),
extension_prefs_->IsAppNotificationSetupDone(extension.id()),
extension_prefs_->IsAppNotificationDisabled(extension.id()));
SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange( SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange(
sync_bundle->HasExtensionId(extension.id()) ? sync_bundle->HasExtensionId(extension.id()) ?
...@@ -1895,10 +1901,12 @@ void ExtensionService::GetSyncDataListHelper( ...@@ -1895,10 +1901,12 @@ void ExtensionService::GetSyncDataListHelper(
// version is out of date. We'll sync back the version we got from // version is out of date. We'll sync back the version we got from
// sync. // sync.
!bundle.HasPendingExtensionId(extension.id())) { !bundle.HasPendingExtensionId(extension.id())) {
sync_data_list->push_back( sync_data_list->push_back(ExtensionSyncData(
ExtensionSyncData(extension, extension,
IsExtensionEnabled(extension.id()), IsExtensionEnabled(extension.id()),
IsIncognitoEnabled(extension.id()))); IsIncognitoEnabled(extension.id()),
extension_prefs_->IsAppNotificationSetupDone(extension.id()),
extension_prefs_->IsAppNotificationDisabled(extension.id())));
} }
} }
} }
...@@ -2022,6 +2030,35 @@ void ExtensionService::SetIsIncognitoEnabled( ...@@ -2022,6 +2030,35 @@ void ExtensionService::SetIsIncognitoEnabled(
SyncExtensionChangeIfNeeded(*extension); SyncExtensionChangeIfNeeded(*extension);
} }
void ExtensionService::SetAppNotificationSetupDone(
const std::string& extension_id,
bool value) {
const Extension* extension = GetInstalledExtension(extension_id);
// This method is called when the user sets up app notifications.
// So it is not expected to be called until the extension is installed.
if (!extension) {
NOTREACHED();
return;
}
extension_prefs_->SetAppNotificationSetupDone(extension_id, value);
SyncExtensionChangeIfNeeded(*extension);
}
void ExtensionService::SetAppNotificationDisabled(
const std::string& extension_id,
bool value) {
const Extension* extension = GetInstalledExtension(extension_id);
// This method is called when the user enables/disables app notifications.
// So it is not expected to be called until the extension is installed.
if (!extension) {
NOTREACHED();
return;
}
extension_prefs_->SetAppNotificationDisabled(extension_id, value);
SyncExtensionChangeIfNeeded(*extension);
}
bool ExtensionService::CanCrossIncognito(const Extension* extension) { bool ExtensionService::CanCrossIncognito(const Extension* extension) {
// We allow the extension to see events and data from another profile iff it // We allow the extension to see events and data from another profile iff it
// uses "spanning" behavior and it has incognito access. "split" mode // uses "spanning" behavior and it has incognito access. "split" mode
......
...@@ -207,6 +207,12 @@ class ExtensionService ...@@ -207,6 +207,12 @@ class ExtensionService
virtual void SetIsIncognitoEnabled(const std::string& extension_id, virtual void SetIsIncognitoEnabled(const std::string& extension_id,
bool enabled); bool enabled);
virtual void SetAppNotificationSetupDone(const std::string& extension_id,
bool value);
virtual void SetAppNotificationDisabled(const std::string& extension_id,
bool value);
// Returns true if the given extension can see events and data from another // Returns true if the given extension can see events and data from another
// sub-profile (incognito to original profile, or vice versa). // sub-profile (incognito to original profile, or vice versa).
bool CanCrossIncognito(const Extension* extension); bool CanCrossIncognito(const Extension* extension);
......
...@@ -13,14 +13,18 @@ ExtensionSyncData::ExtensionSyncData() ...@@ -13,14 +13,18 @@ ExtensionSyncData::ExtensionSyncData()
: uninstalled_(false), : uninstalled_(false),
enabled_(false), enabled_(false),
incognito_enabled_(false), incognito_enabled_(false),
type_(Extension::SYNC_TYPE_NONE) { type_(Extension::SYNC_TYPE_NONE),
notifications_initial_setup_done_(false),
notifications_disabled_(false) {
} }
ExtensionSyncData::ExtensionSyncData(const SyncData& sync_data) ExtensionSyncData::ExtensionSyncData(const SyncData& sync_data)
: uninstalled_(false), : uninstalled_(false),
enabled_(false), enabled_(false),
incognito_enabled_(false), incognito_enabled_(false),
type_(Extension::SYNC_TYPE_NONE) { type_(Extension::SYNC_TYPE_NONE),
notifications_initial_setup_done_(false),
notifications_disabled_(false) {
PopulateFromSyncData(sync_data); PopulateFromSyncData(sync_data);
} }
...@@ -31,7 +35,9 @@ ExtensionSyncData::ExtensionSyncData(const SyncChange& sync_change) ...@@ -31,7 +35,9 @@ ExtensionSyncData::ExtensionSyncData(const SyncChange& sync_change)
ExtensionSyncData::ExtensionSyncData(const Extension& extension, ExtensionSyncData::ExtensionSyncData(const Extension& extension,
bool enabled, bool enabled,
bool incognito_enabled) bool incognito_enabled,
bool notifications_initial_setup_done,
bool notifications_disabled)
: id_(extension.id()), : id_(extension.id()),
uninstalled_(false), uninstalled_(false),
enabled_(enabled), enabled_(enabled),
...@@ -39,11 +45,23 @@ ExtensionSyncData::ExtensionSyncData(const Extension& extension, ...@@ -39,11 +45,23 @@ ExtensionSyncData::ExtensionSyncData(const Extension& extension,
type_(extension.GetSyncType()), type_(extension.GetSyncType()),
version_(*extension.version()), version_(*extension.version()),
update_url_(extension.update_url()), update_url_(extension.update_url()),
name_(extension.name()) { name_(extension.name()),
notifications_initial_setup_done_(notifications_initial_setup_done),
notifications_disabled_(notifications_disabled) {
} }
ExtensionSyncData::~ExtensionSyncData() {} ExtensionSyncData::~ExtensionSyncData() {}
void ExtensionSyncData::PopulateAppSpecifics(
sync_pb::AppSpecifics* specifics) const {
DCHECK(specifics);
sync_pb::AppNotificationSettings* notif_settings =
specifics->mutable_notification_settings();
notif_settings->set_initial_setup_done(notifications_initial_setup_done_);
notif_settings->set_disabled(notifications_disabled_);
PopulateSyncSpecifics(specifics->mutable_extension());
}
void ExtensionSyncData::PopulateSyncSpecifics( void ExtensionSyncData::PopulateSyncSpecifics(
sync_pb::ExtensionSpecifics* specifics) const { sync_pb::ExtensionSpecifics* specifics) const {
DCHECK(Extension::IdIsValid(id_)); DCHECK(Extension::IdIsValid(id_));
...@@ -57,22 +75,18 @@ void ExtensionSyncData::PopulateSyncSpecifics( ...@@ -57,22 +75,18 @@ void ExtensionSyncData::PopulateSyncSpecifics(
SyncData ExtensionSyncData::GetSyncData() const { SyncData ExtensionSyncData::GetSyncData() const {
sync_pb::EntitySpecifics specifics; sync_pb::EntitySpecifics specifics;
sync_pb::ExtensionSpecifics* extension_specifics = NULL;
switch (type_) { switch (type_) {
case Extension::SYNC_TYPE_EXTENSION: case Extension::SYNC_TYPE_EXTENSION:
extension_specifics = specifics.MutableExtension(sync_pb::extension); PopulateSyncSpecifics(specifics.MutableExtension(sync_pb::extension));
break; break;
case Extension::SYNC_TYPE_APP: case Extension::SYNC_TYPE_APP:
extension_specifics = PopulateAppSpecifics(specifics.MutableExtension(sync_pb::app));
specifics.MutableExtension(sync_pb::app)->mutable_extension();
break; break;
default: default:
LOG(FATAL) << "Attempt to get non-syncable data."; LOG(FATAL) << "Attempt to get non-syncable data.";
} }
PopulateSyncSpecifics(extension_specifics);
return SyncData::CreateLocalData(id_, name_, specifics); return SyncData::CreateLocalData(id_, name_, specifics);
} }
...@@ -112,9 +126,18 @@ void ExtensionSyncData::PopulateFromSyncData(const SyncData& sync_data) { ...@@ -112,9 +126,18 @@ void ExtensionSyncData::PopulateFromSyncData(const SyncData& sync_data) {
extension_expecifics = entity_specifics.GetExtension(sync_pb::extension); extension_expecifics = entity_specifics.GetExtension(sync_pb::extension);
type_ = Extension::SYNC_TYPE_EXTENSION; type_ = Extension::SYNC_TYPE_EXTENSION;
} else if (entity_specifics.HasExtension(sync_pb::app)) { } else if (entity_specifics.HasExtension(sync_pb::app)) {
extension_expecifics = sync_pb::AppSpecifics app_specifics = entity_specifics.GetExtension(
entity_specifics.GetExtension(sync_pb::app).extension(); sync_pb::app);
extension_expecifics = app_specifics.extension();
type_ = Extension::SYNC_TYPE_APP; type_ = Extension::SYNC_TYPE_APP;
notifications_initial_setup_done_ =
app_specifics.has_notification_settings() &&
app_specifics.notification_settings().has_initial_setup_done() &&
app_specifics.notification_settings().initial_setup_done();
notifications_disabled_ =
app_specifics.has_notification_settings() &&
app_specifics.notification_settings().has_disabled() &&
app_specifics.notification_settings().disabled();
} else { } else {
LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; LOG(FATAL) << "Attempt to sync bad EntitySpecifics.";
} }
......
...@@ -16,7 +16,10 @@ ...@@ -16,7 +16,10 @@
class ExtensionService; class ExtensionService;
class SyncData; class SyncData;
namespace sync_pb { class ExtensionSpecifics; } namespace sync_pb {
class AppSpecifics;
class ExtensionSpecifics;
}
// A class that encapsulates the synced properties of an Extension. // A class that encapsulates the synced properties of an Extension.
class ExtensionSyncData { class ExtensionSyncData {
...@@ -26,11 +29,14 @@ class ExtensionSyncData { ...@@ -26,11 +29,14 @@ class ExtensionSyncData {
explicit ExtensionSyncData(const SyncChange& sync_change); explicit ExtensionSyncData(const SyncChange& sync_change);
ExtensionSyncData(const Extension& extension, ExtensionSyncData(const Extension& extension,
bool enabled, bool enabled,
bool incognito_enabled); bool incognito_enabled,
bool notifications_initial_setup_done,
bool notifications_disabled);
~ExtensionSyncData(); ~ExtensionSyncData();
// Convert an ExtensionSyncData back out to a sync structure. // Convert an ExtensionSyncData back out to a sync structure.
void PopulateSyncSpecifics(sync_pb::ExtensionSpecifics* specifics) const; void PopulateSyncSpecifics(sync_pb::ExtensionSpecifics* specifics) const;
void PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const;
SyncData GetSyncData() const; SyncData GetSyncData() const;
SyncChange GetSyncChange(SyncChange::SyncChangeType change_type) const; SyncChange GetSyncChange(SyncChange::SyncChangeType change_type) const;
...@@ -51,6 +57,14 @@ class ExtensionSyncData { ...@@ -51,6 +57,14 @@ class ExtensionSyncData {
// Used only for debugging. // Used only for debugging.
const std::string& name() const { return name_; } const std::string& name() const { return name_; }
bool notifications_initial_setup_done() const {
return notifications_initial_setup_done_;
}
bool notifications_disabled() const {
return notifications_disabled_;
}
private: private:
void PopulateFromExtensionSpecifics( void PopulateFromExtensionSpecifics(
const sync_pb::ExtensionSpecifics& specifics); const sync_pb::ExtensionSpecifics& specifics);
...@@ -64,6 +78,8 @@ class ExtensionSyncData { ...@@ -64,6 +78,8 @@ class ExtensionSyncData {
Version version_; Version version_;
GURL update_url_; GURL update_url_;
std::string name_; std::string name_;
bool notifications_initial_setup_done_;
bool notifications_disabled_;
}; };
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_
...@@ -34,7 +34,7 @@ const char kName2[] = "MyExtension2"; ...@@ -34,7 +34,7 @@ const char kName2[] = "MyExtension2";
class ExtensionSyncDataTest : public testing::Test { class ExtensionSyncDataTest : public testing::Test {
}; };
TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncData) { TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncDataForExtension) {
sync_pb::EntitySpecifics entity; sync_pb::EntitySpecifics entity;
sync_pb::ExtensionSpecifics* extension_specifics = sync_pb::ExtensionSpecifics* extension_specifics =
entity.MutableExtension(sync_pb::extension); entity.MutableExtension(sync_pb::extension);
...@@ -60,7 +60,7 @@ TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncData) { ...@@ -60,7 +60,7 @@ TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncData) {
EXPECT_FALSE(extension_sync_data.uninstalled()); EXPECT_FALSE(extension_sync_data.uninstalled());
} }
TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncData) { TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncDataForExtension) {
sync_pb::EntitySpecifics entity; sync_pb::EntitySpecifics entity;
sync_pb::ExtensionSpecifics* input_extension = sync_pb::ExtensionSpecifics* input_extension =
entity.MutableExtension(sync_pb::extension); entity.MutableExtension(sync_pb::extension);
...@@ -88,4 +88,67 @@ TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncData) { ...@@ -88,4 +88,67 @@ TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncData) {
EXPECT_EQ(extension_sync_data.name(), output_specifics.name()); EXPECT_EQ(extension_sync_data.name(), output_specifics.name());
} }
TEST_F(ExtensionSyncDataTest, SyncDataToExtensionSyncDataForApp) {
sync_pb::EntitySpecifics entity;
sync_pb::AppSpecifics* app_specifics = entity.MutableExtension(sync_pb::app);
sync_pb::ExtensionSpecifics* extension_specifics =
app_specifics->mutable_extension();
extension_specifics->set_id(kValidId);
extension_specifics->set_update_url(kValidUpdateUrl2);
extension_specifics->set_enabled(false);
extension_specifics->set_incognito_enabled(true);
extension_specifics->set_version(kVersion1);
extension_specifics->set_name(kName);
sync_pb::AppNotificationSettings* notif_settings =
app_specifics->mutable_notification_settings();
notif_settings->set_initial_setup_done(true);
notif_settings->set_disabled(true);
SyncData sync_data =
SyncData::CreateLocalData("sync_tag", "non_unique_title", entity);
ExtensionSyncData extension_sync_data(sync_data);
EXPECT_EQ(extension_specifics->id(), extension_sync_data.id());
EXPECT_EQ(extension_specifics->version(),
extension_sync_data.version().GetString());
EXPECT_EQ(extension_specifics->update_url(),
extension_sync_data.update_url().spec());
EXPECT_EQ(extension_specifics->enabled(), extension_sync_data.enabled());
EXPECT_EQ(extension_specifics->incognito_enabled(),
extension_sync_data.incognito_enabled());
EXPECT_EQ(extension_specifics->name(), extension_sync_data.name());
EXPECT_FALSE(extension_sync_data.uninstalled());
EXPECT_EQ(notif_settings->initial_setup_done(),
extension_sync_data.notifications_initial_setup_done());
EXPECT_EQ(notif_settings->disabled(),
extension_sync_data.notifications_disabled());
}
TEST_F(ExtensionSyncDataTest, ExtensionSyncDataToSyncDataForApp) {
sync_pb::EntitySpecifics entity;
sync_pb::AppSpecifics* input_specifics = entity.MutableExtension(
sync_pb::app);
sync_pb::ExtensionSpecifics* input_extension =
input_specifics->mutable_extension();
input_extension->set_id(kValidId);
input_extension->set_update_url(kValidUpdateUrl2);
input_extension->set_enabled(true);
input_extension->set_incognito_enabled(false);
input_extension->set_version(kVersion1);
input_extension->set_name(kName);
sync_pb::AppNotificationSettings* notif_settings =
input_specifics->mutable_notification_settings();
notif_settings->set_initial_setup_done(true);
notif_settings->set_disabled(true);
SyncData sync_data =
SyncData::CreateLocalData("sync_tag", "non_unique_title", entity);
ExtensionSyncData extension_sync_data(sync_data);
SyncData output_sync_data = extension_sync_data.GetSyncData();
EXPECT_TRUE(sync_data.GetSpecifics().HasExtension(sync_pb::app));
const sync_pb::AppSpecifics& output_specifics =
output_sync_data.GetSpecifics().GetExtension(sync_pb::app);
EXPECT_EQ(input_specifics->SerializeAsString(),
output_specifics.SerializeAsString());
}
} // namespace } // namespace
...@@ -17,6 +17,18 @@ package sync_pb; ...@@ -17,6 +17,18 @@ package sync_pb;
import "sync.proto"; import "sync.proto";
import "extension_specifics.proto"; import "extension_specifics.proto";
// Settings related to push notifications for apps.
message AppNotificationSettings {
// Whether or not the user has setup notifications at least once.
// The value for this field will start out false and will be set
// to true when the user accepts receiving notifications for the
// first time and then it will always remain true.
optional bool initial_setup_done = 1;
// Whether or not the user has disabled notifications.
optional bool disabled = 2;
}
// Properties of app sync objects. // Properties of app sync objects.
// //
// For now, an app is just an extension. We keep the two data types // For now, an app is just an extension. We keep the two data types
...@@ -24,6 +36,9 @@ import "extension_specifics.proto"; ...@@ -24,6 +36,9 @@ import "extension_specifics.proto";
message AppSpecifics { message AppSpecifics {
// Extension data. // Extension data.
optional ExtensionSpecifics extension = 1; optional ExtensionSpecifics extension = 1;
// Notification settings.
optional AppNotificationSettings notification_settings = 2;
} }
extend EntitySpecifics { extend EntitySpecifics {
......
...@@ -102,6 +102,14 @@ DictionaryValue* EncryptedDataToValue(const sync_pb::EncryptedData& proto) { ...@@ -102,6 +102,14 @@ DictionaryValue* EncryptedDataToValue(const sync_pb::EncryptedData& proto) {
return value; return value;
} }
DictionaryValue* AppSettingsToValue(
const sync_pb::AppNotificationSettings& proto) {
DictionaryValue* value = new DictionaryValue();
SET_BOOL(initial_setup_done);
SET_BOOL(disabled);
return value;
}
DictionaryValue* SessionHeaderToValue( DictionaryValue* SessionHeaderToValue(
const sync_pb::SessionHeader& proto) { const sync_pb::SessionHeader& proto) {
DictionaryValue* value = new DictionaryValue(); DictionaryValue* value = new DictionaryValue();
...@@ -182,6 +190,7 @@ DictionaryValue* AppSpecificsToValue( ...@@ -182,6 +190,7 @@ DictionaryValue* AppSpecificsToValue(
const sync_pb::AppSpecifics& proto) { const sync_pb::AppSpecifics& proto) {
DictionaryValue* value = new DictionaryValue(); DictionaryValue* value = new DictionaryValue();
SET(extension, ExtensionSpecificsToValue); SET(extension, ExtensionSpecificsToValue);
SET(notification_settings, AppSettingsToValue);
return value; return value;
} }
......
...@@ -13,6 +13,7 @@ class DictionaryValue; ...@@ -13,6 +13,7 @@ class DictionaryValue;
} }
namespace sync_pb { namespace sync_pb {
class AppNotificationSettings;
class AppNotificationSpecifics; class AppNotificationSpecifics;
class AppSpecifics; class AppSpecifics;
class AutofillProfileSpecifics; class AutofillProfileSpecifics;
...@@ -54,6 +55,10 @@ namespace browser_sync { ...@@ -54,6 +55,10 @@ namespace browser_sync {
base::DictionaryValue* EncryptedDataToValue( base::DictionaryValue* EncryptedDataToValue(
const sync_pb::EncryptedData& encrypted_data); const sync_pb::EncryptedData& encrypted_data);
// Sub-protocol of AppSpecifics.
base::DictionaryValue* AppSettingsToValue(
const sync_pb::AppNotificationSettings& app_notification_settings);
// Sub-protocols of SessionSpecifics. // Sub-protocols of SessionSpecifics.
base::DictionaryValue* SessionHeaderToValue( base::DictionaryValue* SessionHeaderToValue(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment