Commit 057a95df authored by Hans Wennborg's avatar Hans Wennborg Committed by Commit Bot

Revert "[SendTabToSelf] Don't show send tab to self entry points when sync is paused"

This reverts commit 6b3b1630.

Reason for revert:
The test crashes in official Linux builds and UBSan-vptr builds,
see second bug below.

Original change's description:
> [SendTabToSelf] Don't show send tab to self entry points when sync is paused
> 
> Bug: 950642
> Change-Id: I772378ceaa7e4d43fce185a8e8d251325483788b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1573158
> Commit-Queue: Tina Wang <tinazwang@chromium.org>
> Reviewed-by: sebsg <sebsg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#655805}

TBR=sebsg@chromium.org,tgupta@chromium.org,tinazwang@chromium.org

Change-Id: I9776016673244e9da2c2219452f3b5b0a2a836df
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 950642, 958738
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1591927Reviewed-by: default avatarHans Wennborg <hans@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#655946}
parent 052c6e69
......@@ -14,7 +14,6 @@
#include "components/sync/device_info/device_info.h"
#include "components/sync/device_info/device_info_sync_service.h"
#include "components/sync/device_info/device_info_tracker.h"
#include "components/sync/driver/profile_sync_service.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_user_settings.h"
......@@ -34,13 +33,6 @@ bool IsSendingEnabled() {
base::FeatureList::IsEnabled(kSendTabToSelfShowSendingUI);
}
bool IsSyncPaused(Profile* profile) {
syncer::ProfileSyncService* service =
ProfileSyncServiceFactory::GetAsProfileSyncServiceForProfile(profile);
return service->GetDisableReasons() ==
syncer::SyncService::DISABLE_REASON_PAUSED;
}
bool IsUserSyncTypeActive(Profile* profile) {
SendTabToSelfSyncService* service =
SendTabToSelfSyncServiceFactory::GetForProfile(profile);
......@@ -58,12 +50,6 @@ bool IsSyncingOnMultipleDevices(Profile* profile) {
device_sync_service->GetDeviceInfoTracker()->CountActiveDevices() > 1;
}
bool IsSettingRequirementsMet(Profile* profile) {
// If sending is enabled, then so is receiving.
return IsSendingEnabled() && !IsSyncPaused(profile) &&
IsUserSyncTypeActive(profile) && IsSyncingOnMultipleDevices(profile);
}
bool IsContentRequirementsMet(const GURL& url, Profile* profile) {
bool is_http_or_https = url.SchemeIsHTTPOrHTTPS();
bool is_native_page = url.SchemeIs(content::kChromeUIScheme);
......@@ -79,7 +65,9 @@ bool ShouldOfferFeature(content::WebContents* web_contents) {
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
return IsSettingRequirementsMet(profile) &&
// If sending is enabled, then so is receiving.
return IsSendingEnabled() && IsUserSyncTypeActive(profile) &&
IsSyncingOnMultipleDevices(profile) &&
IsContentRequirementsMet(web_contents->GetURL(), profile);
}
......@@ -89,7 +77,8 @@ bool ShouldOfferFeatureForLink(content::WebContents* web_contents,
return false;
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
return IsSettingRequirementsMet(profile) &&
return IsSendingEnabled() && IsUserSyncTypeActive(profile) &&
IsSyncingOnMultipleDevices(profile) &&
(IsContentRequirementsMet(web_contents->GetURL(), profile) ||
IsContentRequirementsMet(link_url, profile));
}
......
......@@ -21,18 +21,12 @@ bool IsReceivingEnabled();
// flags are enabled.
bool IsSendingEnabled();
// Return true if the the sync mode is paused.
bool IsSyncPaused(Profile* profile);
// Returns true if the SendTabToSelf sync datatype is active.
bool IsUserSyncTypeActive(Profile* profile);
// Returns true if the user syncing on two or more devices.
bool IsSyncingOnMultipleDevices(Profile* profile);
// Returns true if the flag and sync setting requirements are met.
bool IsSettingRequirementsMet(Profile* profile);
// Returns true if the tab and web content requirements are met:
// User is viewing an HTTP or HTTPS page.
// User is not on a native page.
......
......@@ -185,14 +185,6 @@ TEST_F(SendTabToSelfUtilTest, IsOnlySendingEnabled_False) {
EXPECT_FALSE(IsReceivingEnabled());
}
TEST_F(SendTabToSelfUtilTest, IsSyncPaused) {
EXPECT_FALSE(IsSyncPaused(profile()));
test_sync_service_->SetDisableReasons(
syncer::SyncService::DISABLE_REASON_PAUSED);
EXPECT_TRUE(IsSyncPaused(profile()));
}
TEST_F(SendTabToSelfUtilTest, IsSyncingOnMultipleDevices_True) {
mock_device_sync_service_->SetTrackerActiveDevices(2);
......
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