summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-23 21:09:12 +0000
committermek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-23 21:09:12 +0000
commitd8ab2c21b318f626549cba81f35e2c47ded5b984 (patch)
treefc49308c5042314ea2ec5502c14dabf1546bbe37
parentb4afc31a8e12590d7f723dec947bd9a39729da8d (diff)
downloadchromium_src-d8ab2c21b318f626549cba81f35e2c47ded5b984.zip
chromium_src-d8ab2c21b318f626549cba81f35e2c47ded5b984.tar.gz
chromium_src-d8ab2c21b318f626549cba81f35e2c47ded5b984.tar.bz2
Merge 217877 "Make sure that apps that are implementation detail..."
> Make sure that apps that are implementation details are not visible in the management API, similar to how these apps are hidden from the chrome://extensions page and the developer-private API. Also refactor code to have this check only in one spot instead of in the three different places that had similar logic. > > BUG=271788 > > Review URL: https://chromiumcodereview.appspot.com/23072003 TBR=mek@chromium.org Review URL: https://codereview.chromium.org/23407002 git-svn-id: svn://svn.chromium.org/chrome/branches/1547/src@219336 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/developer_private/developer_private_api.cc15
-rw-r--r--chrome/browser/extensions/api/management/management_api.cc11
-rw-r--r--chrome/common/extensions/extension.cc32
-rw-r--r--chrome/common/extensions/extension.h5
4 files changed, 36 insertions, 27 deletions
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index e2b1cc8..b606629 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -387,20 +387,9 @@ bool DeveloperPrivateGetItemsInfoFunction::RunImpl() {
iter != items.end(); ++iter) {
const Extension& item = *iter->get();
- // Don't show component extensions because they are only extensions as an
- // implementation detail of Chrome.
- if (item.location() == Manifest::COMPONENT &&
- !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kShowComponentExtensionOptions)) {
+ // Don't show component extensions and invisible apps.
+ if (item.ShouldNotBeVisible())
continue;
- }
-
- // Don't show apps that aren't visible in either launcher or ntp.
- if (item.is_app() && !item.ShouldDisplayInAppLauncher() &&
- !item.ShouldDisplayInNewTabPage() &&
- !Manifest::IsUnpackedLocation(item.location())) {
- continue;
- }
item_list.push_back(make_linked_ptr<developer::ItemInfo>(
CreateItemInfo(
diff --git a/chrome/browser/extensions/api/management/management_api.cc b/chrome/browser/extensions/api/management/management_api.cc
index 7f98037..e8e89e5 100644
--- a/chrome/browser/extensions/api/management/management_api.cc
+++ b/chrome/browser/extensions/api/management/management_api.cc
@@ -209,8 +209,8 @@ void AddExtensionInfo(const ExtensionSet& extensions,
iter != extensions.end(); ++iter) {
const Extension& extension = *iter->get();
- if (extension.location() == Manifest::COMPONENT)
- continue; // Skip built-in extensions.
+ if (extension.ShouldNotBeVisible())
+ continue; // Skip built-in extensions/apps.
extension_list->push_back(make_linked_ptr<management::ExtensionInfo>(
CreateExtensionInfo(extension, system).release()));
@@ -459,7 +459,7 @@ bool ManagementSetEnabledFunction::RunImpl() {
extension_id_ = params->id;
const Extension* extension = service()->GetInstalledExtension(extension_id_);
- if (!extension) {
+ if (!extension || extension->ShouldNotBeVisible()) {
error_ = ErrorUtils::FormatErrorMessage(
keys::kNoExtensionError, extension_id_);
return false;
@@ -524,7 +524,7 @@ bool ManagementUninstallFunctionBase::Uninstall(
bool show_confirm_dialog) {
extension_id_ = extension_id;
const Extension* extension = service()->GetExtensionById(extension_id_, true);
- if (!extension) {
+ if (!extension || extension->ShouldNotBeVisible()) {
error_ = ErrorUtils::FormatErrorMessage(
keys::kNoExtensionError, extension_id_);
return false;
@@ -676,6 +676,9 @@ void ManagementEventRouter::Observe(
DCHECK(event_name);
DCHECK(extension);
+ if (extension->ShouldNotBeVisible())
+ return; // Don't dispatch events for built-in extensions.
+
scoped_ptr<base::ListValue> args(new base::ListValue());
if (event_name == events::kOnExtensionUninstalled) {
args->Append(Value::CreateStringValue(extension->id()));
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 7dbf7f7..cd875e1 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -398,22 +398,14 @@ bool Extension::ShouldDisplayInExtensionSettings() const {
if (is_theme())
return false;
- // Don't show component extensions because they are only extensions as an
- // implementation detail of Chrome.
- if (location() == Manifest::COMPONENT &&
- !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kShowComponentExtensionOptions)) {
+ // Don't show component extensions and invisible apps.
+ if (ShouldNotBeVisible())
return false;
- }
// Always show unpacked extensions and apps.
if (Manifest::IsUnpackedLocation(location()))
return true;
- // Don't show apps that aren't visible in either launcher or ntp.
- if (is_app() && !ShouldDisplayInAppLauncher() && !ShouldDisplayInNewTabPage())
- return false;
-
// Unless they are unpacked, never show hosted apps. Note: We intentionally
// show packaged apps and platform apps because there are some pieces of
// functionality that are only available in chrome://extensions/ but which
@@ -425,6 +417,26 @@ bool Extension::ShouldDisplayInExtensionSettings() const {
return true;
}
+bool Extension::ShouldNotBeVisible() const {
+ // Don't show component extensions because they are only extensions as an
+ // implementation detail of Chrome.
+ if (location() == Manifest::COMPONENT &&
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kShowComponentExtensionOptions)) {
+ return true;
+ }
+
+ // Always show unpacked extensions and apps.
+ if (Manifest::IsUnpackedLocation(location()))
+ return false;
+
+ // Don't show apps that aren't visible in either launcher or ntp.
+ if (is_app() && !ShouldDisplayInAppLauncher() && !ShouldDisplayInNewTabPage())
+ return true;
+
+ return false;
+}
+
Extension::ManifestData* Extension::GetManifestData(const std::string& key)
const {
DCHECK(finished_parsing_manifest_ || thread_checker_.CalledOnValidThread());
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index c000c80..12fb41f 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -255,6 +255,11 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// settings page (i.e. chrome://extensions).
bool ShouldDisplayInExtensionSettings() const;
+ // Returns true if the extension should not be shown anywhere. This is
+ // mostly the same as the extension being a component extension, but also
+ // includes non-component apps that are hidden from the app launcher and ntp.
+ bool ShouldNotBeVisible() const;
+
// Get the manifest data associated with the key, or NULL if there is none.
// Can only be called after InitValue is finished.
ManifestData* GetManifestData(const std::string& key) const;