summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-05 23:49:19 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-05 23:49:19 +0000
commit0f9e6265d2803430e434c61d4ff328b53f4b6b99 (patch)
tree0d6e4249f01ee086586e3ca44e08d0fece82ced3 /chrome/browser/extensions
parentfcdb90d62005c7892c39568bfef4ee14908bea91 (diff)
downloadchromium_src-0f9e6265d2803430e434c61d4ff328b53f4b6b99.zip
chromium_src-0f9e6265d2803430e434c61d4ff328b53f4b6b99.tar.gz
chromium_src-0f9e6265d2803430e434c61d4ff328b53f4b6b99.tar.bz2
extensions: Remove Blacklist dependency from ExtensionPrefs.
ExtensionPrefs, which I'm in the process of moving to the top-level extensions/ directory, depends on an enum value from the Blacklist class, which appears to be tied to safe browsing, a Chrome-specific feature. This change replaces ExtensionPrefs's use of the enum with a bool. BUG=313284 TBR=thestig@chromium.org, xiyuan@chromium.org Review URL: https://codereview.chromium.org/57563006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233140 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/api/preference/preference_api_prefs_unittest.cc2
-rw-r--r--chrome/browser/extensions/extension_browsertest.cc2
-rw-r--r--chrome/browser/extensions/extension_prefs.cc13
-rw-r--r--chrome/browser/extensions/extension_prefs.h12
-rw-r--r--chrome/browser/extensions/extension_prefs_unittest.cc8
-rw-r--r--chrome/browser/extensions/extension_service.cc12
-rw-r--r--chrome/browser/extensions/extension_sorting_unittest.cc17
-rw-r--r--chrome/browser/extensions/test_extension_prefs.cc2
8 files changed, 36 insertions, 32 deletions
diff --git a/chrome/browser/extensions/api/preference/preference_api_prefs_unittest.cc b/chrome/browser/extensions/api/preference/preference_api_prefs_unittest.cc
index 00272c8..0fece84 100644
--- a/chrome/browser/extensions/api/preference/preference_api_prefs_unittest.cc
+++ b/chrome/browser/extensions/api/preference/preference_api_prefs_unittest.cc
@@ -151,7 +151,7 @@ void ExtensionControlledPrefsTest::EnsureExtensionInstalled(
if (extension == extensions[i] && !installed_[i]) {
prefs()->OnExtensionInstalled(extension,
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal());
installed_[i] = true;
break;
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index 6811bfc..7497884 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -162,7 +162,7 @@ const Extension* ExtensionBrowserTest::LoadExtensionWithFlags(
service->extension_prefs()->OnExtensionInstalled(
extension,
Extension::ENABLED,
- extensions::Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal::CreateInitialOrdinal());
// Toggling incognito or file access will reload the extension, so wait for
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index 93c43b2..7f34c42 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -1167,13 +1167,13 @@ void ExtensionPrefs::SetKnownDisabled(const ExtensionIdSet& extension_ids) {
void ExtensionPrefs::OnExtensionInstalled(
const Extension* extension,
Extension::State initial_state,
- Blacklist::BlacklistState blacklist_state,
+ bool blacklisted_for_malware,
const syncer::StringOrdinal& page_ordinal) {
ScopedExtensionPrefUpdate update(prefs_, extension->id());
DictionaryValue* extension_dict = update.Get();
const base::Time install_time = time_provider_->GetCurrentTime();
PopulateExtensionInfoPrefs(extension, install_time, initial_state,
- blacklist_state, extension_dict);
+ blacklisted_for_malware, extension_dict);
FinishExtensionInfoPrefs(extension->id(), install_time,
extension->RequiresSortOrdinal(),
page_ordinal, extension_dict);
@@ -1358,12 +1358,13 @@ ExtensionPrefs::GetUninstalledExtensionsInfo() const {
void ExtensionPrefs::SetDelayedInstallInfo(
const Extension* extension,
Extension::State initial_state,
- Blacklist::BlacklistState blacklist_state,
+ bool blacklisted_for_malware,
DelayReason delay_reason,
const syncer::StringOrdinal& page_ordinal) {
DictionaryValue* extension_dict = new DictionaryValue();
PopulateExtensionInfoPrefs(extension, time_provider_->GetCurrentTime(),
- initial_state, blacklist_state, extension_dict);
+ initial_state, blacklisted_for_malware,
+ extension_dict);
// Add transient data that is needed by FinishDelayedInstallInfo(), but
// should not be in the final extension prefs. All entries here should have
@@ -1830,7 +1831,7 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs(
const Extension* extension,
const base::Time install_time,
Extension::State initial_state,
- Blacklist::BlacklistState blacklist_state,
+ bool blacklisted_for_malware,
DictionaryValue* extension_dict) {
// Leave the state blank for component extensions so that old chrome versions
// loading new profiles do not fail in GetInstalledExtensionInfo. Older
@@ -1852,7 +1853,7 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs(
extension_dict->Set(kPrefInstallTime,
new base::StringValue(
base::Int64ToString(install_time.ToInternalValue())));
- if (blacklist_state == Blacklist::BLACKLISTED_MALWARE)
+ if (blacklisted_for_malware)
extension_dict->Set(kPrefBlacklist, new base::FundamentalValue(true));
base::FilePath::StringType path = MakePathRelative(install_directory_,
diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h
index c549cfa..b89eae2 100644
--- a/chrome/browser/extensions/extension_prefs.h
+++ b/chrome/browser/extensions/extension_prefs.h
@@ -14,7 +14,6 @@
#include "base/prefs/scoped_user_pref_update.h"
#include "base/time/time.h"
#include "base/values.h"
-#include "chrome/browser/extensions/blacklist.h"
#include "chrome/browser/extensions/extension_scoped_prefs.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -181,11 +180,12 @@ class ExtensionPrefs : public ExtensionScopedPrefs,
void SetKnownDisabled(const ExtensionIdSet& extension_ids);
// Called when an extension is installed, so that prefs get created.
- // If |page_ordinal| is an invalid ordinal, then a page will be found
- // for the App.
+ // |blacklisted_for_malware| should be set if the extension was included in a
+ // blacklist due to being malware. If |page_ordinal| is an invalid ordinal,
+ // then a page will be found for the App.
void OnExtensionInstalled(const Extension* extension,
Extension::State initial_state,
- Blacklist::BlacklistState blacklist_state,
+ bool blacklisted_for_malware,
const syncer::StringOrdinal& page_ordinal);
// Called when an extension is uninstalled, so that prefs get cleaned up.
@@ -417,7 +417,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs,
// to install it.
void SetDelayedInstallInfo(const Extension* extension,
Extension::State initial_state,
- Blacklist::BlacklistState blacklist_state,
+ bool blacklisted_for_malware,
DelayReason delay_reason,
const syncer::StringOrdinal& page_ordinal);
@@ -605,7 +605,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs,
void PopulateExtensionInfoPrefs(const Extension* extension,
const base::Time install_time,
Extension::State initial_state,
- Blacklist::BlacklistState blacklist_state,
+ bool blacklisted_for_malware,
base::DictionaryValue* extension_dict);
// Helper function to complete initialization of the values in
diff --git a/chrome/browser/extensions/extension_prefs_unittest.cc b/chrome/browser/extensions/extension_prefs_unittest.cc
index 9f68634..511aeed 100644
--- a/chrome/browser/extensions/extension_prefs_unittest.cc
+++ b/chrome/browser/extensions/extension_prefs_unittest.cc
@@ -470,7 +470,7 @@ class ExtensionPrefsDelayedInstallInfo : public ExtensionPrefsTest {
ASSERT_EQ(id, extension->id());
prefs()->SetDelayedInstallInfo(extension.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE,
syncer::StringOrdinal());
}
@@ -594,7 +594,7 @@ class ExtensionPrefsFinishDelayedInstallInfo : public ExtensionPrefsTest {
ASSERT_EQ(id_, new_extension->id());
prefs()->SetDelayedInstallInfo(new_extension.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE,
syncer::StringOrdinal());
@@ -631,7 +631,7 @@ class ExtensionPrefsOnExtensionInstalled : public ExtensionPrefsTest {
EXPECT_FALSE(prefs()->IsExtensionDisabled(extension_->id()));
prefs()->OnExtensionInstalled(extension_.get(),
Extension::DISABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal());
}
@@ -652,7 +652,7 @@ class ExtensionPrefsAppDraggedByUser : public ExtensionPrefsTest {
EXPECT_FALSE(prefs()->WasAppDraggedByUser(extension_->id()));
prefs()->OnExtensionInstalled(extension_.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal());
}
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 59466bc..0bac9d2 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2112,11 +2112,13 @@ void ExtensionService::OnExtensionInstalled(
AcknowledgeExternalExtension(extension->id());
const Extension::State initial_state =
initial_enable ? Extension::ENABLED : Extension::DISABLED;
+ const bool blacklisted_for_malware =
+ blacklist_state == extensions::Blacklist::BLACKLISTED_MALWARE;
if (ShouldDelayExtensionUpdate(id, wait_for_idle)) {
extension_prefs_->SetDelayedInstallInfo(
extension,
initial_state,
- blacklist_state,
+ blacklisted_for_malware,
extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE,
page_ordinal);
@@ -2138,7 +2140,7 @@ void ExtensionService::OnExtensionInstalled(
extension_prefs_->SetDelayedInstallInfo(
extension,
initial_state,
- blacklist_state,
+ blacklisted_for_malware,
extensions::ExtensionPrefs::DELAY_REASON_GC,
page_ordinal);
delayed_installs_.Insert(extension);
@@ -2147,7 +2149,7 @@ void ExtensionService::OnExtensionInstalled(
extension_prefs_->SetDelayedInstallInfo(
extension,
initial_state,
- blacklist_state,
+ blacklisted_for_malware,
extensions::ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS,
page_ordinal);
delayed_installs_.Insert(extension);
@@ -2166,9 +2168,11 @@ void ExtensionService::AddNewOrUpdatedExtension(
extensions::Blacklist::BlacklistState blacklist_state,
const syncer::StringOrdinal& page_ordinal) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ const bool blacklisted_for_malware =
+ blacklist_state == extensions::Blacklist::BLACKLISTED_MALWARE;
extension_prefs_->OnExtensionInstalled(extension,
initial_state,
- blacklist_state,
+ blacklisted_for_malware,
page_ordinal);
delayed_installs_.Remove(extension->id());
FinishInstallation(extension);
diff --git a/chrome/browser/extensions/extension_sorting_unittest.cc b/chrome/browser/extensions/extension_sorting_unittest.cc
index 295ff6a..711c4a5 100644
--- a/chrome/browser/extensions/extension_sorting_unittest.cc
+++ b/chrome/browser/extensions/extension_sorting_unittest.cc
@@ -11,7 +11,6 @@
#include "sync/api/string_ordinal.h"
#include "testing/gtest/include/gtest/gtest.h"
-using extensions::Blacklist;
using extensions::Extension;
using extensions::Manifest;
@@ -31,7 +30,7 @@ class ExtensionSortingAppLocation : public ExtensionSortingTest {
// Non-apps should not have any app launch ordinal or page ordinal.
prefs()->OnExtensionInstalled(extension_.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal());
}
@@ -59,7 +58,7 @@ class ExtensionSortingAppLaunchOrdinal : public ExtensionSortingTest {
EXPECT_FALSE(prefs()->IsExtensionDisabled(extension_->id()));
prefs()->OnExtensionInstalled(extension_.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal());
}
@@ -111,7 +110,7 @@ class ExtensionSortingPageOrdinal : public ExtensionSortingTest {
first_page_ = syncer::StringOrdinal::CreateInitialOrdinal();
prefs()->OnExtensionInstalled(extension_.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
first_page_);
EXPECT_TRUE(first_page_.Equals(
extension_sorting()->GetPageOrdinal(extension_->id())));
@@ -121,7 +120,7 @@ class ExtensionSortingPageOrdinal : public ExtensionSortingTest {
// Install without any page preference.
prefs()->OnExtensionInstalled(extension2.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal());
EXPECT_TRUE(first_page_.Equals(
extension_sorting()->GetPageOrdinal(extension2->id())));
@@ -647,7 +646,7 @@ class ExtensionSortingPreinstalledAppsBase
simple_dict, Extension::NO_FLAGS, &error);
prefs()->OnExtensionInstalled(app1_scoped_.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal());
app2_scoped_ = Extension::Create(
@@ -655,7 +654,7 @@ class ExtensionSortingPreinstalledAppsBase
simple_dict, Extension::NO_FLAGS, &error);
prefs()->OnExtensionInstalled(app2_scoped_.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal());
app1_ = app1_scoped_.get();
@@ -841,7 +840,7 @@ class ExtensionSortingDefaultOrdinalsBase : public ExtensionSortingTest {
virtual void InstallApps() {
prefs()->OnExtensionInstalled(app_.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal());
}
@@ -889,7 +888,7 @@ class ExtensionSortingDefaultOrdinalOverriddenByInstallPage
install_page_ = default_page_ordinal_.CreateAfter();
prefs()->OnExtensionInstalled(app_.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
install_page_);
}
diff --git a/chrome/browser/extensions/test_extension_prefs.cc b/chrome/browser/extensions/test_extension_prefs.cc
index c53f136..d525c07 100644
--- a/chrome/browser/extensions/test_extension_prefs.cc
+++ b/chrome/browser/extensions/test_extension_prefs.cc
@@ -160,7 +160,7 @@ scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifestAndFlags(
EXPECT_TRUE(Extension::IdIsValid(extension->id()));
prefs_->OnExtensionInstalled(extension.get(),
Extension::ENABLED,
- Blacklist::NOT_BLACKLISTED,
+ false,
syncer::StringOrdinal::CreateInitialOrdinal());
return extension;
}