| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 7 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/sync/profile_sync_service.h" | 26 #include "chrome/browser/sync/profile_sync_service.h" |
| 27 #include "chrome/browser/themes/theme_service_factory.h" | 27 #include "chrome/browser/themes/theme_service_factory.h" |
| 28 #include "chrome/browser/themes/theme_service.h" | 28 #include "chrome/browser/themes/theme_service.h" |
| 29 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/webui/metrics_handler.h" | 30 #include "chrome/browser/ui/webui/metrics_handler.h" |
| 31 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 31 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| 32 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" | 32 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" |
| 33 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" | 33 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" |
| 34 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" | 34 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" |
| 35 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" | 35 #include "chrome/browser/ui/webui/ntp/new_tab_page_handler.h" |
| 36 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" | |
| 37 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" | 36 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" |
| 38 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" | 37 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" |
| 39 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" | 38 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
| 40 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" | 39 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" |
| 41 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h" | 40 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h" |
| 42 #include "chrome/browser/ui/webui/theme_source.h" | 41 #include "chrome/browser/ui/webui/theme_source.h" |
| 43 #include "chrome/common/chrome_notification_types.h" | 42 #include "chrome/common/chrome_notification_types.h" |
| 44 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
| 45 #include "chrome/common/extensions/extension.h" | 44 #include "chrome/common/extensions/extension.h" |
| 46 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 47 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
| 48 #include "content/browser/renderer_host/render_view_host.h" | 47 #include "content/browser/renderer_host/render_view_host.h" |
| 49 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
| 50 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
| 51 #include "content/public/browser/user_metrics.h" | 50 #include "content/public/browser/user_metrics.h" |
| 52 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 53 #include "content/public/browser/web_ui.h" | 52 #include "content/public/browser/web_ui.h" |
| 54 #include "grit/browser_resources.h" | 53 #include "grit/browser_resources.h" |
| 55 #include "grit/generated_resources.h" | 54 #include "grit/generated_resources.h" |
| 56 #include "grit/theme_resources.h" | 55 #include "grit/theme_resources.h" |
| 57 #include "ui/base/l10n/l10n_util.h" | 56 #include "ui/base/l10n/l10n_util.h" |
| 58 | 57 |
| 58 #if !defined(OS_ANDROID) |
| 59 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" |
| 60 #endif |
| 61 |
| 59 using content::BrowserThread; | 62 using content::BrowserThread; |
| 60 using content::UserMetricsAction; | 63 using content::UserMetricsAction; |
| 61 using content::WebContents; | 64 using content::WebContents; |
| 62 using content::WebUIController; | 65 using content::WebUIController; |
| 63 | 66 |
| 64 namespace { | 67 namespace { |
| 65 | 68 |
| 66 // The amount of time there must be no painting for us to consider painting | 69 // The amount of time there must be no painting for us to consider painting |
| 67 // finished. Observed times are in the ~1200ms range on Windows. | 70 // finished. Observed times are in the ~1200ms range on Windows. |
| 68 const int kTimeoutMs = 2000; | 71 const int kTimeoutMs = 2000; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // thumbnails, but also clicks on recently bookmarked. | 110 // thumbnails, but also clicks on recently bookmarked. |
| 108 web_ui->SetLinkTransitionType(content::PAGE_TRANSITION_AUTO_BOOKMARK); | 111 web_ui->SetLinkTransitionType(content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 109 | 112 |
| 110 if (!GetProfile()->IsOffTheRecord()) { | 113 if (!GetProfile()->IsOffTheRecord()) { |
| 111 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); | 114 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); |
| 112 web_ui->AddMessageHandler(new MostVisitedHandler()); | 115 web_ui->AddMessageHandler(new MostVisitedHandler()); |
| 113 if (NewTabUI::IsSuggestionsPageEnabled()) | 116 if (NewTabUI::IsSuggestionsPageEnabled()) |
| 114 web_ui->AddMessageHandler(new SuggestionsHandler()); | 117 web_ui->AddMessageHandler(new SuggestionsHandler()); |
| 115 web_ui->AddMessageHandler(new RecentlyClosedTabsHandler()); | 118 web_ui->AddMessageHandler(new RecentlyClosedTabsHandler()); |
| 116 web_ui->AddMessageHandler(new MetricsHandler()); | 119 web_ui->AddMessageHandler(new MetricsHandler()); |
| 120 #if !defined(OS_ANDROID) |
| 121 // Android doesn't have a sync promo/username on NTP. |
| 117 if (GetProfile()->IsSyncAccessible()) | 122 if (GetProfile()->IsSyncAccessible()) |
| 118 web_ui->AddMessageHandler(new NewTabPageSyncHandler()); | 123 web_ui->AddMessageHandler(new NewTabPageSyncHandler()); |
| 124 #endif |
| 119 ExtensionService* service = GetProfile()->GetExtensionService(); | 125 ExtensionService* service = GetProfile()->GetExtensionService(); |
| 120 // We might not have an ExtensionService (on ChromeOS when not logged in | 126 // We might not have an ExtensionService (on ChromeOS when not logged in |
| 121 // for example). | 127 // for example). |
| 122 if (service) | 128 if (service) |
| 123 web_ui->AddMessageHandler(new AppLauncherHandler(service)); | 129 web_ui->AddMessageHandler(new AppLauncherHandler(service)); |
| 124 | 130 |
| 125 web_ui->AddMessageHandler(new NewTabPageHandler()); | 131 web_ui->AddMessageHandler(new NewTabPageHandler()); |
| 126 web_ui->AddMessageHandler(new FaviconWebUIHandler()); | 132 web_ui->AddMessageHandler(new FaviconWebUIHandler()); |
| 127 } | 133 } |
| 128 | 134 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 } | 393 } |
| 388 | 394 |
| 389 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 395 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
| 390 const char* mime_type, | 396 const char* mime_type, |
| 391 int resource_id) { | 397 int resource_id) { |
| 392 DCHECK(resource); | 398 DCHECK(resource); |
| 393 DCHECK(mime_type); | 399 DCHECK(mime_type); |
| 394 resource_map_[std::string(resource)] = | 400 resource_map_[std::string(resource)] = |
| 395 std::make_pair(std::string(mime_type), resource_id); | 401 std::make_pair(std::string(mime_type), resource_id); |
| 396 } | 402 } |
| OLD | NEW |