| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/dom_ui/new_tab_ui.h" | 7 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 virtual void RegisterMessages(); | 210 virtual void RegisterMessages(); |
| 211 | 211 |
| 212 // Zero promotional message counter. | 212 // Zero promotional message counter. |
| 213 void HandleClosePromotionalMessage(const Value* content); | 213 void HandleClosePromotionalMessage(const Value* content); |
| 214 | 214 |
| 215 private: | 215 private: |
| 216 DISALLOW_COPY_AND_ASSIGN(PromotionalMessageHandler); | 216 DISALLOW_COPY_AND_ASSIGN(PromotionalMessageHandler); |
| 217 }; | 217 }; |
| 218 | 218 |
| 219 void PromotionalMessageHandler::RegisterMessages() { | 219 void PromotionalMessageHandler::RegisterMessages() { |
| 220 dom_ui_->RegisterMessageCallback("stopPromoMessages", | 220 dom_ui_->RegisterMessageCallback("stopPromoLineMessage", |
| 221 NewCallback(this, | 221 NewCallback(this, |
| 222 &PromotionalMessageHandler::HandleClosePromotionalMessage)); | 222 &PromotionalMessageHandler::HandleClosePromotionalMessage)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void PromotionalMessageHandler::HandleClosePromotionalMessage( | 225 void PromotionalMessageHandler::HandleClosePromotionalMessage( |
| 226 const Value* content) { | 226 const Value* content) { |
| 227 dom_ui_->GetProfile()->GetPrefs()->SetInteger(prefs::kNTPPromoRemaining, 0); | 227 dom_ui_->GetProfile()->GetPrefs()->SetInteger( |
| 228 prefs::kNTPPromoLineRemaining, 0); |
| 228 } | 229 } |
| 229 | 230 |
| 230 | 231 |
| 231 /////////////////////////////////////////////////////////////////////////////// | 232 /////////////////////////////////////////////////////////////////////////////// |
| 232 // RecentlyClosedTabsHandler | 233 // RecentlyClosedTabsHandler |
| 233 | 234 |
| 234 class RecentlyClosedTabsHandler : public DOMMessageHandler, | 235 class RecentlyClosedTabsHandler : public DOMMessageHandler, |
| 235 public TabRestoreService::Observer { | 236 public TabRestoreService::Observer { |
| 236 public: | 237 public: |
| 237 RecentlyClosedTabsHandler() : tab_restore_service_(NULL) {} | 238 RecentlyClosedTabsHandler() : tab_restore_service_(NULL) {} |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 force_extension_shelf_visible_ = true; | 560 force_extension_shelf_visible_ = true; |
| 560 focus_location_bar_by_default_ = true; | 561 focus_location_bar_by_default_ = true; |
| 561 should_hide_url_ = true; | 562 should_hide_url_ = true; |
| 562 overridden_title_ = WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_TITLE)); | 563 overridden_title_ = WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_TITLE)); |
| 563 | 564 |
| 564 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more | 565 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more |
| 565 // highly. Note this means we're including clicks on not only most visited | 566 // highly. Note this means we're including clicks on not only most visited |
| 566 // thumbnails, but also clicks on recently bookmarked. | 567 // thumbnails, but also clicks on recently bookmarked. |
| 567 link_transition_type_ = PageTransition::AUTO_BOOKMARK; | 568 link_transition_type_ = PageTransition::AUTO_BOOKMARK; |
| 568 | 569 |
| 569 if (NewTabHTMLSource::first_view() && | |
| 570 (GetProfile()->GetPrefs()->GetInteger(prefs::kRestoreOnStartup) != 0 || | |
| 571 !GetProfile()->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage))) { | |
| 572 NewTabHTMLSource::set_first_view(false); | |
| 573 } | |
| 574 | |
| 575 if (NewTabUI::FirstRunDisabled()) | 570 if (NewTabUI::FirstRunDisabled()) |
| 576 NewTabHTMLSource::set_first_run(false); | 571 NewTabHTMLSource::set_first_run(false); |
| 577 | 572 |
| 578 InitializeCSSCaches(); | 573 InitializeCSSCaches(); |
| 579 if (GetProfile()->IsOffTheRecord()) { | 574 if (GetProfile()->IsOffTheRecord()) { |
| 580 incognito_ = true; | 575 incognito_ = true; |
| 581 | 576 |
| 582 IncognitoTabHTMLSource* html_source = new IncognitoTabHTMLSource( | 577 IncognitoTabHTMLSource* html_source = new IncognitoTabHTMLSource( |
| 583 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)); | 578 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)); |
| 584 ChromeThread::PostTask( | 579 ChromeThread::PostTask( |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 else | 926 else |
| 932 localized_strings.SetString(L"syncispresent", "false"); | 927 localized_strings.SetString(L"syncispresent", "false"); |
| 933 | 928 |
| 934 if (!profile->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) | 929 if (!profile->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) |
| 935 localized_strings.SetString(L"showsetashomepage", "true"); | 930 localized_strings.SetString(L"showsetashomepage", "true"); |
| 936 | 931 |
| 937 SetFontAndTextDirection(&localized_strings); | 932 SetFontAndTextDirection(&localized_strings); |
| 938 | 933 |
| 939 // Let the tab know whether it's the first tab being viewed. | 934 // Let the tab know whether it's the first tab being viewed. |
| 940 if (first_view_) { | 935 if (first_view_) { |
| 941 localized_strings.SetString(L"firstview", L"true"); | 936 // Decrement ntp promo counters; the default values are specified in |
| 942 | |
| 943 // Decrement ntp promo counter; the default value is specified in | |
| 944 // Browser::RegisterUserPrefs. | 937 // Browser::RegisterUserPrefs. |
| 945 profile->GetPrefs()->SetInteger(prefs::kNTPPromoRemaining, | 938 profile->GetPrefs()->SetInteger(prefs::kNTPPromoLineRemaining, |
| 946 profile->GetPrefs()->GetInteger(prefs::kNTPPromoRemaining) - 1); | 939 profile->GetPrefs()->GetInteger(prefs::kNTPPromoLineRemaining) - 1); |
| 940 profile->GetPrefs()->SetInteger(prefs::kNTPPromoImageRemaining, |
| 941 profile->GetPrefs()->GetInteger(prefs::kNTPPromoImageRemaining) - 1); |
| 947 first_view_ = false; | 942 first_view_ = false; |
| 948 } | 943 } |
| 949 | 944 |
| 950 // Control fade and resize animations. | 945 // Control fade and resize animations. |
| 951 std::wstring anim = | 946 std::wstring anim = |
| 952 Animation::ShouldRenderRichAnimation() ? L"true" : L"false"; | 947 Animation::ShouldRenderRichAnimation() ? L"true" : L"false"; |
| 953 localized_strings.SetString(L"anim", anim); | 948 localized_strings.SetString(L"anim", anim); |
| 954 | 949 |
| 955 // Pass the shown_sections pref early so that we can prevent flicker. | 950 // Pass the shown_sections pref early so that we can prevent flicker. |
| 956 const int shown_sections = profile->GetPrefs()->GetInteger( | 951 const int shown_sections = profile->GetPrefs()->GetInteger( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 987 full_html_.append(json_html); | 982 full_html_.append(json_html); |
| 988 size_t after_offset = pos + template_data_placeholder.size(); | 983 size_t after_offset = pos + template_data_placeholder.size(); |
| 989 full_html_.append(new_tab_html.data() + after_offset, | 984 full_html_.append(new_tab_html.data() + after_offset, |
| 990 new_tab_html.size() - after_offset); | 985 new_tab_html.size() - after_offset); |
| 991 } else { | 986 } else { |
| 992 NOTREACHED(); | 987 NOTREACHED(); |
| 993 full_html_.assign(new_tab_html.data(), new_tab_html.size()); | 988 full_html_.assign(new_tab_html.data(), new_tab_html.size()); |
| 994 } | 989 } |
| 995 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_); | 990 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_); |
| 996 } | 991 } |
| OLD | NEW |