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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_ui.cc

Issue 10332049: remove ntp app install hint (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync it Created 8 years, 7 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
OLDNEW
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 "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/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
17 #include "base/metrics/field_trial.h"
18 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
19 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
20 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
21 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
22 #include "chrome/browser/defaults.h" 21 #include "chrome/browser/defaults.h"
23 #include "chrome/browser/prefs/pref_service.h" 22 #include "chrome/browser/prefs/pref_service.h"
24 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/sessions/session_types.h" 24 #include "chrome/browser/sessions/session_types.h"
26 #include "chrome/browser/sync/profile_sync_service.h" 25 #include "chrome/browser/sync/profile_sync_service.h"
27 #include "chrome/browser/themes/theme_service.h" 26 #include "chrome/browser/themes/theme_service.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // finished. Observed times are in the ~1200ms range on Windows. 71 // finished. Observed times are in the ~1200ms range on Windows.
73 const int kTimeoutMs = 2000; 72 const int kTimeoutMs = 2000;
74 73
75 // Strings sent to the page via jstemplates used to set the direction of the 74 // Strings sent to the page via jstemplates used to set the direction of the
76 // HTML document based on locale. 75 // HTML document based on locale.
77 const char kRTLHtmlTextDirection[] = "rtl"; 76 const char kRTLHtmlTextDirection[] = "rtl";
78 const char kLTRHtmlTextDirection[] = "ltr"; 77 const char kLTRHtmlTextDirection[] = "ltr";
79 78
80 static base::LazyInstance<std::set<const WebUIController*> > g_live_new_tabs; 79 static base::LazyInstance<std::set<const WebUIController*> > g_live_new_tabs;
81 80
82 // Group IDs for the web store link field trial.
83 int g_footer_group = 0;
84 int g_hint_group = 0;
85
86 bool WebStoreLinkExperimentGroupIs(int group) {
87 return base::FieldTrialList::TrialExists(kWebStoreLinkExperiment) &&
88 base::FieldTrialList::FindValue(kWebStoreLinkExperiment) == group;
89 }
90
91 } // namespace 81 } // namespace
92 82
93 // The Web Store footer experiment FieldTrial name.
94 const char kWebStoreLinkExperiment[] = "WebStoreLinkExperiment";
95
96 /////////////////////////////////////////////////////////////////////////////// 83 ///////////////////////////////////////////////////////////////////////////////
97 // NewTabUI 84 // NewTabUI
98 85
99 NewTabUI::NewTabUI(content::WebUI* web_ui) 86 NewTabUI::NewTabUI(content::WebUI* web_ui)
100 : WebUIController(web_ui), 87 : WebUIController(web_ui),
101 showing_sync_bubble_(false) { 88 showing_sync_bubble_(false) {
102 g_live_new_tabs.Pointer()->insert(this); 89 g_live_new_tabs.Pointer()->insert(this);
103 // Override some options on the Web UI. 90 // Override some options on the Web UI.
104 web_ui->HideFavicon(); 91 web_ui->HideFavicon();
105 92
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 #if !defined(OS_ANDROID) 266 #if !defined(OS_ANDROID)
280 AppLauncherHandler::RegisterUserPrefs(prefs); 267 AppLauncherHandler::RegisterUserPrefs(prefs);
281 #endif 268 #endif
282 MostVisitedHandler::RegisterUserPrefs(prefs); 269 MostVisitedHandler::RegisterUserPrefs(prefs);
283 if (NewTabUI::IsSuggestionsPageEnabled()) 270 if (NewTabUI::IsSuggestionsPageEnabled())
284 SuggestionsHandler::RegisterUserPrefs(prefs); 271 SuggestionsHandler::RegisterUserPrefs(prefs);
285 browser_sync::ForeignSessionHandler::RegisterUserPrefs(prefs); 272 browser_sync::ForeignSessionHandler::RegisterUserPrefs(prefs);
286 } 273 }
287 274
288 // static 275 // static
289 void NewTabUI::SetupFieldTrials() {
290 scoped_refptr<base::FieldTrial> trial(
291 base::FieldTrialList::FactoryGetFieldTrial(
292 kWebStoreLinkExperiment, 1, "Disabled", 2025, 6, 1, NULL));
293
294 // Try to give the user a consistent experience, if possible.
295 if (base::FieldTrialList::IsOneTimeRandomizationEnabled())
296 trial->UseOneTimeRandomization();
297
298 // 33.3% in each group.
299 g_footer_group = trial->AppendGroup("FooterLink", 1);
300 g_hint_group = trial->AppendGroup("PlusIcon", 0);
301 }
302
303 // static
304 bool NewTabUI::ShouldShowWebStoreFooterLink() {
305 const CommandLine* cli = CommandLine::ForCurrentProcess();
306 return cli->HasSwitch(switches::kEnableWebStoreLink) ||
307 WebStoreLinkExperimentGroupIs(g_footer_group);
308 }
309
310 // static
311 bool NewTabUI::ShouldShowAppInstallHint() {
312 const CommandLine* cli = CommandLine::ForCurrentProcess();
313 return cli->HasSwitch(switches::kNtpAppInstallHint) ||
314 WebStoreLinkExperimentGroupIs(g_hint_group);
315 }
316
317 // static
318 bool NewTabUI::ShouldShowApps() { 276 bool NewTabUI::ShouldShowApps() {
319 #if defined(USE_ASH) || defined(OS_ANDROID) 277 #if defined(USE_ASH) || defined(OS_ANDROID)
320 // Ash shows apps in app list thus should not show apps page in NTP4. 278 // Ash shows apps in app list thus should not show apps page in NTP4.
321 // Android does not have apps. 279 // Android does not have apps.
322 return false; 280 return false;
323 #else 281 #else
324 return true; 282 return true;
325 #endif 283 #endif
326 } 284 }
327 285
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 389 }
432 390
433 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, 391 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource,
434 const char* mime_type, 392 const char* mime_type,
435 int resource_id) { 393 int resource_id) {
436 DCHECK(resource); 394 DCHECK(resource);
437 DCHECK(mime_type); 395 DCHECK(mime_type);
438 resource_map_[std::string(resource)] = 396 resource_map_[std::string(resource)] =
439 std::make_pair(std::string(mime_type), resource_id); 397 std::make_pair(std::string(mime_type), resource_id);
440 } 398 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.h ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698