| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "ui/base/resource/resource_bundle.h" | 55 #include "ui/base/resource/resource_bundle.h" |
| 56 | 56 |
| 57 #if !defined(OS_ANDROID) | 57 #if !defined(OS_ANDROID) |
| 58 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 58 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| 59 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" | 59 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h" |
| 60 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" | 60 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" |
| 61 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h" | 61 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h" |
| 62 #else | 62 #else |
| 63 #include "chrome/browser/ui/webui/ntp/android/bookmarks_handler.h" | 63 #include "chrome/browser/ui/webui/ntp/android/bookmarks_handler.h" |
| 64 #include "chrome/browser/ui/webui/ntp/android/context_menu_handler.h" | 64 #include "chrome/browser/ui/webui/ntp/android/context_menu_handler.h" |
| 65 #include "chrome/browser/ui/webui/ntp/android/promo_handler.h" |
| 65 #endif | 66 #endif |
| 66 | 67 |
| 67 using content::BrowserThread; | 68 using content::BrowserThread; |
| 68 using content::RenderViewHost; | 69 using content::RenderViewHost; |
| 69 using content::UserMetricsAction; | 70 using content::UserMetricsAction; |
| 70 using content::WebContents; | 71 using content::WebContents; |
| 71 using content::WebUIController; | 72 using content::WebUIController; |
| 72 | 73 |
| 73 namespace { | 74 namespace { |
| 74 | 75 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 web_ui->AddMessageHandler(new AppLauncherHandler(service)); | 126 web_ui->AddMessageHandler(new AppLauncherHandler(service)); |
| 126 } | 127 } |
| 127 #endif | 128 #endif |
| 128 | 129 |
| 129 web_ui->AddMessageHandler(new NewTabPageHandler()); | 130 web_ui->AddMessageHandler(new NewTabPageHandler()); |
| 130 web_ui->AddMessageHandler(new FaviconWebUIHandler()); | 131 web_ui->AddMessageHandler(new FaviconWebUIHandler()); |
| 131 } | 132 } |
| 132 | 133 |
| 133 #if defined(OS_ANDROID) | 134 #if defined(OS_ANDROID) |
| 134 // These handlers are specific to the Android NTP page. | 135 // These handlers are specific to the Android NTP page. |
| 135 web_ui->AddMessageHandler((new BookmarksHandler())); | 136 web_ui->AddMessageHandler(new BookmarksHandler()); |
| 136 web_ui->AddMessageHandler((new ContextMenuHandler())); | 137 web_ui->AddMessageHandler(new ContextMenuHandler()); |
| 138 if (!GetProfile()->IsOffTheRecord()) |
| 139 web_ui->AddMessageHandler(new PromoHandler()); |
| 137 #else | 140 #else |
| 138 // Android uses native UI for sync setup. | 141 // Android uses native UI for sync setup. |
| 139 if (NTPLoginHandler::ShouldShow(GetProfile())) | 142 if (NTPLoginHandler::ShouldShow(GetProfile())) |
| 140 web_ui->AddMessageHandler(new NTPLoginHandler()); | 143 web_ui->AddMessageHandler(new NTPLoginHandler()); |
| 141 #endif | 144 #endif |
| 142 | 145 |
| 143 // Initializing the CSS and HTML can require some CPU, so do it after | 146 // Initializing the CSS and HTML can require some CPU, so do it after |
| 144 // we've hooked up the most visited handler. This allows the DB query | 147 // we've hooked up the most visited handler. This allows the DB query |
| 145 // for the new tab thumbs to happen earlier. | 148 // for the new tab thumbs to happen earlier. |
| 146 InitializeCSSCaches(); | 149 InitializeCSSCaches(); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 405 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
| 403 const char* mime_type, | 406 const char* mime_type, |
| 404 int resource_id) { | 407 int resource_id) { |
| 405 DCHECK(resource); | 408 DCHECK(resource); |
| 406 DCHECK(mime_type); | 409 DCHECK(mime_type); |
| 407 resource_map_[std::string(resource)] = | 410 resource_map_[std::string(resource)] = |
| 408 std::make_pair(std::string(mime_type), resource_id); | 411 std::make_pair(std::string(mime_type), resource_id); |
| 409 } | 412 } |
| 410 | 413 |
| 411 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} | 414 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} |
| OLD | NEW |