Commit 3706bd88 authored by Gayane Petrosyan's avatar Gayane Petrosyan Committed by Commit Bot

Revert "Reset NTP customizations when all settings are reset."

This reverts commit dbf62e53.

Reason for revert: Crash following
ProfileResetter::ResetNtpCustomizations() call.

Original change's description:
> Reset NTP customizations when all settings are reset.
>
> Bug: 931806
> Change-Id: I89db8c24edfb9a7e1c4c6bf3ac3d0faa68d70ca1
> Reviewed-on: https://chromium-review.googlesource.com/c/1472450
> Commit-Queue: Gayane Petrosyan <gayane@chromium.org>
> Reviewed-by: Balazs Engedy <engedy@chromium.org>
> Reviewed-by: Ramya Nagarajan <ramyan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#636087}

TBR=engedy@chromium.org,gayane@chromium.org,ramyan@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 936830
Change-Id: Ib81b7839c10f6bd7e75b438c2f98b015e866d4a5
Reviewed-on: https://chromium-review.googlesource.com/c/1495749Reviewed-by: default avatarGayane Petrosyan <gayane@chromium.org>
Commit-Queue: Gayane Petrosyan <gayane@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636610}
parent 485a5222
......@@ -22,7 +22,6 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profile_resetter/brandcoded_default_settings.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/instant_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
......@@ -82,7 +81,6 @@ ProfileResetter::ProfileResetter(Profile* profile)
template_url_service_(TemplateURLServiceFactory::GetForProfile(profile_)),
pending_reset_flags_(0),
cookies_remover_(nullptr),
ntp_service_(InstantServiceFactory::GetForProfile(profile)),
weak_ptr_factory_(this) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(profile_);
......@@ -130,7 +128,6 @@ void ProfileResetter::Reset(
{STARTUP_PAGES, &ProfileResetter::ResetStartupPages},
{PINNED_TABS, &ProfileResetter::ResetPinnedTabs},
{SHORTCUTS, &ProfileResetter::ResetShortcuts},
{NTP_CUSTOMIZATIONS, &ProfileResetter::ResetNtpCustomizations},
};
ResettableFlags reset_triggered_for_flags = 0;
......@@ -337,11 +334,6 @@ void ProfileResetter::ResetShortcuts() {
#endif
}
void ProfileResetter::ResetNtpCustomizations() {
ntp_service_->ResetToDefault();
MarkAsDone(NTP_CUSTOMIZATIONS);
}
void ProfileResetter::OnTemplateURLServiceLoaded() {
// TemplateURLService has loaded. If we need to clean search engines, it's
// time to go on.
......
......@@ -19,7 +19,6 @@
#include "base/sequence_checker.h"
#include "base/strings/string16.h"
#include "chrome/browser/profile_resetter/brandcoded_default_settings.h"
#include "chrome/browser/search/instant_service.h"
#include "components/search_engines/template_url_service.h"
#include "content/public/browser/browsing_data_remover.h"
......@@ -29,10 +28,6 @@ namespace base {
class CancellationFlag;
}
namespace {
FORWARD_DECLARE_TEST(ProfileResetterTest, ResetNTPCustomizationsTest);
}
// This class allows resetting certain aspects of a profile to default values.
// It is used in case the profile has been damaged due to malware or bad user
// settings.
......@@ -48,12 +43,11 @@ class ProfileResetter : public content::BrowsingDataRemover::Observer {
STARTUP_PAGES = 1 << 5,
PINNED_TABS = 1 << 6,
SHORTCUTS = 1 << 7,
NTP_CUSTOMIZATIONS = 1 << 8,
// Update ALL if you add new values and check whether the type of
// ResettableFlags needs to be enlarged.
ALL = DEFAULT_SEARCH_ENGINE | HOMEPAGE | CONTENT_SETTINGS |
COOKIES_AND_SITE_DATA | EXTENSIONS | STARTUP_PAGES | PINNED_TABS |
SHORTCUTS | NTP_CUSTOMIZATIONS
SHORTCUTS
};
// Bit vector for Resettable enum.
......@@ -75,8 +69,6 @@ class ProfileResetter : public content::BrowsingDataRemover::Observer {
virtual bool IsActive() const;
private:
FRIEND_TEST_ALL_PREFIXES(::ProfileResetterTest, ResetNTPCustomizationsTest);
// Marks |resettable| as done and triggers |callback_| if all pending jobs
// have completed.
void MarkAsDone(Resettable resettable);
......@@ -89,7 +81,6 @@ class ProfileResetter : public content::BrowsingDataRemover::Observer {
void ResetStartupPages();
void ResetPinnedTabs();
void ResetShortcuts();
void ResetNtpCustomizations();
// BrowsingDataRemover::Observer:
void OnBrowsingDataRemoverDone() override;
......@@ -116,9 +107,6 @@ class ProfileResetter : public content::BrowsingDataRemover::Observer {
SEQUENCE_CHECKER(sequence_checker_);
// Used for resetting NTP customizations.
InstantService* ntp_service_;
base::WeakPtrFactory<ProfileResetter> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ProfileResetter);
......
......@@ -28,7 +28,6 @@
#include "chrome/browser/profile_resetter/profile_reset_report.pb.h"
#include "chrome/browser/profile_resetter/profile_resetter_test_base.h"
#include "chrome/browser/profile_resetter/resettable_settings_snapshot.h"
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
......@@ -320,14 +319,6 @@ void ShortcutHandler::Delete() {
}
#endif // defined(OS_WIN)
// MockInstantService
class MockInstantService : public InstantService {
public:
explicit MockInstantService(Profile* profile) : InstantService(profile) {}
~MockInstantService() override = default;
MOCK_METHOD0(ResetToDefault, void());
};
// helper functions -----------------------------------------------------------
......@@ -1027,12 +1018,4 @@ TEST_F(ProfileResetterTest, DestroySnapshotFast) {
base::RunLoop().RunUntilIdle();
}
TEST_F(ProfileResetterTest, ResetNTPCustomizationsTest) {
MockInstantService mock_ntp_service(profile());
resetter_->ntp_service_ = &mock_ntp_service;
EXPECT_CALL(mock_ntp_service, ResetToDefault());
ResetAndWait(ProfileResetter::NTP_CUSTOMIZATIONS);
}
} // namespace
......@@ -711,11 +711,6 @@ bool InstantService::IsCustomBackgroundSet() {
return true;
}
void InstantService::ResetToDefault() {
ResetCustomLinks();
ResetCustomBackgroundThemeInfo();
}
bool InstantService::IsCustomBackgroundPrefValid(GURL& custom_background_url) {
const base::DictionaryValue* background_info =
profile_->GetPrefs()->GetDictionary(prefs::kNtpCustomBackgroundDict);
......
......@@ -101,8 +101,8 @@ class InstantService : public KeyedService,
bool UndoCustomLinkAction();
// Invoked when the Instant page wants to delete all custom links and use Most
// Visited sites instead. Returns false and does nothing if the profile is
// using a non-Google search provider. Marked virtual for mocking in tests.
virtual bool ResetCustomLinks();
// using a non-Google search provider.
bool ResetCustomLinks();
// Invoked by the InstantController to update theme information for NTP.
//
......@@ -146,10 +146,6 @@ class InstantService : public KeyedService,
// Check if a custom background has been set by the user.
bool IsCustomBackgroundSet();
// Reset all NTP customizations to default. Marked virtual for mocking in
// tests.
virtual void ResetToDefault();
private:
class SearchProviderObserver;
......@@ -194,8 +190,7 @@ class InstantService : public KeyedService,
void ApplyCustomBackgroundThemeInfo();
// Marked virtual for mocking in tests.
virtual void ResetCustomBackgroundThemeInfo();
void ResetCustomBackgroundThemeInfo();
void FallbackToDefaultThemeInfo();
......
......@@ -20,7 +20,6 @@
#include "chrome/common/url_constants.h"
#include "components/ntp_tiles/constants.h"
#include "components/ntp_tiles/ntp_tile.h"
#include "components/ntp_tiles/pref_names.h"
#include "components/ntp_tiles/section_type.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -47,15 +46,6 @@ base::DictionaryValue GetBackgroundInfoAsDict(const GURL& background_url) {
return background_info;
}
class MockInstantService : public InstantService {
public:
explicit MockInstantService(Profile* profile) : InstantService(profile) {}
~MockInstantService() override = default;
MOCK_METHOD0(ResetCustomLinks, bool());
MOCK_METHOD0(ResetCustomBackgroundThemeInfo, void());
};
} // namespace
using InstantServiceTest = InstantUnitTestBase;
......@@ -439,13 +429,6 @@ TEST_F(InstantServiceTest, ValidateBackdropUrls) {
EXPECT_FALSE(instant_service_->IsCustomBackgroundSet());
}
TEST_F(InstantServiceTest, TestResetToDefault) {
MockInstantService mock_instant_service_(profile());
EXPECT_CALL(mock_instant_service_, ResetCustomLinks());
EXPECT_CALL(mock_instant_service_, ResetCustomBackgroundThemeInfo());
mock_instant_service_.ResetToDefault();
}
class InstantServiceThemeTest : public InstantServiceTest {
public:
InstantServiceThemeTest() {}
......
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