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 "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 "apps/app_launcher.h" | |
10 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
11 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
13 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
14 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
15 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/webui/metrics_handler.h" | 16 #include "chrome/browser/ui/webui/metrics_handler.h" |
18 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" | 17 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" |
19 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" | 18 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" |
(...skipping 25 matching lines...) Expand all Loading... |
45 #include "chrome/browser/ui/webui/ntp/android/bookmarks_handler.h" | 44 #include "chrome/browser/ui/webui/ntp/android/bookmarks_handler.h" |
46 #include "chrome/browser/ui/webui/ntp/android/context_menu_handler.h" | 45 #include "chrome/browser/ui/webui/ntp/android/context_menu_handler.h" |
47 #include "chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.h" | 46 #include "chrome/browser/ui/webui/ntp/android/new_tab_page_ready_handler.h" |
48 #include "chrome/browser/ui/webui/ntp/android/promo_handler.h" | 47 #include "chrome/browser/ui/webui/ntp/android/promo_handler.h" |
49 #endif | 48 #endif |
50 | 49 |
51 #if defined(ENABLE_THEMES) | 50 #if defined(ENABLE_THEMES) |
52 #include "chrome/browser/ui/webui/theme_handler.h" | 51 #include "chrome/browser/ui/webui/theme_handler.h" |
53 #endif | 52 #endif |
54 | 53 |
| 54 #if defined(USE_ASH) |
| 55 #include "chrome/browser/ui/host_desktop.h" |
| 56 #endif |
| 57 |
55 using content::BrowserThread; | 58 using content::BrowserThread; |
56 using content::RenderViewHost; | 59 using content::RenderViewHost; |
57 using content::WebUIController; | 60 using content::WebUIController; |
58 | 61 |
59 namespace { | 62 namespace { |
60 | 63 |
61 // The amount of time there must be no painting for us to consider painting | 64 // The amount of time there must be no painting for us to consider painting |
62 // finished. Observed times are in the ~1200ms range on Windows. | 65 // finished. Observed times are in the ~1200ms range on Windows. |
63 const int kTimeoutMs = 2000; | 66 const int kTimeoutMs = 2000; |
64 | 67 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 NewTabPageHandler::RegisterUserPrefs(registry); | 238 NewTabPageHandler::RegisterUserPrefs(registry); |
236 if (NewTabUI::IsDiscoveryInNTPEnabled()) | 239 if (NewTabUI::IsDiscoveryInNTPEnabled()) |
237 SuggestionsHandler::RegisterUserPrefs(registry); | 240 SuggestionsHandler::RegisterUserPrefs(registry); |
238 #endif | 241 #endif |
239 MostVisitedHandler::RegisterUserPrefs(registry); | 242 MostVisitedHandler::RegisterUserPrefs(registry); |
240 browser_sync::ForeignSessionHandler::RegisterUserPrefs(registry); | 243 browser_sync::ForeignSessionHandler::RegisterUserPrefs(registry); |
241 } | 244 } |
242 | 245 |
243 // static | 246 // static |
244 bool NewTabUI::ShouldShowApps() { | 247 bool NewTabUI::ShouldShowApps() { |
| 248 // Ash shows apps in app list thus should not show apps page in NTP4. |
| 249 // Android does not have apps. |
245 #if defined(OS_ANDROID) | 250 #if defined(OS_ANDROID) |
246 // Ash shows apps in app list thus should not show apps page in NTP4. | |
247 // Android does not have apps. | |
248 return false; | 251 return false; |
| 252 #elif defined(USE_ASH) |
| 253 return chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH; |
249 #else | 254 #else |
250 // This needs to be synchronous, so we use the value the last time it | 255 return true; |
251 // was checked. | |
252 return !apps::WasAppLauncherEnabled(); | |
253 #endif | 256 #endif |
254 } | 257 } |
255 | 258 |
256 // static | 259 // static |
257 bool NewTabUI::IsDiscoveryInNTPEnabled() { | 260 bool NewTabUI::IsDiscoveryInNTPEnabled() { |
258 // TODO(beaudoin): The flag was removed during a clean-up pass. We leave that | 261 // TODO(beaudoin): The flag was removed during a clean-up pass. We leave that |
259 // here to easily enable it back when we will explore this option again. | 262 // here to easily enable it back when we will explore this option again. |
260 return false; | 263 return false; |
261 } | 264 } |
262 | 265 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 380 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
378 const char* mime_type, | 381 const char* mime_type, |
379 int resource_id) { | 382 int resource_id) { |
380 DCHECK(resource); | 383 DCHECK(resource); |
381 DCHECK(mime_type); | 384 DCHECK(mime_type); |
382 resource_map_[std::string(resource)] = | 385 resource_map_[std::string(resource)] = |
383 std::make_pair(std::string(mime_type), resource_id); | 386 std::make_pair(std::string(mime_type), resource_id); |
384 } | 387 } |
385 | 388 |
386 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} | 389 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} |
OLD | NEW |