Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5722)

Unified Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 11859029: Add a policy to hide the Web Store on new tabs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: filter app from c++ Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/ntp/app_launcher_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index a06eab3ac1dbf35ced5fe883cecd562c2fbd6a6c..b0a43dcc284143f152f366312e6b5d8361a879a0 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -61,6 +61,18 @@ using extensions::CrxInstaller;
using extensions::Extension;
using extensions::ExtensionPrefs;
+namespace {
+
+bool ShouldDisplayInNewTabPage(const Extension* app, PrefService* prefs) {
+ bool blocked_by_policy =
+ (app->id() == extension_misc::kWebStoreAppId ||
+ app->id() == extension_misc::kEnterpriseWebStoreAppId) &&
+ prefs->GetBoolean(prefs::kHideWebStoreIcon);
+ return app->ShouldDisplayInNewTabPage() && !blocked_by_policy;
+}
+
+} // namespace
+
const net::UnescapeRule::Type kUnescapeRules =
net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS;
@@ -337,11 +349,12 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
base::AutoReset<bool> auto_reset(&ignore_changes_, true);
ListValue* list = new ListValue();
+ PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
for (std::set<std::string>::iterator it = visible_apps_.begin();
it != visible_apps_.end(); ++it) {
const Extension* extension = extension_service_->GetInstalledExtension(*it);
- if (extension && extension->ShouldDisplayInNewTabPage()) {
+ if (extension && ShouldDisplayInNewTabPage(extension, prefs)) {
DictionaryValue* app_info = GetAppInfo(extension);
list->Append(app_info);
}
@@ -363,7 +376,6 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
dictionary->SetBoolean("disableCreateAppShortcut", true);
#endif
- PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
const ListValue* app_page_names = prefs->GetList(prefs::kNtpAppPageNames);
if (!app_page_names || !app_page_names->GetSize()) {
ListPrefUpdate update(prefs, prefs::kNtpAppPageNames);

Powered by Google App Engine
This is Rietveld 408576698