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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_page_handler.cc

Issue 11953021: Don't show the apps page on the NTP if the app launcher is installed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move getShouldShowApps message to onLoad. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/new_tab_page_handler.h" 5 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "chrome/browser/extensions/app_launcher.h"
11 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "chrome/browser/sync/profile_sync_service.h"
14 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 15 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
15 #include "chrome/browser/web_resource/notification_promo.h" 16 #include "chrome/browser/web_resource/notification_promo.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/web_ui.h" 19 #include "content/public/browser/web_ui.h"
19 #include "grit/chromium_strings.h" 20 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 base::Unretained(this))); 67 base::Unretained(this)));
67 web_ui()->RegisterMessageCallback("bubblePromoLinkClicked", 68 web_ui()->RegisterMessageCallback("bubblePromoLinkClicked",
68 base::Bind(&NewTabPageHandler::HandleBubblePromoLinkClicked, 69 base::Bind(&NewTabPageHandler::HandleBubblePromoLinkClicked,
69 base::Unretained(this))); 70 base::Unretained(this)));
70 web_ui()->RegisterMessageCallback("pageSelected", 71 web_ui()->RegisterMessageCallback("pageSelected",
71 base::Bind(&NewTabPageHandler::HandlePageSelected, 72 base::Bind(&NewTabPageHandler::HandlePageSelected,
72 base::Unretained(this))); 73 base::Unretained(this)));
73 web_ui()->RegisterMessageCallback("logTimeToClick", 74 web_ui()->RegisterMessageCallback("logTimeToClick",
74 base::Bind(&NewTabPageHandler::HandleLogTimeToClick, 75 base::Bind(&NewTabPageHandler::HandleLogTimeToClick,
75 base::Unretained(this))); 76 base::Unretained(this)));
77 web_ui()->RegisterMessageCallback("getShouldShowApps",
78 base::Bind(&NewTabPageHandler::HandleGetShouldShowApps,
79 base::Unretained(this)));
76 } 80 }
77 81
78 void NewTabPageHandler::HandleNotificationPromoClosed(const ListValue* args) { 82 void NewTabPageHandler::HandleNotificationPromoClosed(const ListValue* args) {
79 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification", 83 UMA_HISTOGRAM_ENUMERATION("NewTabPage.Promo.Notification",
80 PROMO_CLOSED, PROMO_ACTION_MAX); 84 PROMO_CLOSED, PROMO_ACTION_MAX);
81 NotificationPromo::HandleClosed(NotificationPromo::NTP_NOTIFICATION_PROMO); 85 NotificationPromo::HandleClosed(NotificationPromo::NTP_NOTIFICATION_PROMO);
82 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED); 86 Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED);
83 } 87 }
84 88
85 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) { 89 void NewTabPageHandler::HandleNotificationPromoViewed(const ListValue* args) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 UMA_HISTOGRAM_LONG_TIMES( 164 UMA_HISTOGRAM_LONG_TIMES(
161 "ExtendedNewTabPage.TimeToClickMostVisited", delta); 165 "ExtendedNewTabPage.TimeToClickMostVisited", delta);
162 } else if (histogram_name == "ExtendedNewTabPage.TimeToClickRecentlyClosed") { 166 } else if (histogram_name == "ExtendedNewTabPage.TimeToClickRecentlyClosed") {
163 UMA_HISTOGRAM_LONG_TIMES( 167 UMA_HISTOGRAM_LONG_TIMES(
164 "ExtendedNewTabPage.TimeToClickRecentlyClosed", delta); 168 "ExtendedNewTabPage.TimeToClickRecentlyClosed", delta);
165 } else { 169 } else {
166 NOTREACHED(); 170 NOTREACHED();
167 } 171 }
168 } 172 }
169 173
174 void NewTabPageHandler::HandleGetShouldShowApps(const ListValue* args) {
175 extensions::UpdateIsAppLauncherEnabled(
176 base::Bind(&NewTabPageHandler::GotIsAppLauncherEnabled,
177 AsWeakPtr()));
178 }
179
180 void NewTabPageHandler::GotIsAppLauncherEnabled(bool is_enabled) {
181 base::FundamentalValue should_show_apps(!is_enabled);
182 web_ui()->CallJavascriptFunction("ntp.gotShouldShowApps", should_show_apps);
183 }
184
170 // static 185 // static
171 void NewTabPageHandler::RegisterUserPrefs(PrefServiceSyncable* prefs) { 186 void NewTabPageHandler::RegisterUserPrefs(PrefServiceSyncable* prefs) {
172 // TODO(estade): should be syncable. 187 // TODO(estade): should be syncable.
173 prefs->RegisterIntegerPref(prefs::kNtpShownPage, APPS_PAGE_ID, 188 prefs->RegisterIntegerPref(prefs::kNtpShownPage, APPS_PAGE_ID,
174 PrefServiceSyncable::UNSYNCABLE_PREF); 189 PrefServiceSyncable::UNSYNCABLE_PREF);
175 } 190 }
176 191
177 // static 192 // static
178 void NewTabPageHandler::GetLocalizedValues(Profile* profile, 193 void NewTabPageHandler::GetLocalizedValues(Profile* profile,
179 DictionaryValue* values) { 194 DictionaryValue* values) {
(...skipping 11 matching lines...) Expand all
191 values->SetInteger("shown_page_index", shown_page & INDEX_MASK); 206 values->SetInteger("shown_page_index", shown_page & INDEX_MASK);
192 } 207 }
193 208
194 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) { 209 void NewTabPageHandler::Notify(chrome::NotificationType notification_type) {
195 content::NotificationService* service = 210 content::NotificationService* service =
196 content::NotificationService::current(); 211 content::NotificationService::current();
197 service->Notify(notification_type, 212 service->Notify(notification_type,
198 content::Source<NewTabPageHandler>(this), 213 content::Source<NewTabPageHandler>(this),
199 content::NotificationService::NoDetails()); 214 content::NotificationService::NoDetails());
200 } 215 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_page_handler.h ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698