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

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

Issue 1140813003: NTP Zombie Code Slayer III, The Saga Continues: Foreign Sessions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@suggestions-page
Patch Set: 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/foreign_session_handler.h"
22 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" 21 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h"
23 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" 22 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h"
24 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" 23 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h"
25 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" 24 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h"
26 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" 25 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
27 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" 26 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
28 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" 27 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h"
29 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
31 #include "chrome/grit/generated_resources.h" 30 #include "chrome/grit/generated_resources.h"
32 #include "components/pref_registry/pref_registry_syncable.h" 31 #include "components/pref_registry/pref_registry_syncable.h"
33 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
35 #include "content/public/browser/render_process_host.h" 34 #include "content/public/browser/render_process_host.h"
36 #include "content/public/browser/render_view_host.h" 35 #include "content/public/browser/render_view_host.h"
37 #include "content/public/browser/url_data_source.h" 36 #include "content/public/browser/url_data_source.h"
38 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
39 #include "content/public/browser/web_ui.h" 38 #include "content/public/browser/web_ui.h"
40 #include "extensions/browser/extension_system.h" 39 #include "extensions/browser/extension_system.h"
41 #include "grit/browser_resources.h" 40 #include "grit/browser_resources.h"
42 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/base/resource/resource_bundle.h"
43 43
44 #if defined(ENABLE_THEMES) 44 #if defined(ENABLE_THEMES)
45 #include "chrome/browser/ui/webui/theme_handler.h" 45 #include "chrome/browser/ui/webui/theme_handler.h"
46 #endif 46 #endif
47 47
48 #if defined(USE_ASH) 48 #if defined(USE_ASH)
49 #include "chrome/browser/ui/host_desktop.h" 49 #include "chrome/browser/ui/host_desktop.h"
50 #endif 50 #endif
51 51
52 using content::BrowserThread; 52 using content::BrowserThread;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 g_live_new_tabs.Pointer()->insert(this); 85 g_live_new_tabs.Pointer()->insert(this);
86 web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); 86 web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
87 87
88 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more 88 // 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 89 // highly. Note this means we're including clicks on not only most visited
90 // thumbnails, but also clicks on recently bookmarked. 90 // thumbnails, but also clicks on recently bookmarked.
91 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); 91 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK);
92 92
93 Profile* profile = GetProfile(); 93 Profile* profile = GetProfile();
94 if (!profile->IsOffTheRecord()) { 94 if (!profile->IsOffTheRecord()) {
95 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
96 web_ui->AddMessageHandler(new MetricsHandler()); 95 web_ui->AddMessageHandler(new MetricsHandler());
97 web_ui->AddMessageHandler(new MostVisitedHandler()); 96 web_ui->AddMessageHandler(new MostVisitedHandler());
98 web_ui->AddMessageHandler(new FaviconWebUIHandler()); 97 web_ui->AddMessageHandler(new FaviconWebUIHandler());
99 web_ui->AddMessageHandler(new NewTabPageHandler()); 98 web_ui->AddMessageHandler(new NewTabPageHandler());
100 web_ui->AddMessageHandler(new CoreAppLauncherHandler()); 99 web_ui->AddMessageHandler(new CoreAppLauncherHandler());
101 web_ui->AddMessageHandler(new NewTabPageSyncHandler()); 100 web_ui->AddMessageHandler(new NewTabPageSyncHandler());
102 101
103 ExtensionService* service = 102 ExtensionService* service =
104 extensions::ExtensionSystem::Get(profile)->extension_service(); 103 extensions::ExtensionSystem::Get(profile)->extension_service();
105 // We might not have an ExtensionService (on ChromeOS when not logged in 104 // We might not have an ExtensionService (on ChromeOS when not logged in
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 "true" : "false"); 207 "true" : "false");
209 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached); 208 web_ui()->CallJavascriptFunction("ntp.setBookmarkBarAttached", attached);
210 } 209 }
211 210
212 // static 211 // static
213 void NewTabUI::RegisterProfilePrefs( 212 void NewTabUI::RegisterProfilePrefs(
214 user_prefs::PrefRegistrySyncable* registry) { 213 user_prefs::PrefRegistrySyncable* registry) {
215 CoreAppLauncherHandler::RegisterProfilePrefs(registry); 214 CoreAppLauncherHandler::RegisterProfilePrefs(registry);
216 NewTabPageHandler::RegisterProfilePrefs(registry); 215 NewTabPageHandler::RegisterProfilePrefs(registry);
217 MostVisitedHandler::RegisterProfilePrefs(registry); 216 MostVisitedHandler::RegisterProfilePrefs(registry);
218 browser_sync::ForeignSessionHandler::RegisterProfilePrefs(registry);
219 } 217 }
220 218
221 // static 219 // static
222 bool NewTabUI::ShouldShowApps() { 220 bool NewTabUI::ShouldShowApps() {
223 // Ash shows apps in app list thus should not show apps page in NTP4. 221 // Ash shows apps in app list thus should not show apps page in NTP4.
224 #if defined(USE_ASH) 222 #if defined(USE_ASH)
225 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH; 223 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH;
226 #else 224 #else
227 return true; 225 return true;
228 #endif 226 #endif
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, 347 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource,
350 const char* mime_type, 348 const char* mime_type,
351 int resource_id) { 349 int resource_id) {
352 DCHECK(resource); 350 DCHECK(resource);
353 DCHECK(mime_type); 351 DCHECK(mime_type);
354 resource_map_[std::string(resource)] = 352 resource_map_[std::string(resource)] =
355 std::make_pair(std::string(mime_type), resource_id); 353 std::make_pair(std::string(mime_type), resource_id);
356 } 354 }
357 355
358 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} 356 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {}
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.h ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698