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

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

Issue 1129903008: NTP Zombie Code Slayer Part IV: Most Visited (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android fix Created 5 years, 7 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
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_ui.h" 5 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/webui/metrics_handler.h" 17 #include "chrome/browser/ui/webui/metrics_handler.h"
18 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 18 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
19 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" 19 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
20 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" 20 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h"
21 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h"
22 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" 21 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
23 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" 22 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h"
24 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" 23 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h"
25 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" 24 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
26 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" 25 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
27 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" 26 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h"
28 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
29 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
30 #include "chrome/grit/generated_resources.h" 29 #include "chrome/grit/generated_resources.h"
31 #include "components/pref_registry/pref_registry_syncable.h" 30 #include "components/pref_registry/pref_registry_syncable.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); 85 web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
87 86
88 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more 87 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more
89 // highly. Note this means we're including clicks on not only most visited 88 // highly. Note this means we're including clicks on not only most visited
90 // thumbnails, but also clicks on recently bookmarked. 89 // thumbnails, but also clicks on recently bookmarked.
91 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); 90 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK);
92 91
93 Profile* profile = GetProfile(); 92 Profile* profile = GetProfile();
94 if (!profile->IsOffTheRecord()) { 93 if (!profile->IsOffTheRecord()) {
95 web_ui->AddMessageHandler(new MetricsHandler()); 94 web_ui->AddMessageHandler(new MetricsHandler());
96 web_ui->AddMessageHandler(new MostVisitedHandler());
97 web_ui->AddMessageHandler(new FaviconWebUIHandler()); 95 web_ui->AddMessageHandler(new FaviconWebUIHandler());
98 web_ui->AddMessageHandler(new NewTabPageHandler()); 96 web_ui->AddMessageHandler(new NewTabPageHandler());
99 web_ui->AddMessageHandler(new CoreAppLauncherHandler()); 97 web_ui->AddMessageHandler(new CoreAppLauncherHandler());
100 web_ui->AddMessageHandler(new NewTabPageSyncHandler()); 98 web_ui->AddMessageHandler(new NewTabPageSyncHandler());
101 99
102 ExtensionService* service = 100 ExtensionService* service =
103 extensions::ExtensionSystem::Get(profile)->extension_service(); 101 extensions::ExtensionSystem::Get(profile)->extension_service();
104 // We might not have an ExtensionService (on ChromeOS when not logged in 102 // We might not have an ExtensionService (on ChromeOS when not logged in
105 // for example). 103 // for example).
106 if (service) 104 if (service)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 GetProfile()->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar) ? 204 GetProfile()->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar) ?
207 "true" : "false"); 205 "true" : "false");
208 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached); 206 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached);
209 } 207 }
210 208
211 // static 209 // static
212 void NewTabUI::RegisterProfilePrefs( 210 void NewTabUI::RegisterProfilePrefs(
213 user_prefs::PrefRegistrySyncable* registry) { 211 user_prefs::PrefRegistrySyncable* registry) {
214 CoreAppLauncherHandler::RegisterProfilePrefs(registry); 212 CoreAppLauncherHandler::RegisterProfilePrefs(registry);
215 NewTabPageHandler::RegisterProfilePrefs(registry); 213 NewTabPageHandler::RegisterProfilePrefs(registry);
216 MostVisitedHandler::RegisterProfilePrefs(registry);
217 } 214 }
218 215
219 // static 216 // static
220 bool NewTabUI::ShouldShowApps() { 217 bool NewTabUI::ShouldShowApps() {
221 // Ash shows apps in app list thus should not show apps page in NTP4. 218 // Ash shows apps in app list thus should not show apps page in NTP4.
222 #if defined(USE_ASH) 219 #if defined(USE_ASH)
223 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH; 220 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH;
224 #else 221 #else
225 return true; 222 return true;
226 #endif 223 #endif
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, 344 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource,
348 const char* mime_type, 345 const char* mime_type,
349 int resource_id) { 346 int resource_id) {
350 DCHECK(resource); 347 DCHECK(resource);
351 DCHECK(mime_type); 348 DCHECK(mime_type);
352 resource_map_[std::string(resource)] = 349 resource_map_[std::string(resource)] =
353 std::make_pair(std::string(mime_type), resource_id); 350 std::make_pair(std::string(mime_type), resource_id);
354 } 351 }
355 352
356 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} 353 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {}
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_page_handler.cc ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698