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

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: addressed comments 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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" 15 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h"
16 #include "chrome/browser/first_run/first_run.h" 16 #include "chrome/browser/first_run/first_run.h"
17 #include "chrome/browser/google/google_brand.h" 17 #include "chrome/browser/google/google_brand.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/signin/account_tracker_service_factory.h" 20 #include "chrome/browser/signin/account_tracker_service_factory.h"
21 #include "chrome/browser/signin/signin_error_controller_factory.h" 21 #include "chrome/browser/signin/signin_error_controller_factory.h"
22 #include "chrome/browser/signin/signin_manager_factory.h" 22 #include "chrome/browser/signin/signin_manager_factory.h"
23 #include "chrome/browser/signin/signin_promo_util.h"
23 #include "chrome/browser/ui/webui/options/core_options_handler.h" 24 #include "chrome/browser/ui/webui/options/core_options_handler.h"
24 #include "chrome/browser/ui/webui/theme_source.h" 25 #include "chrome/browser/ui/webui/theme_source.h"
25 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
27 #include "components/google/core/browser/google_util.h" 28 #include "components/google/core/browser/google_util.h"
28 #include "components/pref_registry/pref_registry_syncable.h" 29 #include "components/pref_registry/pref_registry_syncable.h"
29 #include "components/prefs/pref_service.h" 30 #include "components/prefs/pref_service.h"
30 #include "components/signin/core/browser/account_tracker_service.h" 31 #include "components/signin/core/browser/account_tracker_service.h"
31 #include "components/signin/core/browser/signin_manager.h" 32 #include "components/signin/core/browser/signin_manager.h"
32 #include "components/signin/core/common/profile_management_switches.h" 33 #include "components/signin/core/common/profile_management_switches.h"
33 #include "content/public/browser/url_data_source.h" 34 #include "content/public/browser/url_data_source.h"
34 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
35 #include "content/public/browser/web_ui.h" 36 #include "content/public/browser/web_ui.h"
36 #include "content/public/browser/web_ui_data_source.h" 37 #include "content/public/browser/web_ui_data_source.h"
37 #include "google_apis/gaia/gaia_urls.h" 38 #include "google_apis/gaia/gaia_urls.h"
38 #include "net/base/escape.h" 39 #include "net/base/escape.h"
39 #include "net/base/network_change_notifier.h"
40 #include "net/base/url_util.h" 40 #include "net/base/url_util.h"
41 #include "url/gurl.h" 41 #include "url/gurl.h"
42 42
43 #if defined(OS_WIN) 43 #if defined(OS_WIN)
44 #include "base/win/windows_version.h" 44 #include "base/win/windows_version.h"
45 #endif 45 #endif
46 46
47 using content::WebContents; 47 using content::WebContents;
48 48
49 namespace { 49 namespace {
(...skipping 26 matching lines...) Expand all
76 76
77 // Returns true if the user has previously skipped the sign in promo. 77 // Returns true if the user has previously skipped the sign in promo.
78 bool HasUserSkippedPromo(Profile* profile) { 78 bool HasUserSkippedPromo(Profile* profile) {
79 return profile->GetPrefs()->GetBoolean(prefs::kSignInPromoUserSkipped); 79 return profile->GetPrefs()->GetBoolean(prefs::kSignInPromoUserSkipped);
80 } 80 }
81 81
82 } // namespace 82 } // namespace
83 83
84 namespace signin { 84 namespace signin {
85 85
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) { 86 bool ShouldShowPromoAtStartup(Profile* profile, bool is_new_profile) {
110 DCHECK(profile); 87 DCHECK(profile);
111 88
112 // Don't show if the profile is an incognito. 89 // Don't show if the profile is an incognito.
113 if (profile->IsOffTheRecord()) 90 if (profile->IsOffTheRecord())
114 return false; 91 return false;
115 92
116 if (!ShouldShowPromo(profile)) 93 if (!ShouldShowPromo(profile))
117 return false; 94 return false;
118 95
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 328
352 void RegisterProfilePrefs( 329 void RegisterProfilePrefs(
353 user_prefs::PrefRegistrySyncable* registry) { 330 user_prefs::PrefRegistrySyncable* registry) {
354 registry->RegisterIntegerPref(prefs::kSignInPromoStartupCount, 0); 331 registry->RegisterIntegerPref(prefs::kSignInPromoStartupCount, 0);
355 registry->RegisterBooleanPref(prefs::kSignInPromoUserSkipped, false); 332 registry->RegisterBooleanPref(prefs::kSignInPromoUserSkipped, false);
356 registry->RegisterBooleanPref(prefs::kSignInPromoShowOnFirstRunAllowed, true); 333 registry->RegisterBooleanPref(prefs::kSignInPromoShowOnFirstRunAllowed, true);
357 registry->RegisterBooleanPref(prefs::kSignInPromoShowNTPBubble, false); 334 registry->RegisterBooleanPref(prefs::kSignInPromoShowNTPBubble, false);
358 } 335 }
359 336
360 } // namespace signin 337 } // namespace signin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698