| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "chrome/browser/defaults.h" |
| 19 #include "chrome/browser/metrics/metric_event_duration_details.h" | 20 #include "chrome/browser/metrics/metric_event_duration_details.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/sessions/session_types.h" | 23 #include "chrome/browser/sessions/session_types.h" |
| 23 #include "chrome/browser/sessions/tab_restore_service.h" | 24 #include "chrome/browser/sessions/tab_restore_service.h" |
| 24 #include "chrome/browser/sessions/tab_restore_service_delegate.h" | 25 #include "chrome/browser/sessions/tab_restore_service_delegate.h" |
| 25 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 26 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 26 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 27 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 27 #include "chrome/browser/sync/profile_sync_service.h" | 28 #include "chrome/browser/sync/profile_sync_service.h" |
| 28 #include "chrome/browser/themes/theme_service.h" | 29 #include "chrome/browser/themes/theme_service.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } // namespace | 312 } // namespace |
| 312 | 313 |
| 313 /////////////////////////////////////////////////////////////////////////////// | 314 /////////////////////////////////////////////////////////////////////////////// |
| 314 // NewTabUI | 315 // NewTabUI |
| 315 | 316 |
| 316 NewTabUI::NewTabUI(TabContents* contents) | 317 NewTabUI::NewTabUI(TabContents* contents) |
| 317 : WebUI(contents) { | 318 : WebUI(contents) { |
| 318 // Override some options on the Web UI. | 319 // Override some options on the Web UI. |
| 319 hide_favicon_ = true; | 320 hide_favicon_ = true; |
| 320 | 321 |
| 321 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4)) | 322 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4) && |
| 323 GetProfile()->GetPrefs()->GetBoolean(prefs::kEnableBookmarkBar) && |
| 324 browser_defaults::bookmarks_enabled) { |
| 322 force_bookmark_bar_visible_ = true; | 325 force_bookmark_bar_visible_ = true; |
| 326 } |
| 323 | 327 |
| 324 focus_location_bar_by_default_ = true; | 328 focus_location_bar_by_default_ = true; |
| 325 should_hide_url_ = true; | 329 should_hide_url_ = true; |
| 326 overridden_title_ = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); | 330 overridden_title_ = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
| 327 | 331 |
| 328 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more | 332 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more |
| 329 // highly. Note this means we're including clicks on not only most visited | 333 // highly. Note this means we're including clicks on not only most visited |
| 330 // thumbnails, but also clicks on recently bookmarked. | 334 // thumbnails, but also clicks on recently bookmarked. |
| 331 link_transition_type_ = PageTransition::AUTO_BOOKMARK; | 335 link_transition_type_ = PageTransition::AUTO_BOOKMARK; |
| 332 | 336 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 SendResponse(request_id, html_bytes); | 630 SendResponse(request_id, html_bytes); |
| 627 } | 631 } |
| 628 | 632 |
| 629 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { | 633 std::string NewTabUI::NewTabHTMLSource::GetMimeType(const std::string&) const { |
| 630 return "text/html"; | 634 return "text/html"; |
| 631 } | 635 } |
| 632 | 636 |
| 633 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { | 637 bool NewTabUI::NewTabHTMLSource::ShouldReplaceExistingSource() const { |
| 634 return false; | 638 return false; |
| 635 } | 639 } |
| OLD | NEW |