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

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

Issue 8036002: ntp: remove ntp3 resources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 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 3a9d56335f8a9714cc55693c95598a506b86262e..a497e97b2e7c9ea5228123951606f7378179f818 100644
--- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -98,16 +98,9 @@ static DictionaryValue* SerializeNotification(
// static
bool AppLauncherHandler::IsAppExcludedFromList(const Extension* extension) {
// Don't include the WebStore and the Cloud Print app.
csilv 2011/09/26 22:25:47 You can remove this comment line.
Evan Stade 2011/09/26 22:32:05 yea
- // The WebStore launcher gets special treatment in ntp/apps.js.
// The Cloud Print app should never be displayed in the NTP.
- bool ntp3 =
- !NewTabUI::NTP4Enabled();
- if (!extension->is_app() ||
- (ntp3 && extension->id() == extension_misc::kWebStoreAppId) ||
- (extension->id() == extension_misc::kCloudPrintAppId)) {
- return true;
- }
- return false;
+ return !extension->is_app() ||
+ (extension->id() == extension_misc::kCloudPrintAppId);
}
void AppLauncherHandler::CreateAppInfo(const Extension* extension,
@@ -118,18 +111,17 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension,
!service->GetTerminatedExtension(extension->id());
bool icon_big_exists = true;
// Instead of setting grayscale here, we do it in apps_page.js in NTP4.
- bool grayscale = NewTabUI::NTP4Enabled() ? false : !enabled;
GURL icon_big =
ExtensionIconSource::GetIconURL(extension,
Extension::EXTENSION_ICON_LARGE,
ExtensionIconSet::MATCH_EXACTLY,
- grayscale, &icon_big_exists);
+ false, &icon_big_exists);
bool icon_small_exists = true;
GURL icon_small =
ExtensionIconSource::GetIconURL(extension,
Extension::EXTENSION_ICON_BITTY,
ExtensionIconSet::MATCH_BIGGER,
- grayscale, &icon_small_exists);
+ false, &icon_small_exists);
value->Clear();
value->SetString("id", extension->id());
@@ -137,8 +129,7 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension,
value->SetString("description", extension->description());
value->SetString("launch_url", extension->GetFullLaunchURL().spec());
value->SetBoolean("enabled", enabled);
- if (NewTabUI::NTP4Enabled() || enabled)
- value->SetString("options_url", extension->options_url().spec());
+ value->SetString("options_url", extension->options_url().spec());
value->SetBoolean("can_uninstall",
Extension::UserMayDisable(extension->location()));
value->SetString("icon_big", icon_big.spec());
@@ -261,8 +252,7 @@ void AppLauncherHandler::RegisterMessages() {
void AppLauncherHandler::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
- if (type == chrome::NOTIFICATION_APP_INSTALLED_TO_NTP &&
- NewTabUI::NTP4Enabled()) {
+ if (type == chrome::NOTIFICATION_APP_INSTALLED_TO_NTP) {
highlight_app_id_ = *Details<const std::string>(details).ptr();
if (has_loaded_apps_)
SetAppToBeHighlighted();
@@ -298,11 +288,9 @@ void AppLauncherHandler::Observe(int type,
if (!extension->is_app())
return;
- if (!NewTabUI::NTP4Enabled()) {
- HandleGetApps(NULL);
- break;
- }
-
+#if defined(TOUCH_UI)
+ HandleGetApps(NULL);
+#else
scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension));
if (app_info.get()) {
ExtensionPrefs* prefs = extension_service_->extension_prefs();
@@ -312,7 +300,7 @@ void AppLauncherHandler::Observe(int type,
attempted_bookmark_app_install_ = false;
web_ui_->CallJavascriptFunction("ntp4.appAdded", *app_info, *highlight);
}
-
+#endif
break;
}
case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
@@ -321,11 +309,9 @@ void AppLauncherHandler::Observe(int type,
if (!extension->is_app())
return;
- if (!NewTabUI::NTP4Enabled()) {
- HandleGetApps(NULL);
- break;
- }
-
+#if defined(TOUCH_UI)
+ HandleGetApps(NULL);
+#else
scoped_ptr<DictionaryValue> app_info(GetAppInfo(extension));
scoped_ptr<base::FundamentalValue> uninstall_value(
Value::CreateBooleanValue(
@@ -335,6 +321,7 @@ void AppLauncherHandler::Observe(int type,
web_ui_->CallJavascriptFunction(
"ntp4.appRemoved", *app_info, *uninstall_value);
}
+#endif
break;
}
case chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED:
@@ -418,13 +405,11 @@ void AppLauncherHandler::FillAppDictionary(DictionaryValue* dictionary) {
extension_service_->apps_promo()->ShouldShowAppLauncher(
extension_service_->GetAppIds()));
- if (NewTabUI::NTP4Enabled()) {
- PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs();
- const ListValue* app_page_names = prefs->GetList(prefs::kNTPAppPageNames);
- if (app_page_names && app_page_names->GetSize()) {
- dictionary->Set("appPageNames",
- static_cast<ListValue*>(app_page_names->DeepCopy()));
- }
+ PrefService* prefs = Profile::FromWebUI(web_ui_)->GetPrefs();
+ const ListValue* app_page_names = prefs->GetList(prefs::kNTPAppPageNames);
+ if (app_page_names && app_page_names->GetSize()) {
+ dictionary->Set("appPageNames",
+ static_cast<ListValue*>(app_page_names->DeepCopy()));
}
}
@@ -560,7 +545,7 @@ void AppLauncherHandler::HandleLaunchApp(const ListValue* args) {
if (extension_id != extension_misc::kWebStoreAppId) {
RecordAppLaunchByID(promo_active_, launch_bucket);
extension_service_->apps_promo()->ExpireDefaultApps();
- } else if (NewTabUI::NTP4Enabled()) {
+ } else {
RecordWebStoreLaunch(promo_active_);
}
@@ -608,10 +593,7 @@ void AppLauncherHandler::HandleSetLaunchType(const ListValue* args) {
return;
// Don't update the page; it already knows about the launch type change.
- scoped_ptr<AutoReset<bool> > auto_reset;
- if (NewTabUI::NTP4Enabled())
- auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
-
+ AutoReset<bool> auto_reset(&ignore_changes_, true);
extension_service_->extension_prefs()->SetLaunchType(
extension_id,
static_cast<ExtensionPrefs::LaunchType>(
@@ -639,9 +621,7 @@ void AppLauncherHandler::HandleUninstallApp(const ListValue* args) {
bool dont_confirm = false;
if (args->GetBoolean(1, &dont_confirm) && dont_confirm) {
- scoped_ptr<AutoReset<bool> > auto_reset;
- if (NewTabUI::NTP4Enabled())
- auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
+ AutoReset<bool> auto_reset(&ignore_changes_, true);
ExtensionUninstallAccepted();
} else {
GetExtensionUninstallDialog()->ConfirmUninstall(extension);
@@ -654,20 +634,8 @@ void AppLauncherHandler::HandleHideAppsPromo(const ListValue* args) {
// this point, or the promotion wouldn't have been shown).
// TODO(estade): this isn't used right now as we sort out the future of the
// apps promo on ntp4.
- if (NewTabUI::NTP4Enabled()) {
- UninstallDefaultApps();
- extension_service_->apps_promo()->HidePromo();
- } else {
- // TODO(estade): remove all this. NTP3 uninstalled all the default apps then
- // refreshed the entire NTP, we don't have to jump through these hoops for
- // NTP4 because each app uninstall is handled separately without reloading
- // the entire page.
- ignore_changes_ = true;
- UninstallDefaultApps();
- extension_service_->apps_promo()->HidePromo();
- ignore_changes_ = false;
- HandleGetApps(NULL);
- }
+ UninstallDefaultApps();
+ extension_service_->apps_promo()->HidePromo();
}
void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) {
@@ -702,10 +670,7 @@ void AppLauncherHandler::HandleReorderApps(const ListValue* args) {
}
// Don't update the page; it already knows the apps have been reordered.
- scoped_ptr<AutoReset<bool> > auto_reset;
- if (NewTabUI::NTP4Enabled())
- auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
-
+ AutoReset<bool> auto_reset(&ignore_changes_, true);
extension_service_->extension_prefs()->SetAppDraggedByUser(dragged_app_id);
extension_service_->extension_prefs()->SetAppLauncherOrder(extension_ids);
}
@@ -717,10 +682,7 @@ void AppLauncherHandler::HandleSetPageIndex(const ListValue* args) {
CHECK(args->GetDouble(1, &page_index));
// Don't update the page; it already knows the apps have been reordered.
- scoped_ptr<AutoReset<bool> > auto_reset;
- if (NewTabUI::NTP4Enabled())
- auto_reset.reset(new AutoReset<bool>(&ignore_changes_, true));
-
+ AutoReset<bool> auto_reset(&ignore_changes_, true);
extension_service_->extension_prefs()->SetPageIndex(extension_id,
static_cast<int>(page_index));
}

Powered by Google App Engine
This is Rietveld 408576698