Commit bffb296e authored by Jeffrey Cohen's avatar Jeffrey Cohen Committed by Commit Bot

[SendTabToSelf] Add model type controller to handle DICe signout

This is the most reliable way to make sure send tab to self information
is not tracked for syncing purposes while sync is paused (DICe signout).

Bug: 950642
Change-Id: I4998ea2bcfeb651590c4914249d12e170da13f02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1593401Reviewed-by: default avatarRoger Tawa <rogerta@chromium.org>
Reviewed-by: default avatarsebsg <sebsg@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Jeffrey Cohen <jeffreycohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656460}
parent 2f95f2b1
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "components/password_manager/core/browser/sync/password_model_type_controller.h" #include "components/password_manager/core/browser/sync/password_model_type_controller.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/reading_list/features/reading_list_switches.h" #include "components/reading_list/features/reading_list_switches.h"
#include "components/send_tab_to_self/send_tab_to_self_model_type_controller.h"
#include "components/send_tab_to_self/send_tab_to_self_sync_service.h" #include "components/send_tab_to_self/send_tab_to_self_sync_service.h"
#include "components/sync/base/report_unrecoverable_error.h" #include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/device_info/device_info_sync_service.h" #include "components/sync/device_info/device_info_sync_service.h"
...@@ -378,12 +379,13 @@ ProfileSyncComponentsFactoryImpl::CreateCommonDataTypeControllers( ...@@ -378,12 +379,13 @@ ProfileSyncComponentsFactoryImpl::CreateCommonDataTypeControllers(
if (!disabled_types.Has(syncer::SEND_TAB_TO_SELF) && if (!disabled_types.Has(syncer::SEND_TAB_TO_SELF) &&
base::FeatureList::IsEnabled(switches::kSyncSendTabToSelf)) { base::FeatureList::IsEnabled(switches::kSyncSendTabToSelf)) {
controllers.push_back(std::make_unique<syncer::ModelTypeController>( controllers.push_back(
syncer::SEND_TAB_TO_SELF, std::make_unique<send_tab_to_self::SendTabToSelfModelTypeController>(
std::make_unique<syncer::ForwardingModelTypeControllerDelegate>( sync_service,
sync_client_->GetSendTabToSelfSyncService() std::make_unique<syncer::ForwardingModelTypeControllerDelegate>(
->GetControllerDelegate() sync_client_->GetSendTabToSelfSyncService()
.get()))); ->GetControllerDelegate()
.get())));
} }
// Forward both on-disk and in-memory storage modes to the same delegate, // Forward both on-disk and in-memory storage modes to the same delegate,
......
...@@ -15,6 +15,8 @@ static_library("send_tab_to_self") { ...@@ -15,6 +15,8 @@ static_library("send_tab_to_self") {
"send_tab_to_self_model.cc", "send_tab_to_self_model.cc",
"send_tab_to_self_model.h", "send_tab_to_self_model.h",
"send_tab_to_self_model_observer.h", "send_tab_to_self_model_observer.h",
"send_tab_to_self_model_type_controller.cc",
"send_tab_to_self_model_type_controller.h",
"send_tab_to_self_sync_service.cc", "send_tab_to_self_sync_service.cc",
"send_tab_to_self_sync_service.h", "send_tab_to_self_sync_service.h",
] ]
...@@ -26,6 +28,7 @@ static_library("send_tab_to_self") { ...@@ -26,6 +28,7 @@ static_library("send_tab_to_self") {
"//components/sync", "//components/sync",
"//components/sync/device_info", "//components/sync/device_info",
"//components/version_info", "//components/version_info",
"//google_apis",
"//url", "//url",
] ]
public_deps = [ public_deps = [
......
...@@ -4,4 +4,5 @@ include_rules = [ ...@@ -4,4 +4,5 @@ include_rules = [
"+components/sync", "+components/sync",
"+components/version_info", "+components/version_info",
"+components/history", "+components/history",
"+google_apis",
] ]
// Copyright 2019 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 "components/send_tab_to_self/send_tab_to_self_model_type_controller.h"
#include <utility>
#include "base/feature_list.h"
#include "components/sync/driver/sync_auth_util.h"
#include "components/sync/driver/sync_service.h"
#include "google_apis/gaia/google_service_auth_error.h"
namespace send_tab_to_self {
SendTabToSelfModelTypeController::SendTabToSelfModelTypeController(
syncer::SyncService* sync_service,
std::unique_ptr<syncer::ModelTypeControllerDelegate> delegate)
: ModelTypeController(syncer::SEND_TAB_TO_SELF, std::move(delegate)),
sync_service_(sync_service) {
// TODO(crbug.com/906995): Remove this observing mechanism once all sync
// datatypes are stopped by ProfileSyncService, when sync is paused.
sync_service_->AddObserver(this);
}
SendTabToSelfModelTypeController::~SendTabToSelfModelTypeController() {
sync_service_->RemoveObserver(this);
}
bool SendTabToSelfModelTypeController::ReadyForStart() const {
DCHECK(CalledOnValidThread());
return !(syncer::IsWebSignout(sync_service_->GetAuthError()));
}
void SendTabToSelfModelTypeController::OnStateChanged(
syncer::SyncService* sync) {
DCHECK(CalledOnValidThread());
// Most of these calls will be no-ops but SyncService handles that just fine.
sync_service_->ReadyForStartChanged(type());
}
} // namespace send_tab_to_self
// Copyright 2019 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 COMPONENTS_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_MODEL_TYPE_CONTROLLER_H_
#define COMPONENTS_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_MODEL_TYPE_CONTROLLER_H_
#include "base/macros.h"
#include "components/sync/driver/model_type_controller.h"
#include "components/sync/driver/sync_service_observer.h"
namespace syncer {
class SyncService;
} // namespace syncer
namespace send_tab_to_self {
// Controls syncing of SEND_TAB_TO_SELF.
class SendTabToSelfModelTypeController : public syncer::ModelTypeController,
public syncer::SyncServiceObserver {
public:
// The |delegate| and |sync_service| must not be null. Furthermore,
// |sync_service| must outlive this object.
SendTabToSelfModelTypeController(
syncer::SyncService* sync_service,
std::unique_ptr<syncer::ModelTypeControllerDelegate> delegate);
~SendTabToSelfModelTypeController() override;
// DataTypeController overrides.
bool ReadyForStart() const override;
// syncer::SyncServiceObserver implementation.
void OnStateChanged(syncer::SyncService* sync) override;
private:
syncer::SyncService* const sync_service_;
DISALLOW_COPY_AND_ASSIGN(SendTabToSelfModelTypeController);
};
} // namespace send_tab_to_self
#endif // COMPONENTS_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_MODEL_TYPE_CONTROLLER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment