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

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

Issue 14367029: Introduce SigninManagerDelegate and use to eliminate CookieSettings dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge LKGR Created 7 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 "chrome/browser/signin/signin_manager_base.h" 5 #include "chrome/browser/signin/signin_manager_base.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/content_settings/cookie_settings.h"
18 #include "chrome/browser/profiles/profile_info_cache.h" 17 #include "chrome/browser/profiles/profile_info_cache.h"
19 #include "chrome/browser/profiles/profile_io_data.h" 18 #include "chrome/browser/profiles/profile_io_data.h"
20 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/signin/about_signin_internals.h" 20 #include "chrome/browser/signin/about_signin_internals.h"
22 #include "chrome/browser/signin/about_signin_internals_factory.h" 21 #include "chrome/browser/signin/about_signin_internals_factory.h"
23 #include "chrome/browser/signin/signin_global_error.h" 22 #include "chrome/browser/signin/signin_global_error.h"
24 #include "chrome/browser/signin/signin_manager_cookie_helper.h" 23 #include "chrome/browser/signin/signin_manager_cookie_helper.h"
25 #include "chrome/browser/signin/token_service.h" 24 #include "chrome/browser/signin/token_service.h"
26 #include "chrome/browser/signin/token_service_factory.h" 25 #include "chrome/browser/signin/token_service_factory.h"
27 #include "chrome/browser/sync/sync_prefs.h" 26 #include "chrome/browser/sync/sync_prefs.h"
28 #include "chrome/browser/ui/global_error/global_error_service.h" 27 #include "chrome/browser/ui/global_error/global_error_service.h"
29 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 28 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
30 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
33 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
34 #include "google_apis/gaia/gaia_constants.h" 33 #include "google_apis/gaia/gaia_constants.h"
35 #include "google_apis/gaia/gaia_urls.h" 34 #include "google_apis/gaia/gaia_urls.h"
36 #include "third_party/icu/public/i18n/unicode/regex.h" 35 #include "third_party/icu/public/i18n/unicode/regex.h"
37 36
38 using namespace signin_internals_util; 37 using namespace signin_internals_util;
39 38
40 using content::BrowserThread; 39 using content::BrowserThread;
41 40
42 // static 41 // static
43 bool SigninManagerBase::AreSigninCookiesAllowed(Profile* profile) {
44 CookieSettings* cookie_settings =
45 CookieSettings::Factory::GetForProfile(profile);
46 return AreSigninCookiesAllowed(cookie_settings);
47 }
48
49 // static
50 bool SigninManagerBase::AreSigninCookiesAllowed(
51 CookieSettings* cookie_settings) {
52 return cookie_settings &&
53 cookie_settings->IsSettingCookieAllowed(
54 GURL(GaiaUrls::GetInstance()->gaia_origin_url()),
55 GURL(GaiaUrls::GetInstance()->gaia_origin_url()));
56 }
57
58 // static
59 bool SigninManagerBase::IsAllowedUsername(const std::string& username, 42 bool SigninManagerBase::IsAllowedUsername(const std::string& username,
60 const std::string& policy) { 43 const std::string& policy) {
61 if (policy.empty()) 44 if (policy.empty())
62 return true; 45 return true;
63 46
64 // Patterns like "*@foo.com" are not accepted by our regex engine (since they 47 // Patterns like "*@foo.com" are not accepted by our regex engine (since they
65 // are not valid regular expressions - they should instead be ".*@foo.com"). 48 // are not valid regular expressions - they should instead be ".*@foo.com").
66 // For convenience, detect these patterns and insert a "." character at the 49 // For convenience, detect these patterns and insert a "." character at the
67 // front. 50 // front.
68 string16 pattern = UTF8ToUTF16(policy); 51 string16 pattern = UTF8ToUTF16(policy);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 NotifySigninValueChanged(field, value)); 250 NotifySigninValueChanged(field, value));
268 } 251 }
269 252
270 void SigninManagerBase::NotifyDiagnosticsObservers( 253 void SigninManagerBase::NotifyDiagnosticsObservers(
271 const TimedSigninStatusField& field, 254 const TimedSigninStatusField& field,
272 const std::string& value) { 255 const std::string& value) {
273 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, 256 FOR_EACH_OBSERVER(SigninDiagnosticsObserver,
274 signin_diagnostics_observers_, 257 signin_diagnostics_observers_,
275 NotifySigninValueChanged(field, value)); 258 NotifySigninValueChanged(field, value));
276 } 259 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager_base.h ('k') | chrome/browser/signin/signin_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698