Commit 7f56f97a authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Only show hosted apps that have protected storage

The Clear Browsing Data dialog shows a list of hosted apps that will be
affected by deletions. Only hosted apps with protected storage are
affected, so hide those that do not have protected storage.

Bug: 1140191
Change-Id: If02e65b235d254d50a18031c5b7b972341cd811e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2487108Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819279}
parent e66103ee
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "components/browsing_data/core/pref_names.h" #include "components/browsing_data/core/pref_names.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
...@@ -16,30 +17,30 @@ ...@@ -16,30 +17,30 @@
HostedAppsCounter::HostedAppsCounter(Profile* profile) HostedAppsCounter::HostedAppsCounter(Profile* profile)
: profile_(profile) {} : profile_(profile) {}
HostedAppsCounter::~HostedAppsCounter() {} HostedAppsCounter::~HostedAppsCounter() = default;
const char* HostedAppsCounter::GetPrefName() const { const char* HostedAppsCounter::GetPrefName() const {
return browsing_data::prefs::kDeleteHostedAppsData; return browsing_data::prefs::kDeleteHostedAppsData;
} }
void HostedAppsCounter::Count() { void HostedAppsCounter::Count() {
int count = 0;
std::vector<std::string> names; std::vector<std::string> names;
std::unique_ptr<extensions::ExtensionSet> extensions = std::unique_ptr<extensions::ExtensionSet> extensions =
extensions::ExtensionRegistry::Get(profile_) extensions::ExtensionRegistry::Get(profile_)
->GenerateInstalledExtensionsSet(); ->GenerateInstalledExtensionsSet();
auto* special_storage_policy = profile_->GetExtensionSpecialStoragePolicy();
for (const auto& extension : *extensions) { for (const auto& extension : *extensions) {
// Exclude kChromeAppId because this is not a proper hosted app. It is just // Exclude kChromeAppId because this is not a proper hosted app. It is just
// a shortcut to launch Chrome on Chrome OS. // a shortcut to launch Chrome on Chrome OS.
if (extension->is_hosted_app() && if (special_storage_policy->NeedsProtection(extension.get()) &&
extension->id() != extension_misc::kChromeAppId) { extension->id() != extension_misc::kChromeAppId) {
names.push_back(extension->short_name()); names.push_back(extension->short_name());
} }
} }
count = names.size(); int count = names.size();
// Give the first two names (alphabetically) as examples. // Give the first two names (alphabetically) as examples.
std::sort(names.begin(), names.end()); std::sort(names.begin(), names.end());
......
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