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

Side by Side Diff: chrome/browser/signin/signin_promo.cc

Issue 2138643004: [Autofill] Add support for signin promo on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@aaa
Patch Set: signin_promo_util Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/signin/signin_promo.h" 5 #include "chrome/browser/signin/signin_promo.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 18 matching lines...) Expand all
29 #include "components/prefs/pref_service.h" 29 #include "components/prefs/pref_service.h"
30 #include "components/signin/core/browser/account_tracker_service.h" 30 #include "components/signin/core/browser/account_tracker_service.h"
31 #include "components/signin/core/browser/signin_manager.h" 31 #include "components/signin/core/browser/signin_manager.h"
32 #include "components/signin/core/common/profile_management_switches.h" 32 #include "components/signin/core/common/profile_management_switches.h"
33 #include "content/public/browser/url_data_source.h" 33 #include "content/public/browser/url_data_source.h"
34 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
35 #include "content/public/browser/web_ui.h" 35 #include "content/public/browser/web_ui.h"
36 #include "content/public/browser/web_ui_data_source.h" 36 #include "content/public/browser/web_ui_data_source.h"
37 #include "google_apis/gaia/gaia_urls.h" 37 #include "google_apis/gaia/gaia_urls.h"
38 #include "net/base/escape.h" 38 #include "net/base/escape.h"
39 #include "net/base/network_change_notifier.h"
40 #include "net/base/url_util.h" 39 #include "net/base/url_util.h"
41 #include "url/gurl.h" 40 #include "url/gurl.h"
42 41
43 #if defined(OS_WIN) 42 #if defined(OS_WIN)
44 #include "base/win/windows_version.h" 43 #include "base/win/windows_version.h"
45 #endif 44 #endif
46 45
47 using content::WebContents; 46 using content::WebContents;
48 47
49 namespace { 48 namespace {
(...skipping 26 matching lines...) Expand all
76 75
77 // Returns true if the user has previously skipped the sign in promo. 76 // Returns true if the user has previously skipped the sign in promo.
78 bool HasUserSkippedPromo(Profile* profile) { 77 bool HasUserSkippedPromo(Profile* profile) {
79 return profile->GetPrefs()->GetBoolean(prefs::kSignInPromoUserSkipped); 78 return profile->GetPrefs()->GetBoolean(prefs::kSignInPromoUserSkipped);
80 } 79 }
81 80
82 } // namespace 81 } // namespace
83 82
84 namespace signin { 83 namespace signin {
85 84
86 bool ShouldShowPromo(Profile* profile) {
87 #if defined(OS_CHROMEOS)
88 // There's no need to show the sign in promo on cros since cros users are
89 // already logged in.
90 return false;
91 #else
92
93 // Don't bother if we don't have any kind of network connection.
94 if (net::NetworkChangeNotifier::IsOffline())
95 return false;
96
97 // Don't show for supervised profiles.
98 if (profile->IsSupervised())
99 return false;
100
101 // Display the signin promo if the user is not signed in.
102 SigninManager* signin = SigninManagerFactory::GetForProfile(
103 profile->GetOriginalProfile());
104 return !signin->AuthInProgress() && signin->IsSigninAllowed() &&
105 !signin->IsAuthenticated();
106 #endif
107 }
108
109 bool ShouldShowPromoAtStartup(Profile* profile, bool is_new_profile) { 85 bool ShouldShowPromoAtStartup(Profile* profile, bool is_new_profile) {
110 DCHECK(profile); 86 DCHECK(profile);
111 87
112 // Don't show if the profile is an incognito. 88 // Don't show if the profile is an incognito.
113 if (profile->IsOffTheRecord()) 89 if (profile->IsOffTheRecord())
114 return false; 90 return false;
115 91
116 if (!ShouldShowPromo(profile)) 92 if (!ShouldShowPromo(profile))
117 return false; 93 return false;
118 94
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 327
352 void RegisterProfilePrefs( 328 void RegisterProfilePrefs(
353 user_prefs::PrefRegistrySyncable* registry) { 329 user_prefs::PrefRegistrySyncable* registry) {
354 registry->RegisterIntegerPref(prefs::kSignInPromoStartupCount, 0); 330 registry->RegisterIntegerPref(prefs::kSignInPromoStartupCount, 0);
355 registry->RegisterBooleanPref(prefs::kSignInPromoUserSkipped, false); 331 registry->RegisterBooleanPref(prefs::kSignInPromoUserSkipped, false);
356 registry->RegisterBooleanPref(prefs::kSignInPromoShowOnFirstRunAllowed, true); 332 registry->RegisterBooleanPref(prefs::kSignInPromoShowOnFirstRunAllowed, true);
357 registry->RegisterBooleanPref(prefs::kSignInPromoShowNTPBubble, false); 333 registry->RegisterBooleanPref(prefs::kSignInPromoShowNTPBubble, false);
358 } 334 }
359 335
360 } // namespace signin 336 } // namespace signin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698