OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 #include "ui/gfx/favicon_size.h" | 54 #include "ui/gfx/favicon_size.h" |
55 #include "ui/webui/web_ui_util.h" | 55 #include "ui/webui/web_ui_util.h" |
56 | 56 |
57 using chrome::AppLaunchParams; | 57 using chrome::AppLaunchParams; |
58 using chrome::OpenApplication; | 58 using chrome::OpenApplication; |
59 using content::WebContents; | 59 using content::WebContents; |
60 using extensions::CrxInstaller; | 60 using extensions::CrxInstaller; |
61 using extensions::Extension; | 61 using extensions::Extension; |
62 using extensions::ExtensionPrefs; | 62 using extensions::ExtensionPrefs; |
63 | 63 |
64 namespace { | |
65 | |
66 bool ShouldDisplayInNewTabPage(const Extension* app, PrefService* prefs) { | |
67 bool blocked_by_policy = | |
68 (app->id() == extension_misc::kWebStoreAppId || | |
69 app->id() == extension_misc::kEnterpriseWebStoreAppId) && | |
70 prefs->GetBoolean(prefs::kHideWebStoreIcon); | |
71 return app->ShouldDisplayInNewTabPage() && !blocked_by_policy; | |
72 } | |
73 | |
74 } // namespace | |
75 | |
64 const net::UnescapeRule::Type kUnescapeRules = | 76 const net::UnescapeRule::Type kUnescapeRules = |
65 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS; | 77 net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS; |
66 | 78 |
67 AppLauncherHandler::AppInstallInfo::AppInstallInfo() {} | 79 AppLauncherHandler::AppInstallInfo::AppInstallInfo() {} |
68 | 80 |
69 AppLauncherHandler::AppInstallInfo::~AppInstallInfo() {} | 81 AppLauncherHandler::AppInstallInfo::~AppInstallInfo() {} |
70 | 82 |
71 AppLauncherHandler::AppLauncherHandler(ExtensionService* extension_service) | 83 AppLauncherHandler::AppLauncherHandler(ExtensionService* extension_service) |
72 : extension_service_(extension_service), | 84 : extension_service_(extension_service), |
73 ignore_changes_(false), | 85 ignore_changes_(false), |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 default: | 342 default: |
331 NOTREACHED(); | 343 NOTREACHED(); |
332 } | 344 } |
333 } | 345 } |
334 | 346 |
335 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) { | 347 void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) { |
336 // CreateAppInfo and ClearOrdinals can change the extension prefs. | 348 // CreateAppInfo and ClearOrdinals can change the extension prefs. |
337 base::AutoReset<bool> auto_reset(&ignore_changes_, true); | 349 base::AutoReset<bool> auto_reset(&ignore_changes_, true); |
338 | 350 |
339 ListValue* list = new ListValue(); | 351 ListValue* list = new ListValue(); |
352 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | |
340 | 353 |
341 for (std::set<std::string>::iterator it = visible_apps_.begin(); | 354 for (std::set<std::string>::iterator it = visible_apps_.begin(); |
342 it != visible_apps_.end(); ++it) { | 355 it != visible_apps_.end(); ++it) { |
343 const Extension* extension = extension_service_->GetInstalledExtension(*it); | 356 const Extension* extension = extension_service_->GetInstalledExtension(*it); |
344 if (extension && extension->ShouldDisplayInNewTabPage()) { | 357 if (extension && ShouldDisplayInNewTabPage(extension, prefs)) { |
Dan Beam
2013/02/15 23:50:27
I don't see the diff to remove ::ShouldDisplayInNe
dconnelly
2013/02/18 09:35:54
That's still in the Extension class (chrome/common
| |
345 DictionaryValue* app_info = GetAppInfo(extension); | 358 DictionaryValue* app_info = GetAppInfo(extension); |
346 list->Append(app_info); | 359 list->Append(app_info); |
347 } | 360 } |
348 } | 361 } |
349 | 362 |
350 dictionary->Set("apps", list); | 363 dictionary->Set("apps", list); |
351 | 364 |
352 // TODO(estade): remove these settings when the old NTP is removed. The new | 365 // TODO(estade): remove these settings when the old NTP is removed. The new |
353 // NTP does it in js. | 366 // NTP does it in js. |
354 #if defined(OS_MACOSX) | 367 #if defined(OS_MACOSX) |
355 // App windows are not yet implemented on mac. | 368 // App windows are not yet implemented on mac. |
356 dictionary->SetBoolean("disableAppWindowLaunch", true); | 369 dictionary->SetBoolean("disableAppWindowLaunch", true); |
357 dictionary->SetBoolean("disableCreateAppShortcut", true); | 370 dictionary->SetBoolean("disableCreateAppShortcut", true); |
358 #endif | 371 #endif |
359 | 372 |
360 #if defined(OS_CHROMEOS) | 373 #if defined(OS_CHROMEOS) |
361 // Making shortcut does not make sense on ChromeOS because it does not have | 374 // Making shortcut does not make sense on ChromeOS because it does not have |
362 // a desktop. | 375 // a desktop. |
363 dictionary->SetBoolean("disableCreateAppShortcut", true); | 376 dictionary->SetBoolean("disableCreateAppShortcut", true); |
364 #endif | 377 #endif |
365 | 378 |
366 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | |
367 const ListValue* app_page_names = prefs->GetList(prefs::kNtpAppPageNames); | 379 const ListValue* app_page_names = prefs->GetList(prefs::kNtpAppPageNames); |
368 if (!app_page_names || !app_page_names->GetSize()) { | 380 if (!app_page_names || !app_page_names->GetSize()) { |
369 ListPrefUpdate update(prefs, prefs::kNtpAppPageNames); | 381 ListPrefUpdate update(prefs, prefs::kNtpAppPageNames); |
370 ListValue* list = update.Get(); | 382 ListValue* list = update.Get(); |
371 list->Set(0, Value::CreateStringValue( | 383 list->Set(0, Value::CreateStringValue( |
372 l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME))); | 384 l10n_util::GetStringUTF16(IDS_APP_DEFAULT_PAGE_NAME))); |
373 dictionary->Set("appPageNames", | 385 dictionary->Set("appPageNames", |
374 static_cast<ListValue*>(list->DeepCopy())); | 386 static_cast<ListValue*>(list->DeepCopy())); |
375 } else { | 387 } else { |
376 dictionary->Set("appPageNames", | 388 dictionary->Set("appPageNames", |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { | 897 ExtensionUninstallDialog* AppLauncherHandler::GetExtensionUninstallDialog() { |
886 if (!extension_uninstall_dialog_.get()) { | 898 if (!extension_uninstall_dialog_.get()) { |
887 Browser* browser = chrome::FindBrowserWithWebContents( | 899 Browser* browser = chrome::FindBrowserWithWebContents( |
888 web_ui()->GetWebContents()); | 900 web_ui()->GetWebContents()); |
889 extension_uninstall_dialog_.reset( | 901 extension_uninstall_dialog_.reset( |
890 ExtensionUninstallDialog::Create(extension_service_->profile(), | 902 ExtensionUninstallDialog::Create(extension_service_->profile(), |
891 browser, this)); | 903 browser, this)); |
892 } | 904 } |
893 return extension_uninstall_dialog_.get(); | 905 return extension_uninstall_dialog_.get(); |
894 } | 906 } |
OLD | NEW |