diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 20:04:58 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-11 20:04:58 +0000 |
commit | 3bc627156b7c1594df0ae95407e6b9d18f5b7343 (patch) | |
tree | b7261fda0637408bd3d404b048227310dd6f2f02 /sync | |
parent | bcbb9b4e583a1e068871ef591ae7f8590707eca7 (diff) | |
download | chromium_src-3bc627156b7c1594df0ae95407e6b9d18f5b7343.zip chromium_src-3bc627156b7c1594df0ae95407e6b9d18f5b7343.tar.gz chromium_src-3bc627156b7c1594df0ae95407e6b9d18f5b7343.tar.bz2 |
Add AppListSpecifics .proto definition and support code
This CL introduces the AppList sync type.
As of patchset #7 this CL depends on https://codereview.chromium.org/106033003/
BUG=313376
Review URL: https://codereview.chromium.org/78773004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240162 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/internal_api/public/base/model_type.h | 2 | ||||
-rw-r--r-- | sync/protocol/app_list_specifics.proto | 49 | ||||
-rw-r--r-- | sync/protocol/nigori_specifics.proto | 3 | ||||
-rw-r--r-- | sync/protocol/proto_enum_conversions.cc | 14 | ||||
-rw-r--r-- | sync/protocol/proto_enum_conversions.h | 4 | ||||
-rw-r--r-- | sync/protocol/proto_enum_conversions_unittest.cc | 7 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.cc | 16 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.h | 5 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions_unittest.cc | 7 | ||||
-rw-r--r-- | sync/protocol/sync.proto | 2 | ||||
-rw-r--r-- | sync/sync_proto.gypi | 1 | ||||
-rw-r--r-- | sync/syncable/model_type.cc | 24 | ||||
-rw-r--r-- | sync/syncable/nigori_util.cc | 7 | ||||
-rw-r--r-- | sync/tools/testserver/chromiumsync.py | 7 | ||||
-rw-r--r-- | sync/util/data_type_histogram.h | 3 |
15 files changed, 147 insertions, 4 deletions
diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h index 4f512b4..c618c450 100644 --- a/sync/internal_api/public/base/model_type.h +++ b/sync/internal_api/public/base/model_type.h @@ -101,6 +101,8 @@ enum ModelType { MANAGED_USERS, // Distilled articles. ARTICLES, + // App List items + APP_LIST, // ---- Proxy types ---- // Proxy types are excluded from the sync protocol, but are still considered diff --git a/sync/protocol/app_list_specifics.proto b/sync/protocol/app_list_specifics.proto new file mode 100644 index 0000000..c677a4b --- /dev/null +++ b/sync/protocol/app_list_specifics.proto @@ -0,0 +1,49 @@ +// Copyright 2013 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. +// +// Sync protocol datatype extension for the app list (aka app launcher). + +// Update proto_{value,enum}_conversions{.h,.cc,_unittest.cc} if you change +// any fields in this file. + +syntax = "proto2"; + +option optimize_for = LITE_RUNTIME; +option retain_unknown_fields = true; + +package sync_pb; + +// Properties of app list objects. +message AppListSpecifics { + // Unique identifier for the item: + // * TYPE_FOLDER: Folder id (generated) + // * TYPE_APP: App Id + // * TYPE_URL: Url + optional string item_id = 1; + + // What type of item this is. + enum AppListItemType { + // An extension app. + TYPE_APP = 1; + // A request to remove any matching default installed apps. + TYPE_REMOVE_DEFAULT_APP = 2; + // A folder containing entries whose |parent_id| matches |item_id|. + TYPE_FOLDER = 3; + // A URL shortcut (functionally equivalent to a bookmark). + TYPE_URL = 4; + } + optional AppListItemType item_type = 2; + + // Item name (FOLDER or URL). + optional string item_name = 3; + + // Id of the parent (folder) item. + optional string parent_id = 4; + + // Which page this item will appear on in the app list. + optional string page_ordinal = 5; + + // Where on a page this item will appear. + optional string item_ordinal = 6; +} diff --git a/sync/protocol/nigori_specifics.proto b/sync/protocol/nigori_specifics.proto index 662b94a..87e6c37 100644 --- a/sync/protocol/nigori_specifics.proto +++ b/sync/protocol/nigori_specifics.proto @@ -123,5 +123,8 @@ message NigoriSpecifics { // Boolean corresponding to whether articles should be encrypted. optional bool encrypt_articles = 37; + + // Boolean corresponding to whether app list items should be encrypted. + optional bool encrypt_app_list = 38; } diff --git a/sync/protocol/proto_enum_conversions.cc b/sync/protocol/proto_enum_conversions.cc index 3183633d..af95822 100644 --- a/sync/protocol/proto_enum_conversions.cc +++ b/sync/protocol/proto_enum_conversions.cc @@ -20,6 +20,20 @@ namespace syncer { #define ENUM_CASE(enum_parent, enum_value) \ case enum_parent::enum_value: return #enum_value +const char* GetAppListItemTypeString( + sync_pb::AppListSpecifics::AppListItemType item_type) { + ASSERT_ENUM_BOUNDS(sync_pb::AppListSpecifics, AppListItemType, + TYPE_APP, TYPE_URL); + switch (item_type) { + ENUM_CASE(sync_pb::AppListSpecifics, TYPE_APP); + ENUM_CASE(sync_pb::AppListSpecifics, TYPE_REMOVE_DEFAULT_APP); + ENUM_CASE(sync_pb::AppListSpecifics, TYPE_FOLDER); + ENUM_CASE(sync_pb::AppListSpecifics, TYPE_URL); + } + NOTREACHED(); + return ""; +} + const char* GetBrowserTypeString( sync_pb::SessionWindow::BrowserType browser_type) { ASSERT_ENUM_BOUNDS(sync_pb::SessionWindow, BrowserType, diff --git a/sync/protocol/proto_enum_conversions.h b/sync/protocol/proto_enum_conversions.h index b6d84fa..6812cb7 100644 --- a/sync/protocol/proto_enum_conversions.h +++ b/sync/protocol/proto_enum_conversions.h @@ -8,6 +8,7 @@ // Keep this file in sync with the .proto files in this directory. #include "sync/base/sync_export.h" +#include "sync/protocol/app_list_specifics.pb.h" #include "sync/protocol/client_debug_info.pb.h" #include "sync/protocol/session_specifics.pb.h" #include "sync/protocol/sync.pb.h" @@ -20,6 +21,9 @@ namespace syncer { // The returned strings (which don't have to be freed) are in ASCII. // The result of passing in an invalid enum value is undefined. +SYNC_EXPORT_PRIVATE const char* GetAppListItemTypeString( + sync_pb::AppListSpecifics::AppListItemType item_type); + SYNC_EXPORT_PRIVATE const char* GetBrowserTypeString( sync_pb::SessionWindow::BrowserType browser_type); diff --git a/sync/protocol/proto_enum_conversions_unittest.cc b/sync/protocol/proto_enum_conversions_unittest.cc index f66d379..7b323a5 100644 --- a/sync/protocol/proto_enum_conversions_unittest.cc +++ b/sync/protocol/proto_enum_conversions_unittest.cc @@ -25,6 +25,13 @@ void TestEnumStringFunction(const char* (*enum_string_fn)(T), } } +TEST_F(ProtoEnumConversionsTest, GetAppListItemTypeString) { + TestEnumStringFunction( + GetAppListItemTypeString, + sync_pb::AppListSpecifics::AppListItemType_MIN, + sync_pb::AppListSpecifics::AppListItemType_MAX); +} + TEST_F(ProtoEnumConversionsTest, GetBrowserTypeString) { TestEnumStringFunction( GetBrowserTypeString, diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc index cdb999e..5c8a7ab 100644 --- a/sync/protocol/proto_value_conversions.cc +++ b/sync/protocol/proto_value_conversions.cc @@ -14,6 +14,7 @@ #include "base/strings/string_number_conversions.h" #include "base/values.h" #include "sync/internal_api/public/base/unique_position.h" +#include "sync/protocol/app_list_specifics.pb.h" #include "sync/protocol/app_notification_specifics.pb.h" #include "sync/protocol/app_setting_specifics.pb.h" #include "sync/protocol/app_specifics.pb.h" @@ -347,6 +348,19 @@ base::DictionaryValue* CoalescedNotificationToValue( return value; } +base::DictionaryValue* AppListSpecificsToValue( + const sync_pb::AppListSpecifics& proto) { + base::DictionaryValue* value = new base::DictionaryValue(); + SET_STR(item_id); + SET_ENUM(item_type, GetAppListItemTypeString); + SET_STR(item_name); + SET_STR(parent_id); + SET_STR(page_ordinal); + SET_STR(item_ordinal); + + return value; +} + base::DictionaryValue* AppNotificationToValue( const sync_pb::AppNotification& proto) { base::DictionaryValue* value = new base::DictionaryValue(); @@ -572,6 +586,7 @@ base::DictionaryValue* NigoriSpecificsToValue( SET_BOOL(encrypt_search_engines); SET_BOOL(encrypt_dictionary); SET_BOOL(encrypt_articles); + SET_BOOL(encrypt_app_list); SET_BOOL(encrypt_everything); SET_BOOL(sync_tab_favicons); SET_ENUM(passphrase_type, PassphraseTypeString); @@ -694,6 +709,7 @@ base::DictionaryValue* EntitySpecificsToValue( const sync_pb::EntitySpecifics& specifics) { base::DictionaryValue* value = new base::DictionaryValue(); SET_FIELD(app, AppSpecificsToValue); + SET_FIELD(app_list, AppListSpecificsToValue); SET_FIELD(app_notification, AppNotificationToValue); SET_FIELD(app_setting, AppSettingSpecificsToValue); SET_FIELD(article, ArticleSpecificsToValue); diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h index ee40e2b..9bf45e32 100644 --- a/sync/protocol/proto_value_conversions.h +++ b/sync/protocol/proto_value_conversions.h @@ -14,6 +14,7 @@ class DictionaryValue; } namespace sync_pb { +class AppListSpecifics; class AppNotification; class AppNotificationSettings; class AppSettingSpecifics; @@ -91,6 +92,10 @@ namespace syncer { SYNC_EXPORT_PRIVATE base::DictionaryValue* EncryptedDataToValue( const sync_pb::EncryptedData& encrypted_data); +// Sub-protocol of AppListSpecifics. +SYNC_EXPORT_PRIVATE base::DictionaryValue* AppListSpecificsToValue( + const sync_pb::AppListSpecifics& proto); + // Sub-protocol of AppSpecifics. SYNC_EXPORT_PRIVATE base::DictionaryValue* AppSettingsToValue( const sync_pb::AppNotificationSettings& app_notification_settings); diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc index 86eee98..1366dd5 100644 --- a/sync/protocol/proto_value_conversions_unittest.cc +++ b/sync/protocol/proto_value_conversions_unittest.cc @@ -53,7 +53,7 @@ TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { // If this number changes, that means we added or removed a data // type. Don't forget to add a unit test for {New // type}SpecificsToValue below. - EXPECT_EQ(29, MODEL_TYPE_COUNT); + EXPECT_EQ(30, MODEL_TYPE_COUNT); // We'd also like to check if we changed any field in our messages. // However, that's hard to do: sizeof could work, but it's @@ -93,6 +93,10 @@ TEST_F(ProtoValueConversionsTest, PasswordSpecificsData) { EXPECT_EQ("<redacted>", password_value); } +TEST_F(ProtoValueConversionsTest, AppListSpecificsToValue) { + TestSpecificsToValue(AppListSpecificsToValue); +} + TEST_F(ProtoValueConversionsTest, AppNotificationToValue) { TestSpecificsToValue(AppNotificationToValue); } @@ -255,6 +259,7 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { #define SET_FIELD(key) (void)specifics.mutable_##key() SET_FIELD(app); + SET_FIELD(app_list); SET_FIELD(app_notification); SET_FIELD(app_setting); SET_FIELD(article); diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto index 5b0c175..ecaceef 100644 --- a/sync/protocol/sync.proto +++ b/sync/protocol/sync.proto @@ -14,6 +14,7 @@ option retain_unknown_fields = true; package sync_pb; +import "app_list_specifics.proto"; import "app_notification_specifics.proto"; import "app_setting_specifics.proto"; import "app_specifics.proto"; @@ -120,6 +121,7 @@ message EntitySpecifics { optional ManagedUserSettingSpecifics managed_user_setting = 186662; optional ManagedUserSpecifics managed_user = 194582; optional ArticleSpecifics article = 223759; + optional AppListSpecifics app_list = 229170; } message SyncEntity { diff --git a/sync/sync_proto.gypi b/sync/sync_proto.gypi index 4b90525..968ee9dd 100644 --- a/sync/sync_proto.gypi +++ b/sync/sync_proto.gypi @@ -13,6 +13,7 @@ 'protocol/app_notification_specifics.proto', 'protocol/app_setting_specifics.proto', 'protocol/app_specifics.proto', + 'protocol/app_list_specifics.proto', 'protocol/article_specifics.proto', 'protocol/autofill_specifics.proto', 'protocol/bookmark_specifics.proto', diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc index aac057fd..fa33118 100644 --- a/sync/syncable/model_type.cc +++ b/sync/syncable/model_type.cc @@ -68,6 +68,9 @@ void AddDefaultFieldValue(ModelType datatype, case APPS: specifics->mutable_app(); break; + case APP_LIST: + specifics->mutable_app_list(); + break; case APP_SETTINGS: specifics->mutable_app_setting(); break; @@ -167,6 +170,9 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) { case APPS: return sync_pb::EntitySpecifics::kAppFieldNumber; break; + case APP_LIST: + return sync_pb::EntitySpecifics::kAppListFieldNumber; + break; case APP_SETTINGS: return sync_pb::EntitySpecifics::kAppSettingFieldNumber; break; @@ -276,6 +282,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) { if (specifics.has_app()) return APPS; + if (specifics.has_app_list()) + return APP_LIST; + if (specifics.has_search_engine()) return SEARCH_ENGINES; @@ -461,6 +470,8 @@ const char* ModelTypeToString(ModelType model_type) { return "Sessions"; case APPS: return "Apps"; + case APP_LIST: + return "App List"; case AUTOFILL_PROFILE: return "Autofill Profiles"; case APP_SETTINGS: @@ -564,6 +575,8 @@ int ModelTypeToHistogramInt(ModelType model_type) { return 27; case ARTICLES: return 28; + case APP_LIST: + return 29; // Silence a compiler warning. case MODEL_TYPE_COUNT: return 0; @@ -623,6 +636,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) { return SESSIONS; else if (model_type_string == "Apps") return APPS; + else if (model_type_string == "App List") + return APP_LIST; else if (model_type_string == "App settings") return APP_SETTINGS; else if (model_type_string == "Extension settings") @@ -715,6 +730,8 @@ std::string ModelTypeToRootTag(ModelType type) { return "google_chrome_sessions"; case APPS: return "google_chrome_apps"; + case APP_LIST: + return "google_chrome_app_list"; case AUTOFILL_PROFILE: return "google_chrome_autofill_profiles"; case APP_SETTINGS: @@ -769,6 +786,7 @@ const char kExtensionSettingNotificationType[] = "EXTENSION_SETTING"; const char kNigoriNotificationType[] = "NIGORI"; const char kAppSettingNotificationType[] = "APP_SETTING"; const char kAppNotificationType[] = "APP"; +const char kAppListNotificationType[] = "APP_LIST"; const char kSearchEngineNotificationType[] = "SEARCH_ENGINE"; const char kSessionNotificationType[] = "SESSION"; const char kAutofillProfileNotificationType[] = "AUTOFILL_PROFILE"; @@ -820,6 +838,9 @@ bool RealModelTypeToNotificationType(ModelType model_type, case APPS: *notification_type = kAppNotificationType; return true; + case APP_LIST: + *notification_type = kAppListNotificationType; + return true; case SEARCH_ENGINES: *notification_type = kSearchEngineNotificationType; return true; @@ -904,6 +925,9 @@ bool NotificationTypeToRealModelType(const std::string& notification_type, } else if (notification_type == kAppNotificationType) { *model_type = APPS; return true; + } else if (notification_type == kAppListNotificationType) { + *model_type = APP_LIST; + return true; } else if (notification_type == kSearchEngineNotificationType) { *model_type = SEARCH_ENGINES; return true; diff --git a/sync/syncable/nigori_util.cc b/sync/syncable/nigori_util.cc index fbdd9a5..107a68f 100644 --- a/sync/syncable/nigori_util.cc +++ b/sync/syncable/nigori_util.cc @@ -242,7 +242,7 @@ void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, bool encrypt_everything, sync_pb::NigoriSpecifics* nigori) { nigori->set_encrypt_everything(encrypt_everything); - COMPILE_ASSERT(29 == MODEL_TYPE_COUNT, UpdateEncryptedTypes); + COMPILE_ASSERT(30 == MODEL_TYPE_COUNT, UpdateEncryptedTypes); nigori->set_encrypt_bookmarks( encrypted_types.Has(BOOKMARKS)); nigori->set_encrypt_preferences( @@ -269,6 +269,7 @@ void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, nigori->set_encrypt_favicon_images(encrypted_types.Has(FAVICON_IMAGES)); nigori->set_encrypt_favicon_tracking(encrypted_types.Has(FAVICON_TRACKING)); nigori->set_encrypt_articles(encrypted_types.Has(ARTICLES)); + nigori->set_encrypt_app_list(encrypted_types.Has(APP_LIST)); } ModelTypeSet GetEncryptedTypesFromNigori( @@ -277,7 +278,7 @@ ModelTypeSet GetEncryptedTypesFromNigori( return ModelTypeSet::All(); ModelTypeSet encrypted_types; - COMPILE_ASSERT(29 == MODEL_TYPE_COUNT, UpdateEncryptedTypes); + COMPILE_ASSERT(30 == MODEL_TYPE_COUNT, UpdateEncryptedTypes); if (nigori.encrypt_bookmarks()) encrypted_types.Put(BOOKMARKS); if (nigori.encrypt_preferences()) @@ -312,6 +313,8 @@ ModelTypeSet GetEncryptedTypesFromNigori( encrypted_types.Put(FAVICON_TRACKING); if (nigori.encrypt_articles()) encrypted_types.Put(ARTICLES); + if (nigori.encrypt_app_list()) + encrypted_types.Put(APP_LIST); return encrypted_types; } diff --git a/sync/tools/testserver/chromiumsync.py b/sync/tools/testserver/chromiumsync.py index 8b48113..496cb6a 100644 --- a/sync/tools/testserver/chromiumsync.py +++ b/sync/tools/testserver/chromiumsync.py @@ -23,6 +23,7 @@ import time import urlparse import uuid +import app_list_specifics_pb2 import app_notification_specifics_pb2 import app_setting_specifics_pb2 import app_specifics_pb2 @@ -60,6 +61,7 @@ import typed_url_specifics_pb2 ALL_TYPES = ( TOP_LEVEL, # The type of the 'Google Chrome' folder. APPS, + APP_LIST, APP_NOTIFICATION, APP_SETTINGS, ARTICLE, @@ -84,7 +86,7 @@ ALL_TYPES = ( TYPED_URL, EXTENSION_SETTINGS, FAVICON_IMAGES, - FAVICON_TRACKING) = range(27) + FAVICON_TRACKING) = range(28) # An enumeration on the frequency at which the server should send errors # to the client. This would be specified by the url that triggers the error. @@ -101,6 +103,7 @@ TOP_LEVEL_FOLDER_TAG = 'google_chrome' # to that datatype. Note that TOP_LEVEL has no such token. SYNC_TYPE_FIELDS = sync_pb2.EntitySpecifics.DESCRIPTOR.fields_by_name SYNC_TYPE_TO_DESCRIPTOR = { + APP_LIST: SYNC_TYPE_FIELDS['app_list'], APP_NOTIFICATION: SYNC_TYPE_FIELDS['app_notification'], APP_SETTINGS: SYNC_TYPE_FIELDS['app_setting'], APPS: SYNC_TYPE_FIELDS['app'], @@ -476,6 +479,8 @@ class SyncDataModel(object): _PERMANENT_ITEM_SPECS = [ PermanentItem('google_chrome_apps', name='Apps', parent_tag=ROOT_ID, sync_type=APPS), + PermanentItem('google_chrome_app_list', name='App List', + parent_tag=ROOT_ID, sync_type=APP_LIST), PermanentItem('google_chrome_app_notifications', name='App Notifications', parent_tag=ROOT_ID, sync_type=APP_NOTIFICATION), PermanentItem('google_chrome_app_settings', diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h index 01a2ba0..e3a8d6f 100644 --- a/sync/util/data_type_histogram.h +++ b/sync/util/data_type_histogram.h @@ -72,6 +72,9 @@ case ::syncer::APPS: \ PER_DATA_TYPE_MACRO("Apps"); \ break; \ + case ::syncer::APP_LIST: \ + PER_DATA_TYPE_MACRO("AppList"); \ + break; \ case ::syncer::APP_SETTINGS: \ PER_DATA_TYPE_MACRO("AppSettings"); \ break; \ |