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

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

Issue 2805089: Add bookmark promo to NTP on first run. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months 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/new_tab_ui_uitest.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <string> 5 #include <string>
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 PrefService* current_prefs = dom_ui_->GetProfile()->GetPrefs(); 47 PrefService* current_prefs = dom_ui_->GetProfile()->GetPrefs();
48 if (current_prefs->HasPrefPath(prefs::kNTPTipsServer)) { 48 if (current_prefs->HasPrefPath(prefs::kNTPTipsServer)) {
49 std::string server = current_prefs->GetString(prefs::kNTPTipsServer); 49 std::string server = current_prefs->GetString(prefs::kNTPTipsServer);
50 std::string locale = g_browser_process->GetApplicationLocale(); 50 std::string locale = g_browser_process->GetApplicationLocale();
51 if (!EndsWith(server, locale, false)) { 51 if (!EndsWith(server, locale, false)) {
52 dom_ui_->CallJavascriptFunction(L"tips", list_value); 52 dom_ui_->CallJavascriptFunction(L"tips", list_value);
53 return; 53 return;
54 } 54 }
55 } 55 }
56 56
57 // If the user has just started using Chrome with a fresh profile, send only
58 // the "Import bookmarks" promo until the user has either seen it five times
59 // or added or imported bookmarks.
60 if (current_prefs->GetInteger(prefs::kNTPPromoViewsRemaining) > 0) {
61 SendTip(WideToUTF8(l10n_util::GetStringF(IDS_IMPORT_BOOKMARKS_PROMO,
62 std::wstring(L"<button class='link'>"),
63 std::wstring(L"</button>"))),
64 L"set_promo_tip", 0);
65 return;
66 }
67
57 if (tips_cache_ != NULL && !tips_cache_->empty()) { 68 if (tips_cache_ != NULL && !tips_cache_->empty()) {
58 if (tips_cache_->GetInteger( 69 if (tips_cache_->GetInteger(
59 WebResourceService::kCurrentTipPrefName, &current_tip_index) && 70 WebResourceService::kCurrentTipPrefName, &current_tip_index) &&
60 tips_cache_->GetList( 71 tips_cache_->GetList(
61 WebResourceService::kTipCachePrefName, &wr_list) && 72 WebResourceService::kTipCachePrefName, &wr_list) &&
62 wr_list && wr_list->GetSize() > 0) { 73 wr_list && wr_list->GetSize() > 0) {
63 if (wr_list->GetSize() <= static_cast<size_t>(current_tip_index)) { 74 if (wr_list->GetSize() <= static_cast<size_t>(current_tip_index)) {
64 // Check to see whether the home page is set to NTP; if not, add tip 75 // Check to see whether the home page is set to NTP; if not, add tip
65 // to set home page before resetting tip index to 0. 76 // to set home page before resetting tip index to 0.
66 current_tip_index = 0; 77 current_tip_index = 0;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 prefs->RegisterDictionaryPref(prefs::kNTPTipsCache); 112 prefs->RegisterDictionaryPref(prefs::kNTPTipsCache);
102 prefs->RegisterStringPref(prefs::kNTPTipsServer, 113 prefs->RegisterStringPref(prefs::kNTPTipsServer,
103 WebResourceService::kDefaultResourceServer); 114 WebResourceService::kDefaultResourceServer);
104 } 115 }
105 116
106 bool TipsHandler::IsValidURL(const std::wstring& url_string) { 117 bool TipsHandler::IsValidURL(const std::wstring& url_string) {
107 GURL url(WideToUTF8(url_string)); 118 GURL url(WideToUTF8(url_string));
108 return !url.is_empty() && (url.SchemeIs(chrome::kHttpScheme) || 119 return !url.is_empty() && (url.SchemeIs(chrome::kHttpScheme) ||
109 url.SchemeIs(chrome::kHttpsScheme)); 120 url.SchemeIs(chrome::kHttpsScheme));
110 } 121 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui_uitest.cc ('k') | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698