summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2016-03-15 12:20:06 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-15 19:21:20 +0000
commit76ea109e501ad804a4539f61028515d7ff9b7e07 (patch)
treee9f70f064d47aecb7ee4d35accff9d65ae7c27fe
parentb8ec5143caf3fb0e2858e2abab6c1983eaa9462f (diff)
downloadchromium_src-76ea109e501ad804a4539f61028515d7ff9b7e07.zip
chromium_src-76ea109e501ad804a4539f61028515d7ff9b7e07.tar.gz
chromium_src-76ea109e501ad804a4539f61028515d7ff9b7e07.tar.bz2
[Extensions] Remove unused parts of the preferencesPrivate API
easyUnlockProximityRequired might still be used by someone, but it looks like the rest of this API can be removed. BUG=593166 TBR=erg@chromium.org (profiles/ pref change reviewed by gab@) Review URL: https://codereview.chromium.org/1776373002 Cr-Commit-Position: refs/heads/master@{#381278}
-rw-r--r--chrome/browser/extensions/api/preference/chrome_direct_setting_api.cc1
-rw-r--r--chrome/browser/extensions/api/preferences_private/preferences_private_api.cc69
-rw-r--r--chrome/browser/extensions/api/preferences_private/preferences_private_api.h41
-rw-r--r--chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc209
-rw-r--r--chrome/browser/prefs/browser_prefs.cc15
-rw-r--r--chrome/browser/profiles/profile.cc3
-rw-r--r--chrome/chrome_browser_extensions.gypi2
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/common/extensions/api/preferences_private.json28
-rw-r--r--chrome/common/pref_names.cc6
-rw-r--r--chrome/common/pref_names.h3
11 files changed, 16 insertions, 362 deletions
diff --git a/chrome/browser/extensions/api/preference/chrome_direct_setting_api.cc b/chrome/browser/extensions/api/preference/chrome_direct_setting_api.cc
index e40a5f1..635d127 100644
--- a/chrome/browser/extensions/api/preference/chrome_direct_setting_api.cc
+++ b/chrome/browser/extensions/api/preference/chrome_direct_setting_api.cc
@@ -31,7 +31,6 @@ class PreferenceWhitelist {
// installed. Otherwise, users may install your extension, the extension may
// toggle settings, and after the extension has been disabled/uninstalled
// the toggled setting remains in place. See http://crbug.com/164227#c157 .
- whitelist_.insert("googlegeolocationaccess.enabled");
// The following settings need to be checked and probably removed. See
// http://crbug.com/164227#c157 .
whitelist_.insert("easy_unlock.proximity_required");
diff --git a/chrome/browser/extensions/api/preferences_private/preferences_private_api.cc b/chrome/browser/extensions/api/preferences_private/preferences_private_api.cc
deleted file mode 100644
index 82de6f7..0000000
--- a/chrome/browser/extensions/api/preferences_private/preferences_private_api.cc
+++ /dev/null
@@ -1,69 +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/preferences_private/preferences_private_api.h"
-
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sync/profile_sync_service_factory.h"
-#include "chrome/common/extensions/api/preferences_private.h"
-#include "components/browser_sync/browser/profile_sync_service.h"
-#include "components/sync_driver/sync_prefs.h"
-
-namespace extensions {
-
-namespace GetSyncCategoriesWithoutPassphrase =
- api::preferences_private::GetSyncCategoriesWithoutPassphrase;
-
-PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction::
-PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction() {}
-
-PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction::
-~PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction() {}
-
-void
-PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction::OnStateChanged() {
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetForProfile(GetProfile());
- if (sync_service->IsSyncActive()) {
- sync_service->RemoveObserver(this);
- RunAsync();
- Release(); // Balanced in RunAsync().
- }
-}
-
-bool PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction::RunAsync() {
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetForProfile(GetProfile());
- if (!sync_service)
- return false;
- if (!sync_service->IsSyncActive()) {
- AddRef(); // Balanced in OnStateChanged().
- sync_service->AddObserver(this);
- return true;
- }
-
- syncer::ModelTypeSet result_set = syncer::UserSelectableTypes();
-
- // Only include categories that are synced.
- sync_driver::SyncPrefs sync_prefs(GetProfile()->GetPrefs());
- if (!sync_prefs.HasKeepEverythingSynced()) {
- result_set = syncer::Intersection(result_set,
- sync_service->GetPreferredDataTypes());
- }
- // Don't include encrypted categories.
- result_set = syncer::Difference(result_set,
- sync_service->GetEncryptedDataTypes());
-
- std::vector<std::string> categories;
- for (syncer::ModelTypeSet::Iterator it = result_set.First(); it.Good();
- it.Inc()) {
- categories.push_back(syncer::ModelTypeToString(it.Get()));
- }
-
- results_ = GetSyncCategoriesWithoutPassphrase::Results::Create(categories);
- SendResponse(true);
- return true;
-}
-
-} // namespace extensions
diff --git a/chrome/browser/extensions/api/preferences_private/preferences_private_api.h b/chrome/browser/extensions/api/preferences_private/preferences_private_api.h
deleted file mode 100644
index a9c4665..0000000
--- a/chrome/browser/extensions/api/preferences_private/preferences_private_api.h
+++ /dev/null
@@ -1,41 +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_PREFERENCES_PRIVATE_PREFERENCES_PRIVATE_API_H_
-#define CHROME_BROWSER_EXTENSIONS_API_PREFERENCES_PRIVATE_PREFERENCES_PRIVATE_API_H_
-
-#include "base/macros.h"
-#include "chrome/browser/extensions/chrome_extension_function.h"
-#include "components/sync_driver/sync_service_observer.h"
-#include "extensions/browser/extension_function.h"
-
-namespace extensions {
-
-class PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction
- : public ChromeAsyncExtensionFunction,
- public sync_driver::SyncServiceObserver {
- public:
- DECLARE_EXTENSION_FUNCTION(
- "preferencesPrivate.getSyncCategoriesWithoutPassphrase",
- PREFERENCESPRIVATE_GETSYNCCATEGORIESWITHOUTPASSPHRASE)
-
- PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction();
-
- protected:
- ~PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction() override;
-
- private:
- // sync_driver::SyncServiceObserver:
- void OnStateChanged() override;
-
- // ExtensionFunction:
- bool RunAsync() override;
-
- DISALLOW_COPY_AND_ASSIGN(
- PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction);
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCES_PRIVATE_PREFERENCES_PRIVATE_API_H_
diff --git a/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc b/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc
deleted file mode 100644
index 75101a4..0000000
--- a/chrome/browser/extensions/api/preferences_private/preferences_private_apitest.cc
+++ /dev/null
@@ -1,209 +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 "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/location.h"
-#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/path_service.h"
-#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
-#include "base/values.h"
-#include "build/build_config.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/extensions/api/preferences_private/preferences_private_api.h"
-#include "chrome/browser/extensions/extension_apitest.h"
-#include "chrome/browser/extensions/extension_function_test_utils.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
-#include "chrome/browser/sync/chrome_sync_client.h"
-#include "chrome/browser/sync/profile_sync_service_factory.h"
-#include "chrome/browser/sync/profile_sync_test_util.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/common/channel_info.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/test/base/testing_profile.h"
-#include "components/bookmarks/common/bookmark_constants.h"
-#include "components/browser_sync/browser/profile_sync_service.h"
-#include "components/sync_driver/signin_manager_wrapper.h"
-#include "components/sync_driver/sync_api_component_factory_mock.h"
-#include "components/sync_driver/sync_prefs.h"
-#include "content/public/browser/browser_context.h"
-#include "extensions/test/extension_test_message_listener.h"
-
-#if defined(OS_CHROMEOS)
-#include "chromeos/chromeos_switches.h"
-#endif
-
-using extensions::PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction;
-
-namespace {
-
-class FakeProfileSyncService : public ProfileSyncService {
- public:
- explicit FakeProfileSyncService(Profile* profile)
- : ProfileSyncService(CreateProfileSyncServiceParamsForTest(profile)),
- test_started_(false),
- sync_initialized_(true),
- initialized_state_violation_(false) {}
-
- ~FakeProfileSyncService() override {}
-
- static scoped_ptr<KeyedService> BuildFakeProfileSyncService(
- content::BrowserContext* context) {
- return make_scoped_ptr(
- new FakeProfileSyncService(static_cast<Profile*>(context)));
- }
-
- void set_test_started(bool test_started) {
- test_started_ = test_started;
- }
-
- void set_sync_initialized(bool sync_initialized) {
- sync_initialized_ = sync_initialized;
- }
-
- bool initialized_state_violation() { return initialized_state_violation_; }
-
- // ProfileSyncService:
- bool IsSyncActive() const override { return sync_initialized_; }
-
- void AddObserver(sync_driver::SyncServiceObserver* observer) override {
- // Ignore other SyncServiceObsevers which we don't care about.
- if (!test_started_)
- return;
-
- if (sync_initialized_)
- initialized_state_violation_ = true;
- // Set sync initialized state to true so the function will run after
- // OnStateChanged is called.
- sync_initialized_ = true;
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&sync_driver::SyncServiceObserver::OnStateChanged,
- base::Unretained(observer)));
- }
-
- syncer::ModelTypeSet GetEncryptedDataTypes() const override {
- if (!sync_initialized_)
- initialized_state_violation_ = true;
- syncer::ModelTypeSet type_set;
- type_set.Put(syncer::AUTOFILL);
- return type_set;
- }
-
- syncer::ModelTypeSet GetPreferredDataTypes() const override {
- if (!sync_initialized_)
- initialized_state_violation_ = true;
- syncer::ModelTypeSet preferred_types =
- syncer::UserSelectableTypes();
- preferred_types.Remove(syncer::TYPED_URLS);
- return preferred_types;
- }
-
- private:
- bool test_started_;
- bool sync_initialized_;
- // Set to true if a function is called when sync_initialized is in an
- // unexpected state.
- mutable bool initialized_state_violation_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeProfileSyncService);
-};
-
-class PreferencesPrivateApiTest : public ExtensionApiTest {
- public:
- PreferencesPrivateApiTest() : browser_(NULL), service_(NULL) {}
- ~PreferencesPrivateApiTest() override {}
-
- void SetUpCommandLine(base::CommandLine* command_line) override {
-#if defined(OS_CHROMEOS)
- command_line->AppendSwitch(
- chromeos::switches::kIgnoreUserProfileMappingForTests);
-#endif
- }
-
- void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
-
- base::FilePath path;
- PathService::Get(chrome::DIR_USER_DATA, &path);
- path = path.AppendASCII("test_profile");
- if (!base::PathExists(path))
- CHECK(base::CreateDirectory(path));
-
- Profile* profile =
- Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
- sync_driver::SyncPrefs sync_prefs(profile->GetPrefs());
- sync_prefs.SetKeepEverythingSynced(false);
-
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- profile_manager->RegisterTestingProfile(profile, true, false);
-
- service_ = static_cast<FakeProfileSyncService*>(
- ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile, &FakeProfileSyncService::BuildFakeProfileSyncService));
-
- browser_ = new Browser(Browser::CreateParams(profile));
-
- service_->set_test_started(true);
- }
-
- // Calls GetSyncCategoriesWithoutPassphraseFunction and verifies that the
- // results returned are the expected ones.
- void TestGetSyncCategoriesWithoutPassphraseFunction();
-
- protected:
- Browser* browser_;
- FakeProfileSyncService* service_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(PreferencesPrivateApiTest);
-};
-
-void
-PreferencesPrivateApiTest::TestGetSyncCategoriesWithoutPassphraseFunction() {
- scoped_refptr<PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction>
- function(
- new PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction);
- ASSERT_TRUE(extension_function_test_utils::RunFunction(
- function.get(), "[]", browser_, extension_function_test_utils::NONE));
- EXPECT_FALSE(service_->initialized_state_violation());
-
- const base::ListValue* result = function->GetResultList();
- EXPECT_EQ(1u, result->GetSize());
-
- const base::ListValue* categories = NULL;
- ASSERT_TRUE(result->GetList(0, &categories));
- EXPECT_NE(categories->end(),
- categories->Find(base::StringValue(bookmarks::kBookmarksFileName)));
- EXPECT_NE(categories->end(),
- categories->Find(base::StringValue(chrome::kPreferencesFilename)));
- EXPECT_EQ(categories->end(),
- categories->Find(base::StringValue("Autofill"))) <<
- "Encrypted categories should not be present";
- EXPECT_EQ(categories->end(),
- categories->Find(base::StringValue("Typed URLs"))) <<
- "Unsynced categories should not be present";
-}
-
-IN_PROC_BROWSER_TEST_F(PreferencesPrivateApiTest,
- GetSyncCategoriesWithoutPassphrase) {
- TestGetSyncCategoriesWithoutPassphraseFunction();
-}
-
-// Verifies that we wait for the sync service to be ready before checking
-// encryption status.
-IN_PROC_BROWSER_TEST_F(PreferencesPrivateApiTest,
- GetSyncCategoriesWithoutPassphraseAsynchronous) {
- service_->set_sync_initialized(false);
- TestGetSyncCategoriesWithoutPassphraseFunction();
-}
-
-} // namespace
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 8535069..5698bfa 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -272,6 +272,12 @@ const char kOverscrollVerticalResistThreshold[] =
"overscroll.vertical_resist_threshold";
#endif // defined(USE_AURA)
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
+// Deprecated 3/2016
+const char kGoogleGeolocationAccessEnabled[] =
+ "googlegeolocationaccess.enabled";
+#endif
+
} // namespace
namespace chrome {
@@ -580,6 +586,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterListPref(kURLsToRestoreOnStartupOld);
registry->RegisterInt64Pref(kRestoreStartupURLsMigrationTime, 0);
registry->RegisterBooleanPref(kRestoreOnStartupMigrated, false);
+
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
+ registry->RegisterBooleanPref(kGoogleGeolocationAccessEnabled, false);
+#endif
}
void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
@@ -656,6 +666,11 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
profile_prefs->ClearPref(kOverscrollHorizontalResistThreshold);
profile_prefs->ClearPref(kOverscrollVerticalResistThreshold);
#endif // defined(USE_AURA)
+
+#if BUILDFLAG(ENABLE_GOOGLE_NOW)
+ // Added 3/2016.
+ profile_prefs->ClearPref(kGoogleGeolocationAccessEnabled);
+#endif
}
} // namespace chrome
diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc
index 4e70a7e..5f13d07 100644
--- a/chrome/browser/profiles/profile.cc
+++ b/chrome/browser/profiles/profile.cc
@@ -99,9 +99,6 @@ void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(prefs::kSafeBrowsingIncidentsSent);
registry->RegisterBooleanPref(
prefs::kSafeBrowsingExtendedReportingOptInAllowed, true);
-#if BUILDFLAG(ENABLE_GOOGLE_NOW)
- registry->RegisterBooleanPref(prefs::kGoogleGeolocationAccessEnabled, false);
-#endif
// This pref is intentionally outside the above #if. That flag corresponds
// to the Notifier extension and does not gate the launcher page.
// TODO(skare): Remove or rename ENABLE_GOOGLE_NOW: http://crbug.com/459827.
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index 70d4471..a4d9dc7 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -429,8 +429,6 @@
'browser/extensions/api/preference/preference_api_constants.h',
'browser/extensions/api/preference/preference_helpers.cc',
'browser/extensions/api/preference/preference_helpers.h',
- 'browser/extensions/api/preferences_private/preferences_private_api.cc',
- 'browser/extensions/api/preferences_private/preferences_private_api.h',
'browser/extensions/api/principals_private/principals_private_api.cc',
'browser/extensions/api/principals_private/principals_private_api.h',
'browser/extensions/api/proxy/proxy_api.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 29cec21..584e26d2 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -185,7 +185,6 @@
'browser/extensions/api/permissions/permissions_apitest.cc',
'browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc',
'browser/extensions/api/preference/preference_apitest.cc',
- 'browser/extensions/api/preferences_private/preferences_private_apitest.cc',
'browser/extensions/api/processes/processes_apitest.cc',
'browser/extensions/api/proxy/proxy_apitest.cc',
'browser/extensions/api/resources_private/resources_private_apitest.cc',
diff --git a/chrome/common/extensions/api/preferences_private.json b/chrome/common/extensions/api/preferences_private.json
index 8044178a..e409fb1 100644
--- a/chrome/common/extensions/api/preferences_private.json
+++ b/chrome/common/extensions/api/preferences_private.json
@@ -12,33 +12,7 @@
"$ref": "types.private.ChromeDirectSetting",
"value": ["easy_unlock.proximity_required", {"type":"boolean"}],
"description": "If true, a remote Easy Unlock device can only unlock the local device if it is in very close proximity (roughly, within a foot). This preference's value is a boolean, defaulting to <code>false</code>."
- },
- "googleGeolocationAccessEnabled": {
- "nocompile": true,
- "$ref": "types.private.ChromeDirectSetting",
- "value": ["googlegeolocationaccess.enabled", {"type":"boolean"}],
- "description": "If enabled, Google services can access the user's location. This preference's value is a boolean, defaulting to <code>false</code>."
- }
- },
- "functions": [
- {
- "name": "getSyncCategoriesWithoutPassphrase",
- "description": "Returns a list of sync categories the user has enabled without using a custom passphrase for encryption. The possible values are those that can be returned from syncer::ModelTypeToString in sync/syncable/model_type.cc.",
- "type": "function",
- "parameters": [
- {
- "name": "callback",
- "type": "function",
- "parameters": [
- {
- "name": "categories",
- "type": "array",
- "items": {"type": "string"}
- }
- ]
- }
- ]
}
- ]
+ }
}
]
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index cb643bb..503c0f9 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1577,12 +1577,6 @@ const char kWebAppCreateInQuickLaunchBar[] =
// corresponding access token.
const char kGeolocationAccessToken[] = "geolocation.access_token";
-#if BUILDFLAG(ENABLE_GOOGLE_NOW)
-// Boolean that is true when Google services can use the user's location.
-const char kGoogleGeolocationAccessEnabled[] =
- "googlegeolocationaccess.enabled";
-#endif
-
// Boolean that specifies whether to enable the Google Now Launcher extension.
// Note: This is not the notifications component gated by ENABLE_GOOGLE_NOW.
const char kGoogleNowLauncherEnabled[] = "google_now_launcher.enabled";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 38ff6ae..1e3bd63 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -562,9 +562,6 @@ extern const char kWebAppCreateInQuickLaunchBar[];
extern const char kGeolocationAccessToken[];
-#if BUILDFLAG(ENABLE_GOOGLE_NOW)
-extern const char kGoogleGeolocationAccessEnabled[];
-#endif
extern const char kGoogleNowLauncherEnabled[];
extern const char kDefaultAudioCaptureDevice[];