diff options
author | Nicolas Zea <zea@chromium.org> | 2014-12-11 11:21:28 -0800 |
---|---|---|
committer | Nicolas Zea <zea@chromium.org> | 2014-12-11 19:26:42 +0000 |
commit | 92a506ded2abce9f58c75232da7ab48c83652449 (patch) | |
tree | 183c2bdbe43de38e93e5296b4ac0f0582e9cf589 | |
parent | 62e915a1c0db1f62e9e4687d3670d5423a9ef720 (diff) | |
download | chromium_src-92a506ded2abce9f58c75232da7ab48c83652449.zip chromium_src-92a506ded2abce9f58c75232da7ab48c83652449.tar.gz chromium_src-92a506ded2abce9f58c75232da7ab48c83652449.tar.bz2 |
Delete deprecated synced notifications code
Synced notifications no longer have native code. Delete the remaining code
(which has not been used for serveral milestones).
BUG=439577
R=kalman@chromium.org, petewil@chromium.org, stanisc@chromium.org
TBR=dewittj@chromium.org
Review URL: https://codereview.chromium.org/780363003
Cr-Commit-Position: refs/heads/master@{#307946}
45 files changed, 16 insertions, 2203 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 084efb0..01b04b0 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6361,12 +6361,6 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAGS_ENABLE_SUPERVISED_USER_SAFESITES_DESCRIPTION" desc="Description for the flag to enable the supervised user SafeSites feature."> Enable SafeSites filtering for supervised users. </message> - <message name="IDS_FLAGS_ENABLE_SYNCED_NOTIFICATIONS_NAME" desc="Name of the flag to enable synced notifications."> - Enable Synced Notifications - </message> - <message name="IDS_FLAGS_ENABLE_SYNCED_NOTIFICATIONS_DESCRIPTION" desc="Description for the flag to enable synced notifications."> - Enable experimental Synchronized Notifications. - </message> <message name="IDS_FLAGS_ENABLE_SYNC_APP_LIST_NAME" desc="Name of the flag to enable syncing the app list."> Enable App Launcher sync </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index be60a68..f109d99 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1124,14 +1124,6 @@ const Experiment kExperiments[] = { ENABLE_DISABLE_VALUE_TYPE(switches::kEnableSupervisedUserSafeSites, switches::kDisableSupervisedUserSafeSites) }, - { - "enable-sync-synced-notifications", - IDS_FLAGS_ENABLE_SYNCED_NOTIFICATIONS_NAME, - IDS_FLAGS_ENABLE_SYNCED_NOTIFICATIONS_DESCRIPTION, - kOsDesktop, - ENABLE_DISABLE_VALUE_TYPE(switches::kEnableSyncSyncedNotifications, - switches::kDisableSyncSyncedNotifications) - }, #if defined(ENABLE_APP_LIST) { "enable-sync-app-list", diff --git a/chrome/browser/extensions/api/synced_notifications_private/OWNERS b/chrome/browser/extensions/api/synced_notifications_private/OWNERS deleted file mode 100644 index 2c86af4..0000000 --- a/chrome/browser/extensions/api/synced_notifications_private/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -dewittj@chromium.org -dimich@chromium.org -petewil@chromium.org diff --git a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_private_api.cc b/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_private_api.cc deleted file mode 100644 index 2c6e9be..0000000 --- a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_private_api.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2014 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/extensions/api/synced_notifications_private/synced_notifications_private_api.h" - -#include "chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.h" -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" -#include "chrome/browser/profiles/profile.h" - -namespace extensions { -namespace api { - -namespace { -const char kSyncNotRunningError[] = "Sync Not Running"; -const char kDataConversionError[] = "Data Conversion Error"; -} // namespace - -SyncedNotificationsPrivateGetInitialDataFunction:: - SyncedNotificationsPrivateGetInitialDataFunction() { -} - -SyncedNotificationsPrivateGetInitialDataFunction:: - ~SyncedNotificationsPrivateGetInitialDataFunction() { -} - -ExtensionFunction::ResponseAction -SyncedNotificationsPrivateGetInitialDataFunction::Run() { - scoped_ptr<api::synced_notifications_private::GetInitialData::Params> params( - api::synced_notifications_private::GetInitialData::Params::Create( - *args_)); - EXTENSION_FUNCTION_VALIDATE(params.get()); - - notifier::ChromeNotifierService* notifier_service = - notifier::ChromeNotifierServiceFactory::GetForProfile( - Profile::FromBrowserContext(browser_context()), - Profile::IMPLICIT_ACCESS); - if (!notifier_service || - !notifier_service->GetSyncedNotificationsShim()->IsSyncReady()) { - return RespondNow(Error(kSyncNotRunningError)); - } - - std::vector<linked_ptr<synced_notifications_private::SyncData> > - sync_data_list; - if (!notifier_service->GetSyncedNotificationsShim()->GetInitialData( - params->type, &sync_data_list)) { - return RespondNow(Error(kSyncNotRunningError)); - } - return RespondNow(ArgumentList( - synced_notifications_private::GetInitialData::Results::Create( - sync_data_list))); -} - -SyncedNotificationsPrivateUpdateNotificationFunction:: - SyncedNotificationsPrivateUpdateNotificationFunction() { -} - -SyncedNotificationsPrivateUpdateNotificationFunction:: - ~SyncedNotificationsPrivateUpdateNotificationFunction() { -} - -ExtensionFunction::ResponseAction -SyncedNotificationsPrivateUpdateNotificationFunction::Run() { - scoped_ptr<api::synced_notifications_private::UpdateNotification::Params> - params( - api::synced_notifications_private::UpdateNotification::Params::Create( - *args_)); - EXTENSION_FUNCTION_VALIDATE(params.get()); - - notifier::ChromeNotifierService* notifier_service = - notifier::ChromeNotifierServiceFactory::GetForProfile( - Profile::FromBrowserContext(browser_context()), - Profile::IMPLICIT_ACCESS); - if (!notifier_service || - !notifier_service->GetSyncedNotificationsShim()->IsSyncReady()) { - return RespondNow(Error(kSyncNotRunningError)); - } - - if (!notifier_service->GetSyncedNotificationsShim()->UpdateNotification( - params->changed_notification)) { - return RespondNow(Error(kDataConversionError)); - } - - return RespondNow(NoArguments()); -} - -SyncedNotificationsPrivateSetRenderContextFunction:: - SyncedNotificationsPrivateSetRenderContextFunction() { -} - -SyncedNotificationsPrivateSetRenderContextFunction:: - ~SyncedNotificationsPrivateSetRenderContextFunction() { -} - -ExtensionFunction::ResponseAction -SyncedNotificationsPrivateSetRenderContextFunction::Run() { - scoped_ptr<api::synced_notifications_private::SetRenderContext::Params> - params( - api::synced_notifications_private::SetRenderContext::Params::Create( - *args_)); - EXTENSION_FUNCTION_VALIDATE(params.get()); - - notifier::ChromeNotifierService* notifier_service = - notifier::ChromeNotifierServiceFactory::GetForProfile( - Profile::FromBrowserContext(browser_context()), - Profile::IMPLICIT_ACCESS); - if (!notifier_service || - !notifier_service->GetSyncedNotificationsShim()->IsSyncReady()) { - return RespondNow(Error(kSyncNotRunningError)); - } - - if (!notifier_service->GetSyncedNotificationsShim()->SetRenderContext( - params->refresh, - params->data_type_context)) { - return RespondNow(Error(kDataConversionError)); - } - return RespondNow(NoArguments()); -} - -} // namespace api -} // namespace extensions diff --git a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_private_api.h b/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_private_api.h deleted file mode 100644 index 0e3323d..0000000 --- a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_private_api.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2014 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_EXTENSIONS_API_SYNCED_NOTIFICATIONS_PRIVATE_SYNCED_NOTIFICATIONS_PRIVATE_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_SYNCED_NOTIFICATIONS_PRIVATE_SYNCED_NOTIFICATIONS_PRIVATE_API_H_ - -#include "chrome/browser/extensions/chrome_extension_function.h" -#include "chrome/common/extensions/api/synced_notifications_private.h" - -namespace extensions { -namespace api { - -class SyncedNotificationsPrivateGetInitialDataFunction - : public UIThreadExtensionFunction { - public: - SyncedNotificationsPrivateGetInitialDataFunction(); - DECLARE_EXTENSION_FUNCTION("syncedNotificationsPrivate.getInitialData", - SYNCEDNOTIFICATIONSPRIVATE_GETINITIALDATA); - - protected: - ~SyncedNotificationsPrivateGetInitialDataFunction() override; - ResponseAction Run() override; - - private: - DISALLOW_COPY_AND_ASSIGN(SyncedNotificationsPrivateGetInitialDataFunction); -}; - -class SyncedNotificationsPrivateUpdateNotificationFunction - : public UIThreadExtensionFunction { - public: - SyncedNotificationsPrivateUpdateNotificationFunction(); - DECLARE_EXTENSION_FUNCTION("syncedNotificationsPrivate.updateNotification", - SYNCEDNOTIFICATIONSPRIVATE_UPDATENOTIFICATION); - - protected: - ~SyncedNotificationsPrivateUpdateNotificationFunction() override; - ResponseAction Run() override; - - private: - DISALLOW_COPY_AND_ASSIGN( - SyncedNotificationsPrivateUpdateNotificationFunction); -}; - -class SyncedNotificationsPrivateSetRenderContextFunction - : public UIThreadExtensionFunction { - public: - SyncedNotificationsPrivateSetRenderContextFunction(); - DECLARE_EXTENSION_FUNCTION("syncedNotificationsPrivate.setRenderContext", - SYNCEDNOTIFICATIONSPRIVATE_SETRENDERCONTEXT); - - protected: - ~SyncedNotificationsPrivateSetRenderContextFunction() override; - ResponseAction Run() override; - - private: - DISALLOW_COPY_AND_ASSIGN(SyncedNotificationsPrivateSetRenderContextFunction); -}; - -} // namespace api -} // namespace extensions - -#endif // CHROME_BROWSER_EXTENSIONS_API_SYNCED_NOTIFICATIONS_PRIVATE_SYNCED_NOTIFICATIONS_PRIVATE_API_H_ diff --git a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.cc b/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.cc deleted file mode 100644 index 21361f1..0000000 --- a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.cc +++ /dev/null @@ -1,256 +0,0 @@ -// Copyright 2014 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/extensions/api/synced_notifications_private/synced_notifications_shim.h" - -#include "extensions/browser/event_router.h" -#include "sync/api/sync_change.h" -#include "sync/api/sync_data.h" -#include "sync/api/sync_error_factory.h" -#include "sync/protocol/sync.pb.h" - -using namespace extensions; -using namespace extensions::api; - -namespace { - -synced_notifications_private::ChangeType SyncerChangeTypeToJS( - syncer::SyncChange::SyncChangeType change_type) { - switch (change_type) { - case syncer::SyncChange::ACTION_UPDATE: - return synced_notifications_private::CHANGE_TYPE_UPDATED; - case syncer::SyncChange::ACTION_DELETE: - return synced_notifications_private::CHANGE_TYPE_DELETED; - case syncer::SyncChange::ACTION_ADD: - return synced_notifications_private::CHANGE_TYPE_ADDED; - case syncer::SyncChange::ACTION_INVALID: - return synced_notifications_private::CHANGE_TYPE_NONE; - } - NOTREACHED(); - return synced_notifications_private::CHANGE_TYPE_NONE; -} - -syncer::ModelType JSDataTypeToSyncer( - synced_notifications_private::SyncDataType data_type) { - switch (data_type) { - case synced_notifications_private::SYNC_DATA_TYPE_APP_INFO: - return syncer::SYNCED_NOTIFICATION_APP_INFO; - case synced_notifications_private::SYNC_DATA_TYPE_SYNCED_NOTIFICATION: - return syncer::SYNCED_NOTIFICATIONS; - default: - NOTREACHED(); - return syncer::UNSPECIFIED; - } -} - -synced_notifications_private::SyncDataType SyncerModelTypeToJS( - syncer::ModelType model_type) { - switch (model_type) { - case syncer::SYNCED_NOTIFICATION_APP_INFO: - return synced_notifications_private::SYNC_DATA_TYPE_APP_INFO; - case syncer::SYNCED_NOTIFICATIONS: - return synced_notifications_private::SYNC_DATA_TYPE_SYNCED_NOTIFICATION; - default: - NOTREACHED(); - return synced_notifications_private::SYNC_DATA_TYPE_NONE; - } -} - -bool BuildNewSyncUpdate( - const tracked_objects::Location& from_here, - const std::string& changed_notification, - syncer::SyncChange* sync_change) { - sync_pb::EntitySpecifics specifics; - sync_pb::SyncedNotificationSpecifics* notification_specifics = - specifics.mutable_synced_notification(); - if (!notification_specifics->ParseFromArray( - changed_notification.c_str(), changed_notification.size())) { - return false; - } - - // TODO(synced notifications): pass the tag via the JS API. - const std::string& tag = - notification_specifics->coalesced_notification().key(); - syncer::SyncData sync_data = - syncer::SyncData::CreateLocalData(tag, tag, specifics); - *sync_change = syncer::SyncChange( - from_here, syncer::SyncChange::ACTION_UPDATE, sync_data); - return true; -} - -linked_ptr<synced_notifications_private::SyncChange> BuildNewJSSyncChange( - const syncer::SyncChange& change) { - linked_ptr<synced_notifications_private::SyncChange> js_change = - make_linked_ptr<synced_notifications_private::SyncChange>( - new synced_notifications_private::SyncChange()); - js_change->change_type = SyncerChangeTypeToJS(change.change_type()); - js_change->data.datatype = - SyncerModelTypeToJS(change.sync_data().GetDataType()); - if (change.sync_data().GetDataType() == syncer::SYNCED_NOTIFICATIONS) { - const sync_pb::SyncedNotificationSpecifics& specifics = - change.sync_data().GetSpecifics().synced_notification(); - js_change->data.data_item = specifics.SerializeAsString(); - } else { - DCHECK_EQ(change.sync_data().GetDataType(), - syncer::SYNCED_NOTIFICATION_APP_INFO); - const sync_pb::SyncedNotificationAppInfoSpecifics& specifics = - change.sync_data().GetSpecifics().synced_notification_app_info(); - js_change->data.data_item = specifics.SerializeAsString(); - } - return js_change; -} - -bool PopulateJSDataListFromSync( - const syncer::SyncDataList& sync_data_list, - std::vector<linked_ptr<synced_notifications_private::SyncData> >* - js_data_list) { - for (size_t i = 0; i < sync_data_list.size(); ++i) { - linked_ptr<synced_notifications_private::SyncData> js_data( - new synced_notifications_private::SyncData()); - syncer::ModelType data_type = sync_data_list[i].GetDataType(); - js_data->datatype = SyncerModelTypeToJS(data_type); - if (data_type == syncer::SYNCED_NOTIFICATIONS) { - const sync_pb::SyncedNotificationSpecifics& specifics = - sync_data_list[i].GetSpecifics().synced_notification(); - js_data->data_item = specifics.SerializeAsString(); - } else if (data_type == syncer::SYNCED_NOTIFICATION_APP_INFO) { - const sync_pb::SyncedNotificationAppInfoSpecifics& specifics = - sync_data_list[i].GetSpecifics().synced_notification_app_info(); - js_data->data_item = specifics.SerializeAsString(); - } else { - return false; - } - js_data_list->push_back(js_data); - } - return true; -} - -} // namespace - -SyncedNotificationsShim::SyncedNotificationsShim( - const EventLauncher& event_launcher, - const base::Closure& refresh_request) - : event_launcher_(event_launcher), - refresh_request_(refresh_request) { -} - -SyncedNotificationsShim::~SyncedNotificationsShim() { -} - -syncer::SyncMergeResult SyncedNotificationsShim::MergeDataAndStartSyncing( - syncer::ModelType type, - const syncer::SyncDataList& initial_sync_data, - scoped_ptr<syncer::SyncChangeProcessor> sync_processor, - scoped_ptr<syncer::SyncErrorFactory> error_handler) { - if (type == syncer::SYNCED_NOTIFICATIONS) - notifications_change_processor_ = sync_processor.Pass(); - else if (type == syncer::SYNCED_NOTIFICATION_APP_INFO) - app_info_change_processor_ = sync_processor.Pass(); - else - NOTREACHED(); - - // Only wake up the extension if both sync data types are ready. - if (notifications_change_processor_ && app_info_change_processor_) { - scoped_ptr<Event> event(new Event( - synced_notifications_private::OnSyncStartup::kEventName, - synced_notifications_private::OnSyncStartup::Create())); - event_launcher_.Run(event.Pass()); - } - - return syncer::SyncMergeResult(type); -} - -void SyncedNotificationsShim::StopSyncing(syncer::ModelType type) { - if (type == syncer::SYNCED_NOTIFICATIONS) - notifications_change_processor_.reset(); - else if (type == syncer::SYNCED_NOTIFICATION_APP_INFO) - app_info_change_processor_.reset(); - else - NOTREACHED(); -} - -syncer::SyncError SyncedNotificationsShim::ProcessSyncChanges( - const tracked_objects::Location& from_here, - const syncer::SyncChangeList& changes) { - std::vector<linked_ptr<synced_notifications_private::SyncChange> > js_changes; - for (size_t i = 0; i < changes.size(); ++i) - js_changes.push_back(BuildNewJSSyncChange(changes[i])); - - scoped_ptr<base::ListValue> args( - synced_notifications_private::OnDataChanges::Create(js_changes)); - scoped_ptr<Event> event(new Event( - synced_notifications_private::OnDataChanges::kEventName, args.Pass())); - event_launcher_.Run(event.Pass()); - return syncer::SyncError(); -} - -syncer::SyncDataList SyncedNotificationsShim::GetAllSyncData( - syncer::ModelType type) const { - NOTIMPLEMENTED(); - return syncer::SyncDataList(); -} - -bool SyncedNotificationsShim::GetInitialData( - synced_notifications_private::SyncDataType data_type, - std::vector<linked_ptr<synced_notifications_private::SyncData> >* - js_data_list) const { - if (!IsSyncReady()) - return false; - - syncer::SyncDataList sync_data_list; - if (JSDataTypeToSyncer(data_type) == syncer::SYNCED_NOTIFICATIONS) { - sync_data_list = notifications_change_processor_->GetAllSyncData( - syncer::SYNCED_NOTIFICATIONS); - if (PopulateJSDataListFromSync(sync_data_list, js_data_list)) - return true; - } else if (JSDataTypeToSyncer(data_type) == - syncer::SYNCED_NOTIFICATION_APP_INFO) { - sync_data_list = app_info_change_processor_->GetAllSyncData( - syncer::SYNCED_NOTIFICATION_APP_INFO); - if (PopulateJSDataListFromSync(sync_data_list, js_data_list)) - return true; - } - return false; -} - -bool SyncedNotificationsShim::UpdateNotification( - const std::string& changed_notification) { - if (!IsSyncReady()) - return false; - - syncer::SyncChange sync_change; - if (!BuildNewSyncUpdate(FROM_HERE, changed_notification, &sync_change)) - return false; - syncer::SyncError error = notifications_change_processor_->ProcessSyncChanges( - FROM_HERE, - syncer::SyncChangeList(1, sync_change)); - return !error.IsSet(); -} - -bool SyncedNotificationsShim::SetRenderContext( - synced_notifications_private::RefreshRequest refresh_request, - const std::string& new_context) { - if (!IsSyncReady()) - return false; - - syncer::SyncChangeProcessor::ContextRefreshStatus sync_refresh_status = - refresh_request == - synced_notifications_private::REFRESH_REQUEST_REFRESH_NEEDED - ? syncer::SyncChangeProcessor::REFRESH_NEEDED - : syncer::SyncChangeProcessor::NO_REFRESH; - syncer::SyncError error = - notifications_change_processor_->UpdateDataTypeContext( - syncer::SYNCED_NOTIFICATIONS, sync_refresh_status, new_context); - - if (sync_refresh_status == syncer::SyncChangeProcessor::REFRESH_NEEDED && - !refresh_request_.is_null()) { - refresh_request_.Run(); - } - - return !error.IsSet(); -} - -bool SyncedNotificationsShim::IsSyncReady() const { - return notifications_change_processor_ && app_info_change_processor_; -} diff --git a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.h b/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.h deleted file mode 100644 index 7878c79..0000000 --- a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2014 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_EXTENSIONS_API_SYNCED_NOTIFICATIONS_PRIVATE_SYNCED_NOTIFICATIONS_SHIM_H_ -#define CHROME_BROWSER_EXTENSIONS_API_SYNCED_NOTIFICATIONS_PRIVATE_SYNCED_NOTIFICATIONS_SHIM_H_ - -#include <string> - -#include "base/callback.h" -#include "base/memory/scoped_ptr.h" -#include "chrome/common/extensions/api/synced_notifications_private.h" -#include "sync/api/syncable_service.h" - -namespace extensions { -struct Event; -} - -// Shim for SYNCED_NOTIFICATIONS and SYNCED_NOTIFICATIONS_APP_INFO datatypes -// to interface with their extension backed sync code. -class SyncedNotificationsShim : public syncer::SyncableService { - public: - // Callback for firing extension events. - typedef base::Callback<void(scoped_ptr<extensions::Event>)> EventLauncher; - - explicit SyncedNotificationsShim(const EventLauncher& event_launcher, - const base::Closure& refresh_request); - ~SyncedNotificationsShim() override; - - // SyncableService interface. - syncer::SyncMergeResult MergeDataAndStartSyncing( - syncer::ModelType type, - const syncer::SyncDataList& initial_sync_data, - scoped_ptr<syncer::SyncChangeProcessor> sync_processor, - scoped_ptr<syncer::SyncErrorFactory> error_handler) override; - void StopSyncing(syncer::ModelType type) override; - syncer::SyncError ProcessSyncChanges( - const tracked_objects::Location& from_here, - const syncer::SyncChangeList& change_list) override; - syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; - - // JS interface methods (see synced_notifications_private.h). - bool GetInitialData( - extensions::api::synced_notifications_private::SyncDataType data_type, - std::vector< - linked_ptr<extensions::api::synced_notifications_private::SyncData> >* - js_data_list) const; - bool UpdateNotification(const std::string& changed_notification); - bool SetRenderContext( - extensions::api::synced_notifications_private::RefreshRequest - refresh_status, - const std::string& new_context); - - // Returns whether both sync notification datatypes are up and running. - bool IsSyncReady() const; - - private: - // Callback to trigger firing extension events. - EventLauncher event_launcher_; - - // Callback to trigger synced notification refresh. - base::Closure refresh_request_; - - // The sync change processors, initialized via MergeDataAndStartSyncing. - scoped_ptr<syncer::SyncChangeProcessor> notifications_change_processor_; - scoped_ptr<syncer::SyncChangeProcessor> app_info_change_processor_; - - DISALLOW_COPY_AND_ASSIGN(SyncedNotificationsShim); -}; - -#endif // CHROME_BROWSER_EXTENSIONS_API_SYNCED_NOTIFICATIONS_PRIVATE_SYNCED_NOTIFICATIONS_SHIM_H_ diff --git a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim_unittest.cc b/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim_unittest.cc deleted file mode 100644 index d849f3b..0000000 --- a/chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim_unittest.cc +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright 2014 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/extensions/api/synced_notifications_private/synced_notifications_shim.h" - -#include "base/json/json_writer.h" -#include "extensions/browser/event_router.h" -#include "sync/api/fake_sync_change_processor.h" -#include "sync/api/sync_change.h" -#include "sync/api/sync_error_factory.h" -#include "sync/protocol/sync.pb.h" -#include "testing/gtest/include/gtest/gtest.h" - -using namespace extensions; -using namespace extensions::api; - -namespace { - -// Builds a SyncData for the specified |type| based on |key|. -syncer::SyncData BuildData(syncer::ModelType type, const std::string& key) { - sync_pb::EntitySpecifics specifics; - if (type == syncer::SYNCED_NOTIFICATIONS) { - specifics.mutable_synced_notification() - ->mutable_coalesced_notification() - ->set_key(key); - } else { - specifics.mutable_synced_notification_app_info() - ->add_synced_notification_app_info() - ->add_app_id(key); - } - syncer::SyncData data = syncer::SyncData::CreateLocalData( - key, key, specifics); - return data; -} - -// Builds a SyncChange with an update to the specified |type| based on |key|. -syncer::SyncChange BuildChange(syncer::ModelType type, const std::string& key) { - syncer::SyncChangeList change_list; - syncer::SyncData data = BuildData(type, key); - return syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_UPDATE, data); -} - -// Verifies that the specifics within |data| match the serialized specifics -// within |serialized|. -testing::AssertionResult DataSpecificsMatch(const syncer::SyncData& data, - const std::string& serialized) { - if (data.GetDataType() == syncer::SYNCED_NOTIFICATIONS) { - const sync_pb::SyncedNotificationSpecifics& proto = - data.GetSpecifics().synced_notification(); - if (serialized != proto.SerializeAsString()) - return testing::AssertionFailure() << "Notification specifics mismatch"; - } else { - const sync_pb::SyncedNotificationAppInfoSpecifics& proto = - data.GetSpecifics().synced_notification_app_info(); - if (serialized != proto.SerializeAsString()) - return testing::AssertionFailure() << "App info specifics mismatch"; - } - return testing::AssertionSuccess(); -} - -// Verifies that the update within |change| matchs the serialized specifics -// within |serialized|. -testing::AssertionResult ChangeSpecificsMatch(const syncer::SyncChange& change, - const std::string& serialized) { - if (change.change_type() != syncer::SyncChange::ACTION_UPDATE) - return testing::AssertionFailure() << "Invalid change type"; - return DataSpecificsMatch(change.sync_data(), serialized); -} - -class SyncedNotificationsShimTest : public testing::Test { - public: - SyncedNotificationsShimTest(); - ~SyncedNotificationsShimTest() override; - - // Starts sync for both sync types. - void StartSync(); - // Starts sync for the specified datatype |type|. - void StartSync(syncer::ModelType type); - - // Transfers ownership of the last event received. - scoped_ptr<Event> GetLastEvent(); - - // Records that a refresh has been requested. - void RequestRefresh(); - - SyncedNotificationsShim* shim() { return &shim_; } - syncer::FakeSyncChangeProcessor* notification_processor() { - return notification_processor_; - } - syncer::FakeSyncChangeProcessor* app_info_processor() { - return app_info_processor_; - } - bool refresh_requested() const { return refresh_requested_; } - - private: - void EventCallback(scoped_ptr<Event> event); - - // Shim being tested. - SyncedNotificationsShim shim_; - - syncer::FakeSyncChangeProcessor* notification_processor_; - syncer::FakeSyncChangeProcessor* app_info_processor_; - - // The last event fired by the shim. - scoped_ptr<Event> last_event_fired_; - - // Whether a refresh has been requested; - bool refresh_requested_; -}; - -SyncedNotificationsShimTest::SyncedNotificationsShimTest() - : shim_(base::Bind(&SyncedNotificationsShimTest::EventCallback, - base::Unretained(this)), - base::Bind(&SyncedNotificationsShimTest::RequestRefresh, - base::Unretained(this))), - notification_processor_(NULL), - app_info_processor_(NULL), - refresh_requested_(false) {} - -SyncedNotificationsShimTest::~SyncedNotificationsShimTest() {} - -void SyncedNotificationsShimTest::EventCallback(scoped_ptr<Event> event) { - ASSERT_FALSE(last_event_fired_); - last_event_fired_ = event.Pass(); -} - -void SyncedNotificationsShimTest::RequestRefresh() { - ASSERT_FALSE(refresh_requested_); - refresh_requested_ = true; -} - -scoped_ptr<Event> SyncedNotificationsShimTest::GetLastEvent() { - return last_event_fired_.Pass(); -} - -void SyncedNotificationsShimTest::StartSync() { - StartSync(syncer::SYNCED_NOTIFICATIONS); - StartSync(syncer::SYNCED_NOTIFICATION_APP_INFO); - GetLastEvent(); -} - -void SyncedNotificationsShimTest::StartSync(syncer::ModelType type) { - scoped_ptr<syncer::FakeSyncChangeProcessor> change_processor( - new syncer::FakeSyncChangeProcessor()); - if (type == syncer::SYNCED_NOTIFICATIONS) - notification_processor_ = change_processor.get(); - else - app_info_processor_ = change_processor.get(); - syncer::SyncDataList sync_data; - shim_.MergeDataAndStartSyncing( - type, sync_data, change_processor.Pass(), nullptr); -} - -// Starting sync should fire the sync started event, but only after both types -// have started. -TEST_F(SyncedNotificationsShimTest, StartSync) { - EXPECT_FALSE(shim()->IsSyncReady()); - StartSync(syncer::SYNCED_NOTIFICATIONS); - EXPECT_FALSE(shim()->IsSyncReady()); - EXPECT_FALSE(GetLastEvent()); - - StartSync(syncer::SYNCED_NOTIFICATION_APP_INFO); - EXPECT_TRUE(shim()->IsSyncReady()); - - scoped_ptr<Event> event = GetLastEvent(); - ASSERT_TRUE(event); - EXPECT_EQ(synced_notifications_private::OnSyncStartup::kEventName, - event->event_name); - - EXPECT_TRUE(notification_processor()->changes().empty()); - EXPECT_TRUE(app_info_processor()->changes().empty()); -} - -// A sync update should fire the OnDataChanges event with the updated -// notification. -TEST_F(SyncedNotificationsShimTest, ProcessSyncChangesSingleNotification) { - StartSync(); - syncer::SyncChangeList change_list; - change_list.push_back(BuildChange(syncer::SYNCED_NOTIFICATIONS, "key")); - shim()->ProcessSyncChanges(FROM_HERE, change_list); - scoped_ptr<Event> event = GetLastEvent(); - ASSERT_TRUE(event); - EXPECT_EQ(synced_notifications_private::OnDataChanges::kEventName, - event->event_name); - ASSERT_TRUE(event->event_args); - EXPECT_EQ(1U, event->event_args->GetSize()); - - base::ListValue* args = NULL; - ASSERT_TRUE(event->event_args->GetList(0, &args)); - EXPECT_EQ(1U, args->GetSize()); - base::DictionaryValue* sync_change_value = NULL; - ASSERT_TRUE(args->GetDictionary(0, &sync_change_value)); - scoped_ptr<synced_notifications_private::SyncChange> sync_change = - synced_notifications_private::SyncChange::FromValue(*sync_change_value); - ASSERT_TRUE(sync_change); - EXPECT_TRUE(ChangeSpecificsMatch(change_list[0], - sync_change->data.data_item)); - EXPECT_EQ(synced_notifications_private::CHANGE_TYPE_UPDATED, - sync_change->change_type); -} - -// Verify that multiple notification updates can be sent in one event. -TEST_F(SyncedNotificationsShimTest, ProcessSyncChangesMultipleNotification) { - StartSync(); - syncer::SyncChangeList change_list; - change_list.push_back(BuildChange(syncer::SYNCED_NOTIFICATIONS, "key")); - change_list.push_back(BuildChange(syncer::SYNCED_NOTIFICATIONS, "key2")); - shim()->ProcessSyncChanges(FROM_HERE, change_list); - scoped_ptr<Event> event = GetLastEvent(); - ASSERT_TRUE(event); - EXPECT_EQ(synced_notifications_private::OnDataChanges::kEventName, - event->event_name); - ASSERT_TRUE(event->event_args); - base::ListValue* args = NULL; - ASSERT_TRUE(event->event_args->GetList(0, &args)); - EXPECT_EQ(2U, args->GetSize()); - - base::DictionaryValue* sync_change_value = NULL; - ASSERT_TRUE(args->GetDictionary(0, &sync_change_value)); - scoped_ptr<synced_notifications_private::SyncChange> sync_change = - synced_notifications_private::SyncChange::FromValue(*sync_change_value); - ASSERT_TRUE(sync_change); - EXPECT_TRUE(ChangeSpecificsMatch(change_list[0], - sync_change->data.data_item)); - EXPECT_EQ(synced_notifications_private::CHANGE_TYPE_UPDATED, - sync_change->change_type); - - ASSERT_TRUE(args->GetDictionary(1, &sync_change_value)); - sync_change = - synced_notifications_private::SyncChange::FromValue(*sync_change_value); - ASSERT_TRUE(sync_change); - EXPECT_TRUE(ChangeSpecificsMatch(change_list[1], - sync_change->data.data_item)); - EXPECT_EQ(synced_notifications_private::CHANGE_TYPE_UPDATED, - sync_change->change_type); -} - -// Verify AppInfo updates trigger OnDataChanges events. -TEST_F(SyncedNotificationsShimTest, ProcessSyncChangeAppInfo) { - StartSync(); - syncer::SyncChangeList change_list; - change_list.push_back( - BuildChange(syncer::SYNCED_NOTIFICATION_APP_INFO, "key")); - shim()->ProcessSyncChanges(FROM_HERE, change_list); - scoped_ptr<Event> event = GetLastEvent(); - ASSERT_TRUE(event); - EXPECT_EQ(synced_notifications_private::OnDataChanges::kEventName, - event->event_name); - ASSERT_TRUE(event->event_args); - EXPECT_EQ(1U, event->event_args->GetSize()); - - base::ListValue* args = NULL; - ASSERT_TRUE(event->event_args->GetList(0, &args)); - EXPECT_EQ(1U, args->GetSize()); - base::DictionaryValue* sync_change_value = NULL; - ASSERT_TRUE(args->GetDictionary(0, &sync_change_value)); - scoped_ptr<synced_notifications_private::SyncChange> sync_change = - synced_notifications_private::SyncChange::FromValue(*sync_change_value); - ASSERT_TRUE(sync_change); - EXPECT_TRUE(ChangeSpecificsMatch(change_list[0], - sync_change->data.data_item)); - EXPECT_EQ(synced_notifications_private::CHANGE_TYPE_UPDATED, - sync_change->change_type); -} - -// Attempt to get the initial sync data both before and after sync starts. -TEST_F(SyncedNotificationsShimTest, GetInitialData) { - std::vector<linked_ptr<synced_notifications_private::SyncData> > data; - EXPECT_FALSE(shim()->GetInitialData( - synced_notifications_private::SYNC_DATA_TYPE_SYNCED_NOTIFICATION, &data)); - EXPECT_FALSE(shim()->GetInitialData( - synced_notifications_private::SYNC_DATA_TYPE_APP_INFO, &data)); - - StartSync(); - - EXPECT_TRUE(shim()->GetInitialData( - synced_notifications_private::SYNC_DATA_TYPE_SYNCED_NOTIFICATION, &data)); - EXPECT_TRUE(data.empty()); - EXPECT_TRUE(shim()->GetInitialData( - synced_notifications_private::SYNC_DATA_TYPE_APP_INFO, &data)); - EXPECT_TRUE(data.empty()); - - notification_processor()->data().push_back(BuildData( - syncer::SYNCED_NOTIFICATIONS, "notif_key")); - EXPECT_TRUE(shim()->GetInitialData( - synced_notifications_private::SYNC_DATA_TYPE_SYNCED_NOTIFICATION, &data)); - EXPECT_EQ(1U, data.size()); - EXPECT_TRUE(DataSpecificsMatch(notification_processor()->data()[0], - data[0]->data_item)); - - data.clear(); - app_info_processor()->data().push_back(BuildData( - syncer::SYNCED_NOTIFICATION_APP_INFO, "app_key")); - EXPECT_TRUE(shim()->GetInitialData( - synced_notifications_private::SYNC_DATA_TYPE_APP_INFO, &data)); - EXPECT_EQ(1U, data.size()); - EXPECT_TRUE(DataSpecificsMatch(app_info_processor()->data()[0], - data[0]->data_item)); -} - -// Verify that notification updates are properly handled. -TEST_F(SyncedNotificationsShimTest, UpdateNotification) { - syncer::SyncData data = - BuildData(syncer::SYNCED_NOTIFICATIONS, "notif_key"); - std::string serialized = - data.GetSpecifics().synced_notification().SerializeAsString(); - EXPECT_FALSE(shim()->UpdateNotification(serialized)); - - StartSync(); - - EXPECT_FALSE(shim()->UpdateNotification("gibberish")); - EXPECT_TRUE(notification_processor()->changes().empty()); - - EXPECT_TRUE(shim()->UpdateNotification(serialized)); - EXPECT_EQ(1U, notification_processor()->changes().size()); - EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, - notification_processor()->changes()[0].change_type()); - EXPECT_EQ(syncer::SYNCED_NOTIFICATIONS, - notification_processor()->changes()[0].sync_data().GetDataType()); - EXPECT_EQ(serialized, - notification_processor() - ->changes()[0] - .sync_data() - .GetSpecifics() - .synced_notification() - .SerializeAsString()); -} - -// Verify that SetRenderContext updates the datatype context properly. -TEST_F(SyncedNotificationsShimTest, SetRenderContext) { - const std::string kContext = "context"; - EXPECT_FALSE(shim()->SetRenderContext( - synced_notifications_private::REFRESH_REQUEST_REFRESH_NEEDED, kContext)); - EXPECT_FALSE(refresh_requested()); - - StartSync(); - - EXPECT_TRUE(shim()->SetRenderContext( - synced_notifications_private::REFRESH_REQUEST_REFRESH_NEEDED, kContext)); - EXPECT_EQ(kContext, notification_processor()->context()); - EXPECT_TRUE(refresh_requested()); -} - -} // namespace diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc index 5b8d0a2..055c48b 100644 --- a/chrome/browser/notifications/message_center_settings_controller.cc +++ b/chrome/browser/notifications/message_center_settings_controller.cc @@ -19,8 +19,6 @@ #include "chrome/browser/notifications/desktop_notification_profile_util.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/desktop_notification_service_factory.h" -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" diff --git a/chrome/browser/notifications/sync_notifier/OWNERS b/chrome/browser/notifications/sync_notifier/OWNERS deleted file mode 100644 index f11bada..0000000 --- a/chrome/browser/notifications/sync_notifier/OWNERS +++ /dev/null @@ -1 +0,0 @@ -petewil@chromium.org
\ No newline at end of file diff --git a/chrome/browser/notifications/sync_notifier/chrome_notifier_service.cc b/chrome/browser/notifications/sync_notifier/chrome_notifier_service.cc deleted file mode 100644 index c85fa07..0000000 --- a/chrome/browser/notifications/sync_notifier/chrome_notifier_service.cc +++ /dev/null @@ -1,55 +0,0 @@ -// 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. - -// The ChromeNotifierService works together with sync to maintain the state of -// user notifications, which can then be presented in the notification center, -// via the Notification UI Manager. - -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" - -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.h" -#include "chrome/browser/profiles/profile.h" -#include "content/public/browser/notification_service.h" -#include "extensions/browser/event_router.h" - -namespace notifier { - -ChromeNotifierService::ChromeNotifierService(Profile* profile) - : profile_(profile), - weak_ptr_factory_(this) { - synced_notifications_shim_.reset(new SyncedNotificationsShim( - base::Bind(&ChromeNotifierService::FireSyncJSEvent, - weak_ptr_factory_.GetWeakPtr()), - base::Bind(&ChromeNotifierService::NotifyRefreshNeeded, - weak_ptr_factory_.GetWeakPtr()))); -} - -ChromeNotifierService::~ChromeNotifierService() { -} - -// Methods from KeyedService. -void ChromeNotifierService::Shutdown() {} - -SyncedNotificationsShim* ChromeNotifierService::GetSyncedNotificationsShim() { - return synced_notifications_shim_.get(); -} - -void ChromeNotifierService::FireSyncJSEvent( - scoped_ptr<extensions::Event> event) { - event->restrict_to_browser_context = profile_; - // TODO(synced notifications): consider broadcasting to a specific extension - // id. - extensions::EventRouter::Get(profile_)->BroadcastEvent(event.Pass()); -} - -void ChromeNotifierService::NotifyRefreshNeeded() { - const syncer::ModelTypeSet types(syncer::SYNCED_NOTIFICATIONS); - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, - content::Source<Profile>(profile_), - content::Details<const syncer::ModelTypeSet>(&types)); -} - -} // namespace notifier diff --git a/chrome/browser/notifications/sync_notifier/chrome_notifier_service.h b/chrome/browser/notifications/sync_notifier/chrome_notifier_service.h deleted file mode 100644 index 0daf4c3..0000000 --- a/chrome/browser/notifications/sync_notifier/chrome_notifier_service.h +++ /dev/null @@ -1,57 +0,0 @@ -// 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_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ -#define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ - -#include "base/memory/weak_ptr.h" -#include "components/keyed_service/core/keyed_service.h" - -class Profile; -class SyncedNotificationsShim; - -namespace extensions { -struct Event; -} - -namespace notifier { - -// The ChromeNotifierService acts as the bridge between sync and the JS -// extension that implements the synced notifications processing code. -// TODO(zea): consider making this a generic bridge for extension backed -// datatypes. -class ChromeNotifierService : public KeyedService { - public: - explicit ChromeNotifierService(Profile* profile); - ~ChromeNotifierService() override; - - // KeyedService implementation. - void Shutdown() override; - - // Returns the SyncableService for syncer::SYNCED_NOTIFICATIONS and - // syncer::SYNCED_NOTIFICATION_APP_INFO - SyncedNotificationsShim* GetSyncedNotificationsShim(); - - private: - // Helper method for firing JS events triggered by sync. - void FireSyncJSEvent(scoped_ptr<extensions::Event> event); - - // Helper method for trigger synced notification refreshes. - void NotifyRefreshNeeded(); - - // The owning profile. - Profile* const profile_; - - // Shim connecting the JS private api to sync. // TODO(zea): delete all other - // code. - scoped_ptr<SyncedNotificationsShim> synced_notifications_shim_; - - base::WeakPtrFactory<ChromeNotifierService> weak_ptr_factory_; - - DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService); -}; - -} // namespace notifier - -#endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ diff --git a/chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.cc b/chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.cc deleted file mode 100644 index a31f1ed..0000000 --- a/chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 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. - -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" - -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" -#include "components/keyed_service/content/browser_context_dependency_manager.h" - -namespace notifier { - -// static -ChromeNotifierService* ChromeNotifierServiceFactory::GetForProfile( - Profile* profile, Profile::ServiceAccessType service_access_type) { - return static_cast<ChromeNotifierService*>( - GetInstance()->GetServiceForBrowserContext(profile, true)); -} - -// static -ChromeNotifierServiceFactory* ChromeNotifierServiceFactory::GetInstance() { - return Singleton<ChromeNotifierServiceFactory>::get(); -} - - -ChromeNotifierServiceFactory::ChromeNotifierServiceFactory() - : BrowserContextKeyedServiceFactory( - "ChromeNotifierService", - BrowserContextDependencyManager::GetInstance()) { -} - -ChromeNotifierServiceFactory::~ChromeNotifierServiceFactory() { -} - -KeyedService* ChromeNotifierServiceFactory::BuildServiceInstanceFor( - content::BrowserContext* profile) const { - ChromeNotifierService* chrome_notifier_service = - new ChromeNotifierService(static_cast<Profile*>(profile)); - return chrome_notifier_service; -} - -} // namespace notifier diff --git a/chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h b/chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h deleted file mode 100644 index 66d36cf..0000000 --- a/chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 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. - -#ifndef CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_FACTORY_H_ -#define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_FACTORY_H_ - -#include "base/memory/singleton.h" -#include "chrome/browser/profiles/profile.h" -#include "components/keyed_service/content/browser_context_keyed_service_factory.h" - -namespace base { -class CommandLine; -} - -namespace notifier { - -class ChromeNotifierService; - -class ChromeNotifierServiceFactory : public BrowserContextKeyedServiceFactory { - public: - static ChromeNotifierService* GetForProfile( - Profile* profile, Profile::ServiceAccessType service_access_type); - - static ChromeNotifierServiceFactory* GetInstance(); - - // Based on command line switches, make the call to use SyncedNotifications or - // not. - // TODO(petewil): Remove this when the SyncedNotifications feature is ready - // to be turned on by default, and just use a disable switch instead then. - static bool UseSyncedNotifications(base::CommandLine* command_line); - - private: - friend struct DefaultSingletonTraits<ChromeNotifierServiceFactory>; - - ChromeNotifierServiceFactory(); - ~ChromeNotifierServiceFactory() override; - - // BrowserContextKeyedServiceFactory: - KeyedService* BuildServiceInstanceFor( - content::BrowserContext* profile) const override; -}; - -} // namespace notifier - -#endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_CHROME_NOTIFIER_SERVICE_FACTORY_H_ diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index 58040a7..fc5fa3f 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -144,7 +144,6 @@ #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h" #include "chrome/browser/android/new_tab_page_prefs.h" #else -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h" #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" #endif diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc index 45686cd..695cd40 100644 --- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc +++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc @@ -105,7 +105,6 @@ #if defined(OS_ANDROID) #include "chrome/browser/media/protected_media_identifier_permission_context_factory.h" #else -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h" #endif @@ -223,7 +222,6 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() { #endif #if !defined(OS_ANDROID) MediaGalleriesPreferencesFactory::GetInstance(); - notifier::ChromeNotifierServiceFactory::GetInstance(); NTPResourceCacheFactory::GetInstance(); #endif PasswordStoreFactory::GetInstance(); diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc index aa276c3..8bbfaaa 100644 --- a/chrome/browser/sync/profile_sync_components_factory_impl.cc +++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc @@ -9,8 +9,6 @@ #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" #include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service_factory.h" -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" #include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/pref_service_flags_storage.h" #include "chrome/browser/prefs/pref_model_associator.h" @@ -76,7 +74,6 @@ #if defined(ENABLE_EXTENSIONS) #include "chrome/browser/extensions/api/storage/settings_sync_util.h" -#include "chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.h" #include "chrome/browser/extensions/extension_sync_service.h" #include "chrome/browser/sync/glue/extension_backed_data_type_controller.h" #include "chrome/browser/sync/glue/extension_data_type_controller.h" @@ -143,9 +140,6 @@ syncer::ModelTypeSet GetDisabledTypesFromCommandLine( syncer::ModelTypeSet GetEnabledTypesFromCommandLine( const CommandLine& command_line) { syncer::ModelTypeSet enabled_types; - if (command_line.HasSwitch(switches::kEnableSyncSyncedNotifications)) { - enabled_types.Put(syncer::SYNCED_NOTIFICATIONS); - } return enabled_types; } @@ -374,25 +368,6 @@ void ProfileSyncComponentsFactoryImpl::RegisterDesktopDataTypes( } #endif - // Synced Notifications are disabled by default. -#if defined(ENABLE_EXTENSIONS) && defined(ENABLE_NOTIFICATIONS) - if (enabled_types.Has(syncer::SYNCED_NOTIFICATIONS)) { - pss->RegisterDataTypeController( - new ExtensionBackedDataTypeController( - syncer::SYNCED_NOTIFICATIONS, - "", // TODO(dewittj): pass the extension hash here. - this, - profile_)); - - pss->RegisterDataTypeController( - new ExtensionBackedDataTypeController( - syncer::SYNCED_NOTIFICATION_APP_INFO, - "", // TODO(dewittj): pass the extension hash here. - this, - profile_)); - } -#endif - #if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_CHROMEOS) // Dictionary sync is enabled by default. if (!disabled_types.Has(syncer::DICTIONARY)) { @@ -506,15 +481,6 @@ base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl:: profile_, Profile::EXPLICIT_ACCESS); return history ? history->AsWeakPtr() : base::WeakPtr<HistoryService>(); } -#if defined(ENABLE_EXTENSIONS) - case syncer::SYNCED_NOTIFICATIONS: - case syncer::SYNCED_NOTIFICATION_APP_INFO: { - return notifier::ChromeNotifierServiceFactory::GetForProfile( - profile_, Profile::IMPLICIT_ACCESS) - ->GetSyncedNotificationsShim() - ->AsWeakPtr(); - } -#endif #if defined(ENABLE_SPELLCHECK) case syncer::DICTIONARY: return SpellcheckServiceFactory::GetForContext(profile_)-> diff --git a/chrome/browser/sync/profile_sync_service_factory.cc b/chrome/browser/sync/profile_sync_service_factory.cc index 30fe671..0016b96 100644 --- a/chrome/browser/sync/profile_sync_service_factory.cc +++ b/chrome/browser/sync/profile_sync_service_factory.cc @@ -35,7 +35,6 @@ #include "url/gurl.h" #if defined(ENABLE_EXTENSIONS) -#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" #include "extensions/browser/extension_system_provider.h" #include "extensions/browser/extensions_browser_client.h" #endif @@ -80,7 +79,6 @@ ProfileSyncServiceFactory::ProfileSyncServiceFactory() #if defined(ENABLE_EXTENSIONS) DependsOn( extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); - DependsOn(notifier::ChromeNotifierServiceFactory::GetInstance()); #endif // The following have not been converted to KeyedServices yet, diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index faa1dd9..5512a4c 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1854,10 +1854,6 @@ 'browser/notifications/notification_ui_manager_desktop.cc', 'browser/notifications/screen_lock_notification_blocker.cc', 'browser/notifications/screen_lock_notification_blocker.h', - 'browser/notifications/sync_notifier/chrome_notifier_service.cc', - 'browser/notifications/sync_notifier/chrome_notifier_service_factory.cc', - 'browser/notifications/sync_notifier/chrome_notifier_service_factory.h', - 'browser/notifications/sync_notifier/chrome_notifier_service.h', ], 'chrome_browser_nss_sources': [ 'browser/certificate_manager_model.cc', diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index fd92f6c..8a6f32e 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -454,10 +454,6 @@ 'browser/extensions/api/sync_file_system/sync_file_system_api.h', 'browser/extensions/api/sync_file_system/sync_file_system_api_helpers.cc', 'browser/extensions/api/sync_file_system/sync_file_system_api_helpers.h', - 'browser/extensions/api/synced_notifications_private/synced_notifications_private_api.cc', - 'browser/extensions/api/synced_notifications_private/synced_notifications_private_api.h', - 'browser/extensions/api/synced_notifications_private/synced_notifications_shim.cc', - 'browser/extensions/api/synced_notifications_private/synced_notifications_shim.h', 'browser/extensions/api/system_indicator/system_indicator_api.h', 'browser/extensions/api/system_indicator/system_indicator_manager.cc', 'browser/extensions/api/system_indicator/system_indicator_manager.h', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index e8f8de0..1cc5874 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -363,7 +363,6 @@ 'browser/extensions/api/storage/policy_value_store_unittest.cc', 'browser/extensions/api/storage/settings_sync_unittest.cc', 'browser/extensions/api/streams_private/streams_private_manifest_unittest.cc', - 'browser/extensions/api/synced_notifications_private/synced_notifications_shim_unittest.cc', 'browser/extensions/api/web_navigation/frame_navigation_state_unittest.cc', 'browser/extensions/api/web_request/web_request_api_unittest.cc', 'browser/extensions/api/web_request/web_request_permissions_unittest.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 493bc6d..4907270 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -360,10 +360,6 @@ const char kDisableSupervisedUserSafeSites[] = // Disables syncing browser data to a Google Account. const char kDisableSync[] = "disable-sync"; -// Disable synced notifications. -const char kDisableSyncSyncedNotifications[] = - "disable-sync-synced-notifications"; - // Disables syncing one or more sync data types that are on by default. // See sync/internal_api/public/base/model_type.h for possible types. Types // should be comma separated, and follow the naming convention for string @@ -615,10 +611,6 @@ const char kEnableSupervisedUserBlacklist[] = const char kEnableSupervisedUserSafeSites[] = "enable-supervised-user-safesites"; -// Enables synced notifications. -const char kEnableSyncSyncedNotifications[] = - "enable-sync-synced-notifications"; - // Enables synced articles. const char kEnableSyncArticles[] = "enable-sync-articles"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index ef92618..ed7773a 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -107,7 +107,6 @@ extern const char kDisableSuggestionsService[]; extern const char kDisableSupervisedUserBlacklist[]; extern const char kDisableSupervisedUserSafeSites[]; extern const char kDisableSync[]; -extern const char kDisableSyncSyncedNotifications[]; extern const char kDisableSyncTypes[]; extern const char kDisableWebResources[]; extern const char kDisableZeroBrowsersOpenForTests[]; @@ -179,7 +178,6 @@ extern const char kEnableSuggestionsService[]; extern const char kEnableSupervisedUserBlacklist[]; extern const char kEnableSupervisedUserSafeSites[]; extern const char kEnableSyncArticles[]; -extern const char kEnableSyncSyncedNotifications[]; extern const char kEnableTabAudioMuting[]; extern const char kEnableThumbnailRetargeting[]; extern const char kEnableTranslateNewUX[]; diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json index 4237edd..aa81f08 100644 --- a/chrome/common/extensions/api/_api_features.json +++ b/chrome/common/extensions/api/_api_features.json @@ -612,10 +612,6 @@ "dependencies": ["permission:syncFileSystem"], "contexts": ["blessed_extension"] }, - "syncedNotificationsPrivate": { - "contexts": ["blessed_extension"], - "dependencies": ["permission:syncedNotificationsPrivate"] - }, "systemIndicator": { "dependencies": ["manifest:system_indicator"], "contexts": ["blessed_extension"] diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json index eb191e4..3ed3286 100644 --- a/chrome/common/extensions/api/_permission_features.json +++ b/chrome/common/extensions/api/_permission_features.json @@ -947,13 +947,6 @@ "channel": "stable", "extension_types": ["platform_app"] }, - "syncedNotificationsPrivate": { - "channel": "dev", - "extension_types": ["platform_app"], - "whitelist": [ - "34967F9FA3C399E1EC380B443D7331AA93AC445B" // http://crbug.com/400436 - ] - }, "systemPrivate": { "channel": "stable", "extension_types": ["extension", "legacy_packaged_app", "platform_app"], diff --git a/chrome/common/extensions/api/schemas.gypi b/chrome/common/extensions/api/schemas.gypi index deda47d..b53fe07 100644 --- a/chrome/common/extensions/api/schemas.gypi +++ b/chrome/common/extensions/api/schemas.gypi @@ -77,7 +77,6 @@ 'sessions.json', 'signed_in_devices.idl', 'streams_private.idl', - 'synced_notifications_private.idl', 'sync_file_system.idl', 'system_indicator.idl', 'system_private.json', diff --git a/chrome/common/extensions/api/synced_notifications_private.idl b/chrome/common/extensions/api/synced_notifications_private.idl deleted file mode 100644 index e687fdf..0000000 --- a/chrome/common/extensions/api/synced_notifications_private.idl +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2014 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. - -// This API is designed to be used with Chrome Sync. -namespace syncedNotificationsPrivate { - -// Potential sync change types. -enum ChangeType { - added, - updated, - deleted -}; - -// Whether or not to resync all data items if the data type context changes. -enum RefreshRequest { - refresh_needed, - no_refresh -}; - -enum SyncDataType { - synced_notification, - app_info -}; - -dictionary SyncData { - SyncDataType datatype; - // |dataItem| will be a binary protobuf which matches the backend - // for the datatype. - ArrayBuffer dataItem; -}; - -// Datatype that represents a single sync change to a notification or an app -// info. -dictionary SyncChange { - SyncData data; - ChangeType changeType; -}; - -// Gets an array of SyncChange objects representing the current sync state. -// chrome.runtime.lastError contains any errors; if that is the case then -// changes should be undefined. -callback GetInitialDataCallback = void (SyncData[] changes); -// Called on completion or error of the sync operation. lastError contains an -// error message if required. -callback SyncOperationCallback = void (); - -interface Functions { - - // Gets all data from sync representing the current state (for use at - // startup). This returns both Synced Notifications and AppInfos (with the - // datatype enum set appropriately). Can return undefined, in which case - // LastError will be set. This means sync is unavailable at this time. - static void getInitialData(SyncDataType type, - GetInitialDataCallback callback); - - // Sends a changed (read state) notification back up to sync. To keep the - // sync from needing to understand the protocol, we send the whole object, - // not just the new read state. - static void updateNotification(ArrayBuffer changedNotification, - SyncOperationCallback callback); - - // Sets the (e.g.) Locale and DPI scale factor and list of sending services, - // encoded as a binary protobuf. Sync will persist these values for this - // and future sessions. - static void setRenderContext(RefreshRequest refresh, - ArrayBuffer dataTypeContext, - SyncOperationCallback callback); - -}; - -interface Events { - // Called by sync when we get new notifications or app infos from the - // server. - static void onDataChanges(SyncChange[] changes); - - // Called by sync when sync becomes available. This can be used to get the - // initial data for the app as soon as sync starts up, even if that is not - // soon after chrome startup. - static void onSyncStartup(); -}; - -}; diff --git a/chrome/common/extensions/permissions/chrome_api_permissions.cc b/chrome/common/extensions/permissions/chrome_api_permissions.cc index 9beb004..22f2462 100644 --- a/chrome/common/extensions/permissions/chrome_api_permissions.cc +++ b/chrome/common/extensions/permissions/chrome_api_permissions.cc @@ -296,8 +296,6 @@ std::vector<APIPermissionInfo*> ChromeAPIPermissions::GetAllPermissions() {APIPermission::kRtcPrivate, "rtcPrivate", APIPermissionInfo::kFlagCannotBeOptional}, - {APIPermission::kSyncedNotificationsPrivate, - "syncedNotificationsPrivate"}, {APIPermission::kTerminalPrivate, "terminalPrivate", APIPermissionInfo::kFlagCannotBeOptional}, diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc index 7870fa2..578d1fe 100644 --- a/chrome/common/extensions/permissions/permission_set_unittest.cc +++ b/chrome/common/extensions/permissions/permission_set_unittest.cc @@ -749,7 +749,6 @@ TEST(PermissionsTest, PermissionMessages) { skip.insert(APIPermission::kReadingListPrivate); skip.insert(APIPermission::kRtcPrivate); skip.insert(APIPermission::kStreamsPrivate); - skip.insert(APIPermission::kSyncedNotificationsPrivate); skip.insert(APIPermission::kSystemPrivate); skip.insert(APIPermission::kTabCaptureForTab); skip.insert(APIPermission::kTerminalPrivate); diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index 54f83ee..faa83c6 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h @@ -825,9 +825,9 @@ enum HistogramValue { DELETED_FILESYSTEMPROVIDERINTERNAL_OPENFILEREQUESTEDERROR, DELETED_FILESYSTEMPROVIDERINTERNAL_CLOSEFILEREQUESTEDSUCCESS, DELETED_FILESYSTEMPROVIDERINTERNAL_CLOSEFILEREQUESTEDERROR, - SYNCEDNOTIFICATIONSPRIVATE_GETINITIALDATA, - SYNCEDNOTIFICATIONSPRIVATE_UPDATENOTIFICATION, - SYNCEDNOTIFICATIONSPRIVATE_SETRENDERCONTEXT, + DELETED_SYNCEDNOTIFICATIONSPRIVATE_GETINITIALDATA, + DELETED_SYNCEDNOTIFICATIONSPRIVATE_UPDATENOTIFICATION, + DELETED_SYNCEDNOTIFICATIONSPRIVATE_SETRENDERCONTEXT, IDENTITY_GETACCOUNTS, FILEMANAGERPRIVATE_RESOLVEISOLATEDENTRIES, FILESYSTEMPROVIDERINTERNAL_READFILEREQUESTEDSUCCESS, diff --git a/extensions/common/permissions/api_permission.h b/extensions/common/permissions/api_permission.h index 924412b..041cfbe 100644 --- a/extensions/common/permissions/api_permission.h +++ b/extensions/common/permissions/api_permission.h @@ -166,7 +166,6 @@ class APIPermission { kStorage, kStreamsPrivate, kSyncFileSystem, - kSyncedNotificationsPrivate, kSystemPrivate, kSystemDisplay, kSystemStorage, diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h index 13c7373..511f66b 100644 --- a/sync/internal_api/public/base/model_type.h +++ b/sync/internal_api/public/base/model_type.h @@ -80,13 +80,13 @@ enum ModelType { // An extension setting from the extension settings API. EXTENSION_SETTINGS, // App notifications. - APP_NOTIFICATIONS, + APP_NOTIFICATIONS, // Deprecated. // History delete directives. HISTORY_DELETE_DIRECTIVES, // Synced push notifications. - SYNCED_NOTIFICATIONS, + SYNCED_NOTIFICATIONS, // Deprecated. // Synced Notification app info. - SYNCED_NOTIFICATION_APP_INFO, + SYNCED_NOTIFICATION_APP_INFO, // Deprecated. // Custom spelling dictionary. DICTIONARY, // Favicon images. diff --git a/sync/protocol/BUILD.gn b/sync/protocol/BUILD.gn index 5bdca9d..5ec0001 100644 --- a/sync/protocol/BUILD.gn +++ b/sync/protocol/BUILD.gn @@ -39,8 +39,6 @@ proto_library("protocol") { "sync.proto", "sync_enums.proto", "synced_notification_app_info_specifics.proto", - "synced_notification_data.proto", - "synced_notification_render.proto", "synced_notification_specifics.proto", "test.proto", "theme_specifics.proto", diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc index cc022c4..91a11e3 100644 --- a/sync/protocol/proto_value_conversions.cc +++ b/sync/protocol/proto_value_conversions.cc @@ -38,8 +38,6 @@ #include "sync/protocol/search_engine_specifics.pb.h" #include "sync/protocol/session_specifics.pb.h" #include "sync/protocol/sync.pb.h" -#include "sync/protocol/synced_notification_app_info_specifics.pb.h" -#include "sync/protocol/synced_notification_specifics.pb.h" #include "sync/protocol/theme_specifics.pb.h" #include "sync/protocol/typed_url_specifics.pb.h" #include "sync/protocol/unique_position.pb.h" @@ -266,127 +264,6 @@ base::DictionaryValue* TimeRangeDirectiveToValue( return value; } -base::DictionaryValue* SyncedNotificationAppInfoToValue( - const sync_pb::SyncedNotificationAppInfo& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET_STR_REP(app_id); - SET_STR(settings_display_name); - SET_STR(app_name); - SET_STR(settings_url); - SET_STR(info_url); - SET(icon, SyncedNotificationImageToValue); - // TODO(petewil): Add fields for the monochrome icon when it is available. - return value; -} - -base::DictionaryValue* SyncedNotificationImageToValue( - const sync_pb::SyncedNotificationImage& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET_STR(url); - SET_STR(alt_text); - SET_INT32(preferred_width); - SET_INT32(preferred_height); - return value; -} - -base::DictionaryValue* SyncedNotificationProfileImageToValue( - const sync_pb::SyncedNotificationProfileImage& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET_STR(image_url); - SET_STR(oid); - SET_STR(display_name); - return value; -} - -base::DictionaryValue* MediaToValue( - const sync_pb::Media& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET(image, SyncedNotificationImageToValue); - return value; -} - -base::DictionaryValue* SyncedNotificationActionToValue( - const sync_pb::SyncedNotificationAction& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET_STR(text); - SET(icon, SyncedNotificationImageToValue); - SET_STR(url); - SET_STR(request_data); - SET_STR(accessibility_label); - return value; -} - -base::DictionaryValue* SyncedNotificationDestiationToValue( - const sync_pb::SyncedNotificationDestination& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET_STR(text); - SET(icon, SyncedNotificationImageToValue); - SET_STR(url); - SET_STR(accessibility_label); - return value; -} - -base::DictionaryValue* TargetToValue( - const sync_pb::Target& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET(destination, SyncedNotificationDestiationToValue); - SET(action, SyncedNotificationActionToValue); - SET_STR(target_key); - return value; -} - -base::DictionaryValue* SimpleCollapsedLayoutToValue( - const sync_pb::SimpleCollapsedLayout& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET(app_icon, SyncedNotificationImageToValue); - SET_REP(profile_image, SyncedNotificationProfileImageToValue); - SET_STR(heading); - SET_STR(description); - SET_STR(annotation); - SET_REP(media, MediaToValue); - return value; -} - -base::DictionaryValue* CollapsedInfoToValue( - const sync_pb::CollapsedInfo& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET(simple_collapsed_layout, SimpleCollapsedLayoutToValue); - SET_INT64(creation_timestamp_usec); - SET(default_destination, SyncedNotificationDestiationToValue); - SET_REP(target, TargetToValue); - return value; -} - -base::DictionaryValue* SyncedNotificationToValue( - const sync_pb::SyncedNotification& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET_STR(type); - SET_STR(external_id); - // TODO(petewil) Add SyncedNotificationCreator here if we ever need it. - return value; -} - -base::DictionaryValue* RenderInfoToValue( - const sync_pb::SyncedNotificationRenderInfo& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - // TODO(petewil): Add the expanded info values once we start using them. - SET(collapsed_info, CollapsedInfoToValue); - return value; -} - -base::DictionaryValue* CoalescedNotificationToValue( - const sync_pb::CoalescedSyncedNotification& proto) { - base::DictionaryValue* value = new base::DictionaryValue(); - SET_STR(key); - SET_STR(app_id); - SET_REP(notification, SyncedNotificationToValue); - SET(render_info, RenderInfoToValue); - SET_INT32(read_state); - SET_INT64(creation_time_msec); - SET_INT32(priority); - return value; -} - base::DictionaryValue* AppListSpecificsToValue( const sync_pb::AppListSpecifics& proto) { base::DictionaryValue* value = new base::DictionaryValue(); @@ -708,17 +585,12 @@ base::DictionaryValue* PriorityPreferenceSpecificsToValue( base::DictionaryValue* SyncedNotificationAppInfoSpecificsToValue( const sync_pb::SyncedNotificationAppInfoSpecifics& proto) { base::DictionaryValue* value = new base::DictionaryValue(); - SET_REP(synced_notification_app_info, SyncedNotificationAppInfoToValue); return value; } base::DictionaryValue* SyncedNotificationSpecificsToValue( const sync_pb::SyncedNotificationSpecifics& proto) { - // There is a lot of data, for now just use heading, description, key, and - // the read state. - // TODO(petewil): Eventually add more data here. base::DictionaryValue* value = new base::DictionaryValue(); - SET(coalesced_notification, CoalescedNotificationToValue); return value; } diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h index 79e4ca2..aae3507 100644 --- a/sync/protocol/proto_value_conversions.h +++ b/sync/protocol/proto_value_conversions.h @@ -27,7 +27,6 @@ class BookmarkSpecifics; class ClientConfigParams; class ClientToServerMessage; class ClientToServerResponse; -class CoalescedSyncedNotification; class CollapsedInfo; class DatatypeAssociationStats; class DebugEventInfo; @@ -64,14 +63,7 @@ class SessionWindow; class SimpleCollapsedLayout; class SyncCycleCompletedEventInfo; class SyncEntity; -class SyncedNotification; -class SyncedNotificationAction; -class SyncedNotificationAppInfo; class SyncedNotificationAppInfoSpecifics; -class SyncedNotificationDestination; -class SyncedNotificationImage; -class SyncedNotificationProfileImage; -class SyncedNotificationRenderInfo; class SyncedNotificationSpecifics; class TabNavigation; class Target; @@ -147,42 +139,9 @@ base::DictionaryValue* TimeRangeDirectiveToValue( base::DictionaryValue* KeystoreEncryptionToValue( const sync_pb::KeystoreEncryptionFlagsSpecifics& proto); -// Sub protocols of SyncedNotifications. - -base::DictionaryValue* SimpleCollapsedLayoutToValue( - const sync_pb::SimpleCollapsedLayout& proto); - -base::DictionaryValue* CollapsedInfoToValue( - const sync_pb::CollapsedInfo& proto); - -base::DictionaryValue* RenderInfoToValue( - const sync_pb::SyncedNotificationRenderInfo& proto); - -base::DictionaryValue* CoalescedNotificationToValue( - const sync_pb::CoalescedSyncedNotification& proto); - -base::DictionaryValue* SyncedNotificationActionToValue( - const sync_pb::SyncedNotificationAction& action); - -base::DictionaryValue* SyncedNotificationDestinationToValue( - const sync_pb::SyncedNotificationDestination& destination); - -base::DictionaryValue* SyncedNotificationToValue( - const sync_pb::SyncedNotification& notification); - SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionSpecificsToValue( const sync_pb::SessionSpecifics& session_specifics); -SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncedNotificationImageToValue( - const sync_pb::SyncedNotificationImage& image); - -SYNC_EXPORT_PRIVATE base::DictionaryValue* - SyncedNotificationProfileImageToValue( - const sync_pb::SyncedNotificationProfileImage& image); - -SYNC_EXPORT_PRIVATE base::DictionaryValue* TargetToValue( - const sync_pb::Target& target); - // Main *SpecificsToValue functions. SYNC_EXPORT_PRIVATE base::DictionaryValue* AppNotificationToValue( diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto index ea0013e..8974828 100644 --- a/sync/protocol/sync.proto +++ b/sync/protocol/sync.proto @@ -116,8 +116,7 @@ message EntitySpecifics { optional AppSettingSpecifics app_setting = 103656; optional HistoryDeleteDirectiveSpecifics history_delete_directive = 150251; optional SyncedNotificationSpecifics synced_notification = 153108; - optional SyncedNotificationAppInfoSpecifics synced_notification_app_info = - 235816; + optional SyncedNotificationAppInfoSpecifics synced_notification_app_info = 235816; optional DeviceInfoSpecifics device_info = 154522; optional ExperimentsSpecifics experiments = 161496; optional PriorityPreferenceSpecifics priority_preference = 163425; diff --git a/sync/protocol/synced_notification_app_info_specifics.proto b/sync/protocol/synced_notification_app_info_specifics.proto index 73ed92c..cfdbfd0 100644 --- a/sync/protocol/synced_notification_app_info_specifics.proto +++ b/sync/protocol/synced_notification_app_info_specifics.proto @@ -1,6 +1,9 @@ -// Copyright 2014 Google Inc. All Rights Reserved. +// Copyright 2014 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 appInfo objects. +// Sync protocol datatype extension for synced notification app info objects. +// DO NOT USE: This datatype is deprecated. syntax = "proto2"; @@ -9,48 +12,6 @@ option retain_unknown_fields = true; package sync_pb; -import "synced_notification_render.proto"; - +// This message is kept around for backwards compatibility sake. message SyncedNotificationAppInfoSpecifics { - // Information of the list of apps we know about. - // NOTE: This may not be the comprehensive list of apps that send - // notifications. At best, it will contain all the first party apps and - // paging support is not needed. - // This is a static list sent from the server that is read only on the client. - repeated SyncedNotificationAppInfo synced_notification_app_info = 1; -} - -message SyncedNotificationAppInfo { - // The application ID (the subservice within the sending service). - repeated string app_id = 1; - - // The name to use in the settings screen for this app. - // Use app_name field instead. - optional string settings_display_name = 2 [deprecated = true]; - - // This field is deprecated. Use the app_icon field instead. - optional SyncedNotificationImage icon = 3 [deprecated = true]; - - optional string app_name = 4; - - optional string settings_url = 5; - - optional string info_url = 6; - - message Icon { - enum Type { - GRAYSCALE_FAVICON_1X = 1; // Grayscale 16x16 px icon. - GRAYSCALE_FAVICON_2X = 2; // Grayscale 32x32 px icon. - COLOR_FAVICON_1X = 3; // Color 16x16 px icon. - COLOR_FAVICON_2X = 4; // Color 32x32 px icon. - COLOR_APPICON_1X = 5; // Color 80x80 px icon. - COLOR_APPICON_2X = 6; // Color 160x160 px icon. - }; - optional Type type = 1; - - optional string url = 2; - }; - - // A repeated set of icons of different resolutions and types. - repeated Icon app_icon = 7; } diff --git a/sync/protocol/synced_notification_data.proto b/sync/protocol/synced_notification_data.proto deleted file mode 100644 index abd52a8..0000000 --- a/sync/protocol/synced_notification_data.proto +++ /dev/null @@ -1,207 +0,0 @@ -// 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. -// -// Sync protocol datatype extension for push notifications.. - -// Update proto_value_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; - -import "synced_notification_render.proto"; - -// This message allows clients to identify a notification they have created. -message SyncedNotificationIdentifier { - // The application that the notification is a part of. - optional string app_id = 1; - - // Notifications with the same coalescing key (isolated to the same app_id) - // will be grouped together when fetched. - optional string coalescing_key = 2; -} - -message SyncedNotificationCreator { - // The gaia id of the creator. If a notification does not have a clear - // creator, skip this and follow the directions below to use a system creator. - optional int64 gaia_id = 1; - - // Indicates that the creator is a "system" creator. Example of these are - // notifications sent to the user where the addressee is "Google", such as the - // "You have violated our TOS, and have 3 days to fix it or you'll lose your - // account" notifications. If is_system is set, gaia_id must not be set and - // instead the app_id field must be set. - optional bool is_system = 2; - - // Only set this in the system-creator case. - optional string app_id = 3; -} - -message SyncedNotificationRecipients { - repeated int64 gaia_id = 1; - - // For now, only support gaia id recipients. Add more recipient types via - // 'repeated Type other_type = X' when necessary. -} - -message SyncedNotification { - // A secondary type that is isolated within the same app_id. - // - // NOTE: For ASBE support purposes this must be in the format [A-Za-z_]+. - optional string type = 1; - - // Whatever string the client entered during creation. If no external_id is - // specified, the notification can no longer be identified individually for - // fetching/deleting, etc... - optional string external_id = 2; - - // The creator of the notification. - optional SyncedNotificationCreator creator = 3; - - // Client specific data. - optional MapData client_data = 4; -} - -message CoalescedSyncedNotification { - // An opaque string key used to identify individual coalesced notifications. - optional string key = 1; - - optional string app_id = 2; - - // All the notifications that are grouped together. - repeated SyncedNotification notification = 3; - - // Data that is used directly by endpoints to render notifications in the case - // where no "native" app can handle the notification. - optional SyncedNotificationRenderInfo render_info = 4; - - // Read state will be per coalesced notification. - enum ReadState { - UNREAD = 1; - READ = 2; - DISMISSED = 3; - SEEN = 4; - } - optional ReadState read_state = 5; - - // The time when the LATEST notification of the coalesced notification is - // created (in milliseconds since the linux epoch). - // This is called updated_version in the server side protobuf. - optional uint64 creation_time_msec = 6; - - enum Priority { - INVISIBLE = 1; - LOW = 2; - HIGH = 3; - // We will most likely add at least one more priority in the near future. - }; - optional Priority priority = 7; - - // Security token that is to be used when making a PerformUserAction request - // when any user action within this coalesced notification is triggered. - optional string user_action_token = 8; - - // This field corresponds to catchup_version in entity, which represents the - // version entity was last modified. Note that the - // Entity.last_modified_version will be actually the last creation version. - // See comments in updated_version. - optional uint64 last_modified_version = 9; - - // Clients should use this field to order the notifications. Currently this is - // calculated from (priority, updated_version) pair. - optional uint64 sort_version = 10; -} - -message SyncedNotificationList { - repeated CoalescedSyncedNotification coalesced_notification = 1; -} - -// MapData, Data, and ListData are used to sending aribitrary payloads -// between instances of applications using Synced Notifications. The -// schema atop MapData will be defined by the client application. -message MapData { - message Entry { - optional string key = 1; - optional Data value = 2; - }; - repeated Entry entry = 1; -}; - -message Data { - optional bool boolean_value = 1; - optional int32 int_value = 2; - optional double float_value = 3; - optional string string_value = 4; - optional ListData list_value = 5; - optional MapData map_value = 6; -}; - -message ListData { - repeated Data value = 1; -}; - -// The RenderContext encapsulates data about the device that is displaying the -// notification. In the future, RenderContext might include data like the -// location of the user. -message RenderContext { - // The type of the device. This will be used to decide the resolution as well - // as the size of the image returned with the response. - // The server will try to find the closest matching resource to use. - // The android densities are from - // http://developer.android.com/guide/practices/screens_support.html - enum DeviceType { - UNKNOWN = 0; - IOS_NON_RETINA = 1; - IOS_RETINA = 2; - ANDROID_MDPI = 3; - ANDROID_HDPI = 4; - ANDROID_XHDPI = 5; - ANDROID_TVDPI = 6; - DESKTOP_NON_RETINA = 7; - DESKTOP_RETINA = 8; - ANDROID_XXHDPI = 9; - CHROME_1X = 10; - CHROME_2X = 11; - } - - optional DeviceType device_type = 1; - - // The locale to render the notifications in. - optional string language_code = 2; -}; - -// List of AppIds and whether to treat the list as a Whitelist or Blacklist. -message AppList { - enum Type { - // Specified app_ids are supported. - WHITELIST = 1; - // Specified app_ids are not supported. - BLACKLIST = 2; - } - - // Whether to treat the app_id list as a Whitelist or Blacklist. - optional Type type = 1 [default = WHITELIST]; - - // List of AppIds. - repeated string app_id = 2; -}; - -message ServerContext { - // render_context encapsulates data about the device that is displaying the - // notifications. - optional RenderContext render_context = 1; - - // List of AppIds and whether it is a blacklist or whitelist. - // This field needs to be set only when the set of apps enabled on a client - // changes. In the server response, this field will get cleared. - optional AppList app_list = 2; - - // The view that the device has registered with. It is obtained from guns - // based on the app_list specified above. - optional string view_id = 3; -};
\ No newline at end of file diff --git a/sync/protocol/synced_notification_render.proto b/sync/protocol/synced_notification_render.proto deleted file mode 100644 index 5ee073e..0000000 --- a/sync/protocol/synced_notification_render.proto +++ /dev/null @@ -1,178 +0,0 @@ -// 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. -// - -// Update proto_value_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; - -// Data that is used directly by endpoints to render notifications in the case -// where no "native" app can handle the notification. -message SyncedNotificationRenderInfo { - // Render information for the collapsed (summary) view of a notification. - optional CollapsedInfo collapsed_info = 1; - - // Render information for the expanded view of a notification. - optional ExpandedInfo expanded_info = 2; -} - -// Render information for the collapsed (summary) view of a coalesced -// notification. -message CollapsedInfo { - optional SimpleCollapsedLayout simple_collapsed_layout = 1; - - // The creation time of the notification in microseconds since the UNIX - // epoch. - optional uint64 creation_timestamp_usec = 2; - - // The default destination target. - optional SyncedNotificationDestination default_destination = 3; - - repeated Target target = 4; - - // Defines a repeated list of meta tags that provide some context on what - // this collapsed info is describing. Nothing about the display of this - // collapsed info is defined by the meta tags. - repeated string meta_tag = 5; -} - -// Render information for the expanded (detail) view of a coalesced -// notification. -message ExpandedInfo { - optional SimpleExpandedLayout simple_expanded_layout = 1; - - // Collapsed information for each notification in the coalesced group. - repeated CollapsedInfo collapsed_info = 2; - - // A set of targets for actions the user can take, or destinations the - // viewer can be taken to. These relate to the coalesced notification. - repeated Target target = 3; - - // Enhanced context for the expanded view. - repeated string meta_tag = 4; -} - -message SimpleCollapsedLayout { - // Application icon. - optional SyncedNotificationImage app_icon = 1; - - // Profile image(s) of the notification creator(s) to show in the - // collapsed UI. - repeated SyncedNotificationProfileImage profile_image = 2; - - // Heading - often the name(s) of the notification creator(s). - optional string heading = 3; - - // Description - often the action that generated the notification. - optional string description = 4; - - // Media - one or more shared media items. - repeated Media media = 5; - - // Annotation - often the annotation of the entity generating the - // notification. - optional string annotation = 6; -} - -message SimpleExpandedLayout { - // Title - often the title of the underlying entity referred to by the - // notification(s). - optional string title = 1; - - // Text content - often a snippet of text from the underlying entity - // reference or the notification. - optional string text = 2; - - repeated Media media = 3; - - // Profile image, usually this is the creator of the referenced entity. - optional SyncedNotificationProfileImage profile_image = 4; - - // A set of targets for actions the user can take, or destinations the - // viewer can be taken to. Usually these relate to the referenced entity. - repeated Target target = 5; -} - -// Media. -message Media { - // TOOD(jro): Do we need other media types? - optional SyncedNotificationImage image = 1; -} - -// Secondary destinations and actions grouped into a message to account for -// ordering. -message Target { - // URL that the user will be taken to by clicking on the notification. - optional SyncedNotificationDestination destination = 1; - // URI to POST if the user clicks on a button. - optional SyncedNotificationAction action = 2; - - // A key to identify this target within a group of targets. - optional string target_key = 3; -} - -// A Destination is a target URL that the user can be taken to by clicking on or -// selecting the notification or part thereof. -message SyncedNotificationDestination { - // The description for the link to the destination. - optional string text = 1; - - // The icon to use for the link to the destination. - optional SyncedNotificationImage icon = 2; - - // The destination URL. - optional string url = 3; - - // Optional label to aid accessibility. - optional string accessibility_label = 4; -} - -// An Action encapsulates an UI component that trigger certain programmable -// actions. Depending on the endpoint, this may show up as a HTML button, an -// action button associated with the notification on native mobile, a link, or -// even the notification card itself. -message SyncedNotificationAction { - // The description for the Action. - optional string text = 1; - - // The icon to use for the Action. - optional SyncedNotificationImage icon = 2; - - // The URL that performs the action. - optional string url = 3; - - // Additional request data. - optional string request_data = 4; - - // Optional label to aid accessibility. - optional string accessibility_label= 5; - - // Defines a repeated list of meta tags that provide some context on this - // action. Nothing about the display of this action is defined by the tags. - repeated string meta_tag = 6; -} - -message SyncedNotificationImage { - // Note that the image may be from any source. Clients wishing to resize the - // image should ensure the image is proxied appropriately. - optional string url = 1; - optional string alt_text = 2; - optional int32 preferred_width = 3; - optional int32 preferred_height = 4; -} - -message SyncedNotificationProfileImage { - // Url for the image. - optional string image_url = 1; - // Object id for the image. - optional string oid = 2; - // Name to display for this image. - optional string display_name = 3; -} diff --git a/sync/protocol/synced_notification_specifics.proto b/sync/protocol/synced_notification_specifics.proto index 373ac57..910f280 100644 --- a/sync/protocol/synced_notification_specifics.proto +++ b/sync/protocol/synced_notification_specifics.proto @@ -3,9 +3,7 @@ // found in the LICENSE file. // // Sync protocol datatype extension for synced notifications. - -// Update proto_value_conversions{.h,.cc,_unittest.cc} if you change -// any fields in this file. +// DO NOT USE: This datatype is deprecated. syntax = "proto2"; @@ -14,11 +12,6 @@ option retain_unknown_fields = true; package sync_pb; -import "synced_notification_data.proto"; -import "synced_notification_render.proto"; - -// Properties of SyncedNotificationSpecifics objects. +// This message is kept around for backwards compatibility sake. message SyncedNotificationSpecifics { - // The notification from the server. - optional CoalescedSyncedNotification coalesced_notification = 1; } diff --git a/sync/sync.gyp b/sync/sync.gyp index 7544fbf..99478df 100644 --- a/sync/sync.gyp +++ b/sync/sync.gyp @@ -503,8 +503,6 @@ 'protocol/sync.proto', 'protocol/sync_enums.proto', 'protocol/synced_notification_app_info_specifics.proto', - 'protocol/synced_notification_data.proto', - 'protocol/synced_notification_render.proto', 'protocol/synced_notification_specifics.proto', 'protocol/test.proto', 'protocol/theme_specifics.proto', diff --git a/sync/tools/testserver/chromiumsync.py b/sync/tools/testserver/chromiumsync.py index 5487ef2..55bea94 100644 --- a/sync/tools/testserver/chromiumsync.py +++ b/sync/tools/testserver/chromiumsync.py @@ -50,8 +50,6 @@ import session_specifics_pb2 import sync_pb2 import sync_enums_pb2 import synced_notification_app_info_specifics_pb2 -import synced_notification_data_pb2 -import synced_notification_render_pb2 import synced_notification_specifics_pb2 import theme_specifics_pb2 import typed_url_specifics_pb2 @@ -1207,46 +1205,6 @@ class SyncDataModel(object): def GetInducedError(self): return self.induced_error - def AddSyncedNotification(self, serialized_notification): - """Adds a synced notification to the server data. - - The notification will be delivered to the client on the next GetUpdates - call. - - Args: - serialized_notification: A serialized CoalescedSyncedNotification. - - Returns: - The string representation of the added SyncEntity. - - Raises: - ClientNotConnectedError: if the client has not yet connected to this - server - """ - # A unique string used wherever a unique ID for this notification is - # required. - unique_notification_id = str(uuid.uuid4()) - - specifics = self._CreateSyncedNotificationEntitySpecifics( - unique_notification_id, serialized_notification) - - # Create the root SyncEntity representing a single notification. - entity = sync_pb2.SyncEntity() - entity.specifics.CopyFrom(specifics) - entity.parent_id_string = self._ServerTagToId( - 'google_chrome_synced_notifications') - entity.name = 'Synced notification added for testing' - entity.version = self._GetNextVersionNumber() - - entity.client_defined_unique_tag = self._CreateSyncedNotificationClientTag( - specifics.synced_notification.coalesced_notification.key) - entity.id_string = self._ClientTagToId(GetEntryType(entity), - entity.client_defined_unique_tag) - - self._entries[entity.id_string] = copy.deepcopy(entity) - - return google.protobuf.text_format.MessageToString(entity) - def _GetNextVersionNumber(self): """Set the version to one more than the greatest version number seen.""" entries = sorted(self._entries.values(), key=operator.attrgetter('version')) @@ -1254,97 +1212,6 @@ class SyncDataModel(object): raise ClientNotConnectedError return entries[-1].version + 1 - def _CreateSyncedNotificationEntitySpecifics(self, unique_id, - serialized_notification): - """Create the EntitySpecifics proto for a synced notification.""" - coalesced = synced_notification_data_pb2.CoalescedSyncedNotification() - google.protobuf.text_format.Merge(serialized_notification, coalesced) - - # Override the provided key so that we have a unique one. - coalesced.key = unique_id - - specifics = sync_pb2.EntitySpecifics() - notification_specifics = \ - synced_notification_specifics_pb2.SyncedNotificationSpecifics() - notification_specifics.coalesced_notification.CopyFrom(coalesced) - specifics.synced_notification.CopyFrom(notification_specifics) - - return specifics - - def _CreateSyncedNotificationClientTag(self, key): - """Create the client_defined_unique_tag value for a SyncedNotification. - - Args: - key: The entity used to create the client tag. - - Returns: - The string value of the to be used as the client_defined_unique_tag. - """ - serialized_type = sync_pb2.EntitySpecifics() - specifics = synced_notification_specifics_pb2.SyncedNotificationSpecifics() - serialized_type.synced_notification.CopyFrom(specifics) - hash_input = serialized_type.SerializeToString() + key - return base64.b64encode(hashlib.sha1(hash_input).digest()) - - def AddSyncedNotificationAppInfo(self, app_info): - """Adds an app info struct to the server data. - - The notification will be delivered to the client on the next GetUpdates - call. - - Args: - app_info: A serialized AppInfo. - - Returns: - The string representation of the added SyncEntity. - - Raises: - ClientNotConnectedError: if the client has not yet connected to this - server - """ - specifics = self._CreateSyncedNotificationAppInfoEntitySpecifics(app_info) - - # Create the root SyncEntity representing a single app info protobuf. - entity = sync_pb2.SyncEntity() - entity.specifics.CopyFrom(specifics) - entity.parent_id_string = self._ServerTagToId( - 'google_chrome_synced_notification_app_info') - entity.name = 'App info added for testing' - entity.version = self._GetNextVersionNumber() - - # App Infos do not have a strong id, it only needs to be unique. - entity.client_defined_unique_tag = "foo" - entity.id_string = "foo" - - self._entries[entity.id_string] = copy.deepcopy(entity) - - print "entity before exit is ", entity - - return google.protobuf.text_format.MessageToString(entity) - - def _CreateSyncedNotificationAppInfoEntitySpecifics( - self, synced_notification_app_info): - """Create the EntitySpecifics proto for a synced notification app info.""" - # Create a single, empty app_info object - app_info = \ - synced_notification_app_info_specifics_pb2.SyncedNotificationAppInfo() - # Fill the app_info object from the text format protobuf. - google.protobuf.text_format.Merge(synced_notification_app_info, app_info) - - # Create a new specifics object with a contained app_info - specifics = sync_pb2.EntitySpecifics() - app_info_specifics = \ - synced_notification_app_info_specifics_pb2.\ - SyncedNotificationAppInfoSpecifics() - - # Copy the app info from the text format protobuf - contained_app_info = app_info_specifics.synced_notification_app_info.add() - contained_app_info.CopyFrom(app_info) - - # And put the new app_info_specifics into the specifics before returning. - specifics.synced_notification_app_info.CopyFrom(app_info_specifics) - - return specifics class TestServer(object): """An object to handle requests for one (and only one) Chrome Sync account. @@ -1740,9 +1607,7 @@ class TestServer(object): """Customizes the value of the ClientCommand of ServerToClientResponse. Currently, this only allows for changing the sessions_commit_delay_seconds - field. This is useful for testing in conjunction with - AddSyncedNotification so that synced notifications are seen immediately - after triggering them with an HTTP call to the test server. + field. Args: sessions_commit_delay_seconds: The desired sync delay time for sessions. diff --git a/sync/tools/testserver/sync_testserver.py b/sync/tools/testserver/sync_testserver.py index 66789ea..b3ca642 100755 --- a/sync/tools/testserver/sync_testserver.py +++ b/sync/tools/testserver/sync_testserver.py @@ -154,10 +154,6 @@ class SyncPageHandler(testserver_base.BasePageHandler): self.ChromiumSyncEnablePreCommitGetUpdateAvoidanceHandler, self.GaiaOAuth2TokenHandler, self.GaiaSetOAuth2TokenResponseHandler, - self.TriggerSyncedNotificationHandler, - self.SyncedNotificationsPageHandler, - self.TriggerSyncedNotificationAppInfoHandler, - self.SyncedNotificationsAppInfoPageHandler, self.CustomizeClientCommandHandler] post_handlers = [self.ChromiumSyncCommandHandler, @@ -503,68 +499,6 @@ class SyncPageHandler(testserver_base.BasePageHandler): self.wfile.write(raw_reply) return True - def TriggerSyncedNotificationHandler(self): - test_name = "/triggersyncednotification" - if not self._ShouldHandleRequest(test_name): - return False - - query = urlparse.urlparse(self.path)[4] - query_params = urlparse.parse_qs(query) - - serialized_notification = '' - - if 'serialized_notification' in query_params: - serialized_notification = query_params['serialized_notification'][0] - - try: - notification_string = self.server._sync_handler.account \ - .AddSyncedNotification(serialized_notification) - reply = "A synced notification was triggered:\n\n" - reply += "<code>{}</code>.".format(notification_string) - response_code = 200 - except chromiumsync.ClientNotConnectedError: - reply = ('The client is not connected to the server, so the notification' - ' could not be created.') - response_code = 400 - - self.send_response(response_code) - self.send_header('Content-Type', 'text/html') - self.send_header('Content-Length', len(reply)) - self.end_headers() - self.wfile.write(reply) - return True - - def TriggerSyncedNotificationAppInfoHandler(self): - test_name = "/triggersyncednotificationappinfo" - if not self._ShouldHandleRequest(test_name): - return False - - query = urlparse.urlparse(self.path)[4] - query_params = urlparse.parse_qs(query) - - app_info = '' - - if 'synced_notification_app_info' in query_params: - app_info = query_params['synced_notification_app_info'][0] - - try: - app_info_string = self.server._sync_handler.account \ - .AddSyncedNotificationAppInfo(app_info) - reply = "A synced notification app info was sent:\n\n" - reply += "<code>{}</code>.".format(app_info_string) - response_code = 200 - except chromiumsync.ClientNotConnectedError: - reply = ('The client is not connected to the server, so the app info' - ' could not be created.') - response_code = 400 - - self.send_response(response_code) - self.send_header('Content-Type', 'text/html') - self.send_header('Content-Length', len(reply)) - self.end_headers() - self.wfile.write(reply) - return True - def CustomizeClientCommandHandler(self): test_name = "/customizeclientcommand" if not self._ShouldHandleRequest(test_name): @@ -595,36 +529,6 @@ class SyncPageHandler(testserver_base.BasePageHandler): self.wfile.write(reply) return True - def SyncedNotificationsPageHandler(self): - test_name = "/syncednotifications" - if not self._ShouldHandleRequest(test_name): - return False - - html = open('sync/tools/testserver/synced_notifications.html', 'r').read() - - self.send_response(200) - self.send_header('Content-Type', 'text/html') - self.send_header('Content-Length', len(html)) - self.end_headers() - self.wfile.write(html) - return True - - def SyncedNotificationsAppInfoPageHandler(self): - test_name = "/syncednotificationsappinfo" - if not self._ShouldHandleRequest(test_name): - return False - - html = \ - open('sync/tools/testserver/synced_notification_app_info.html', 'r').\ - read() - - self.send_response(200) - self.send_header('Content-Type', 'text/html') - self.send_header('Content-Length', len(html)) - self.end_headers() - self.wfile.write(html) - return True - class SyncServerRunner(testserver_base.TestServerRunner): """TestServerRunner for the net test servers.""" diff --git a/sync/tools/testserver/synced_notifications.html b/sync/tools/testserver/synced_notifications.html deleted file mode 100644 index 10cac30..0000000 --- a/sync/tools/testserver/synced_notifications.html +++ /dev/null @@ -1,69 +0,0 @@ -<html> - <head> - <title>Synced notifications</title> - - <script type="text/javascript"> - // Creates link (appended to the bottom of the page body) to trigger a - // synced notifications. The link's title will be |title| and - // |serialized_notification| is the ASCII-serialized version of the - // CoalescedSyncedNotification to be triggered. - function appendNotificationLink(title, serialized_notification) { - var link = document.createElement('a'); - link.innerHTML = title; - link.setAttribute('target', '_blank'); - link.setAttribute('href', 'triggersyncednotification?' + - 'serialized_notification=' + - encodeURIComponent(serialized_notification)); - document.body.appendChild(link); - } - </script> - </head> - - <body> - <h1>Synced notifications</h1> - - <h2>Step 0: Sign in to the browser and set up Sync</h2> - - <h2>Step 1: Click this link (only required once per server lifetime)</h2> - - <a href="/customizeclientcommand?sessions_commit_delay_seconds=0"> - Make notifications triggering instant</a> - - <h2>Step 2: Ctrl-Click the links below to trigger synced notifications</h2> - - <script type="text/javascript"> - appendNotificationLink('Simple notification', - 'key: \"foo\"\n' + - 'priority: 2\n' + - 'read_state: 1\n' + - 'render_info {\n' + - ' collapsed_info {\n' + - ' creation_timestamp_usec: 42\n' + - ' simple_collapsed_layout {\n' + - ' annotation: \"Space Needle, 12:00 pm\"\n' + - ' description: \"Space Needle, 12:00 pm\"\n' + - ' heading: \"New appointment\"\n' + - ' }\n' + - ' }\n' + - '}'); - </script> - <br/> - <script type="text/javascript"> - appendNotificationLink('New Service notification', - 'key: \"foo\"\n' + - 'app_id: \"maps_street_view\"\n' + - 'priority: 2\n' + - 'read_state: 1\n' + - 'render_info {\n' + - ' collapsed_info {\n' + - ' creation_timestamp_usec: 42\n' + - ' simple_collapsed_layout {\n' + - ' annotation: \"787 6th Street South\"\n' + - ' description: \"Building B\"\n' + - ' heading: \"Google Kirkland\"\n' + - ' }\n' + - ' }\n' + - '}'); - </script> - </body> -</html> diff --git a/sync/tools/testserver/synced_notifications_app_info.html b/sync/tools/testserver/synced_notifications_app_info.html deleted file mode 100644 index 42cbd12..0000000 --- a/sync/tools/testserver/synced_notifications_app_info.html +++ /dev/null @@ -1,49 +0,0 @@ -<html> - <head> - <title>Synced notification App Info</title> - - <script type="text/javascript"> - // Creates link (appended to the bottom of the page body) to trigger a - // new synced notification app info. The link's title will be |title| - // and the ASCII-serialized app info will be - // |synced_notification_app_info|. - function appendSyncedNotificationAppInfoLink(title, app_info) { - var link = document.createElement('a'); - link.innerHTML = title; - link.setAttribute('target', '_blank'); - link.setAttribute('href', 'triggersyncednotificationappinfo?' + - 'synced_notification_app_info=' + - encodeURIComponent(app_info)); - document.body.appendChild(link); - } - </script> - </head> - - <body> - <h1>Synced Notification App Info</h1> - - <h2>Step 0: Sign in to the browser and set up Sync</h2> - - <h2>Step 1: Click this link (only required once per server lifetime)</h2> - - <a href="/customizeclientcommand?sessions_commit_delay_seconds=0"> - Make synced notification app info triggering instant</a> - - <h2>Step 2: Ctrl-Click the link below to send a synced notification app info</h2> - - <script type="text/javascript"> - // JSON version of an app info protobuf - appendSyncedNotificationAppInfoLink( - 'Simple SyncedNotificationAppInfo', - 'settings_display_name: \"Google Maps\"\n' + - 'icon: {\n' + - ' alt_text: \"Google Maps\"\n' + - ' preferred_height: 80\n' + - ' preferred_width: 80\n' + - ' url: \"https://ssl.gstatic.com/s2/oz/images/notifications/app_icons/system-gplus_62d72f2ec5e1ef193f0dfa600eabcfeb.png\"\n' + - '}\n' + - 'app_id: \"maps_street_view\"\n' + - 'app_id: \"maps_earth_view\"\n'); - </script> - </body> -</html> |