Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 385135: Tweaks for promo messages on NTP (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_theme_source.cc ('k') | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 virtual void RegisterMessages(); 212 virtual void RegisterMessages();
213 213
214 // Zero promotional message counter. 214 // Zero promotional message counter.
215 void HandleClosePromotionalMessage(const Value* content); 215 void HandleClosePromotionalMessage(const Value* content);
216 216
217 private: 217 private:
218 DISALLOW_COPY_AND_ASSIGN(PromotionalMessageHandler); 218 DISALLOW_COPY_AND_ASSIGN(PromotionalMessageHandler);
219 }; 219 };
220 220
221 void PromotionalMessageHandler::RegisterMessages() { 221 void PromotionalMessageHandler::RegisterMessages() {
222 dom_ui_->RegisterMessageCallback("stopPromoMessages", 222 dom_ui_->RegisterMessageCallback("stopPromoLineMessage",
223 NewCallback(this, 223 NewCallback(this,
224 &PromotionalMessageHandler::HandleClosePromotionalMessage)); 224 &PromotionalMessageHandler::HandleClosePromotionalMessage));
225 } 225 }
226 226
227 void PromotionalMessageHandler::HandleClosePromotionalMessage( 227 void PromotionalMessageHandler::HandleClosePromotionalMessage(
228 const Value* content) { 228 const Value* content) {
229 dom_ui_->GetProfile()->GetPrefs()->SetInteger(prefs::kNTPPromoRemaining, 0); 229 dom_ui_->GetProfile()->GetPrefs()->SetInteger(
230 prefs::kNTPPromoLineRemaining, 0);
230 } 231 }
231 232
232 233
233 /////////////////////////////////////////////////////////////////////////////// 234 ///////////////////////////////////////////////////////////////////////////////
234 // RecentlyClosedTabsHandler 235 // RecentlyClosedTabsHandler
235 236
236 class RecentlyClosedTabsHandler : public DOMMessageHandler, 237 class RecentlyClosedTabsHandler : public DOMMessageHandler,
237 public TabRestoreService::Observer { 238 public TabRestoreService::Observer {
238 public: 239 public:
239 RecentlyClosedTabsHandler() : tab_restore_service_(NULL) {} 240 RecentlyClosedTabsHandler() : tab_restore_service_(NULL) {}
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 force_extension_shelf_visible_ = true; 562 force_extension_shelf_visible_ = true;
562 focus_location_bar_by_default_ = true; 563 focus_location_bar_by_default_ = true;
563 should_hide_url_ = true; 564 should_hide_url_ = true;
564 overridden_title_ = WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_TITLE)); 565 overridden_title_ = WideToUTF16Hack(l10n_util::GetString(IDS_NEW_TAB_TITLE));
565 566
566 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more 567 // We count all link clicks as AUTO_BOOKMARK, so that site can be ranked more
567 // highly. Note this means we're including clicks on not only most visited 568 // highly. Note this means we're including clicks on not only most visited
568 // thumbnails, but also clicks on recently bookmarked. 569 // thumbnails, but also clicks on recently bookmarked.
569 link_transition_type_ = PageTransition::AUTO_BOOKMARK; 570 link_transition_type_ = PageTransition::AUTO_BOOKMARK;
570 571
571 if (NewTabHTMLSource::first_view() &&
572 (GetProfile()->GetPrefs()->GetInteger(prefs::kRestoreOnStartup) != 0 ||
573 !GetProfile()->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage))) {
574 NewTabHTMLSource::set_first_view(false);
575 }
576
577 if (NewTabUI::FirstRunDisabled()) 572 if (NewTabUI::FirstRunDisabled())
578 NewTabHTMLSource::set_first_run(false); 573 NewTabHTMLSource::set_first_run(false);
579 574
580 InitializeCSSCaches(); 575 InitializeCSSCaches();
581 if (GetProfile()->IsOffTheRecord()) { 576 if (GetProfile()->IsOffTheRecord()) {
582 incognito_ = true; 577 incognito_ = true;
583 578
584 IncognitoTabHTMLSource* html_source = new IncognitoTabHTMLSource( 579 IncognitoTabHTMLSource* html_source = new IncognitoTabHTMLSource(
585 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)); 580 GetProfile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar));
586 ChromeThread::PostTask( 581 ChromeThread::PostTask(
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 else 928 else
934 localized_strings.SetString(L"syncispresent", "false"); 929 localized_strings.SetString(L"syncispresent", "false");
935 930
936 if (!profile->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) 931 if (!profile->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage))
937 localized_strings.SetString(L"showsetashomepage", "true"); 932 localized_strings.SetString(L"showsetashomepage", "true");
938 933
939 SetFontAndTextDirection(&localized_strings); 934 SetFontAndTextDirection(&localized_strings);
940 935
941 // Let the tab know whether it's the first tab being viewed. 936 // Let the tab know whether it's the first tab being viewed.
942 if (first_view_) { 937 if (first_view_) {
943 localized_strings.SetString(L"firstview", L"true"); 938 // Decrement ntp promo counters; the default values are specified in
944
945 // Decrement ntp promo counter; the default value is specified in
946 // Browser::RegisterUserPrefs. 939 // Browser::RegisterUserPrefs.
947 profile->GetPrefs()->SetInteger(prefs::kNTPPromoRemaining, 940 profile->GetPrefs()->SetInteger(prefs::kNTPPromoLineRemaining,
948 profile->GetPrefs()->GetInteger(prefs::kNTPPromoRemaining) - 1); 941 profile->GetPrefs()->GetInteger(prefs::kNTPPromoLineRemaining) - 1);
942 profile->GetPrefs()->SetInteger(prefs::kNTPPromoImageRemaining,
943 profile->GetPrefs()->GetInteger(prefs::kNTPPromoImageRemaining) - 1);
949 first_view_ = false; 944 first_view_ = false;
950 } 945 }
951 946
952 // Control fade and resize animations. 947 // Control fade and resize animations.
953 std::wstring anim = 948 std::wstring anim =
954 Animation::ShouldRenderRichAnimation() ? L"true" : L"false"; 949 Animation::ShouldRenderRichAnimation() ? L"true" : L"false";
955 localized_strings.SetString(L"anim", anim); 950 localized_strings.SetString(L"anim", anim);
956 951
957 // Pass the shown_sections pref early so that we can prevent flicker. 952 // Pass the shown_sections pref early so that we can prevent flicker.
958 const int shown_sections = profile->GetPrefs()->GetInteger( 953 const int shown_sections = profile->GetPrefs()->GetInteger(
(...skipping 30 matching lines...) Expand all
989 full_html_.append(json_html); 984 full_html_.append(json_html);
990 size_t after_offset = pos + template_data_placeholder.size(); 985 size_t after_offset = pos + template_data_placeholder.size();
991 full_html_.append(new_tab_html.data() + after_offset, 986 full_html_.append(new_tab_html.data() + after_offset,
992 new_tab_html.size() - after_offset); 987 new_tab_html.size() - after_offset);
993 } else { 988 } else {
994 NOTREACHED(); 989 NOTREACHED();
995 full_html_.assign(new_tab_html.data(), new_tab_html.size()); 990 full_html_.assign(new_tab_html.data(), new_tab_html.size());
996 } 991 }
997 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_); 992 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html_);
998 } 993 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_theme_source.cc ('k') | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698