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

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

Issue 216703002: Move the SigninProcess APIs from SigninManager to ChromeSigninClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove cruft Created 6 years, 8 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.h" 5 #include "chrome/browser/signin/signin_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/profiles/profile_io_data.h" 16 #include "chrome/browser/profiles/profile_io_data.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_account_id_helper.h" 18 #include "chrome/browser/signin/signin_account_id_helper.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/common/profile_management_switches.h" 20 #include "chrome/common/profile_management_switches.h"
21 #include "components/signin/core/browser/profile_oauth2_token_service.h" 21 #include "components/signin/core/browser/profile_oauth2_token_service.h"
22 #include "components/signin/core/browser/signin_client.h" 22 #include "components/signin/core/browser/signin_client.h"
23 #include "components/signin/core/browser/signin_internals_util.h" 23 #include "components/signin/core/browser/signin_internals_util.h"
24 #include "components/signin/core/browser/signin_manager_cookie_helper.h" 24 #include "components/signin/core/browser/signin_manager_cookie_helper.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/render_process_host.h"
27 #include "content/public/common/child_process_host.h"
28 #include "google_apis/gaia/gaia_auth_util.h" 26 #include "google_apis/gaia/gaia_auth_util.h"
29 #include "google_apis/gaia/gaia_urls.h" 27 #include "google_apis/gaia/gaia_urls.h"
30 #include "net/base/escape.h" 28 #include "net/base/escape.h"
31 #include "third_party/icu/source/i18n/unicode/regex.h" 29 #include "third_party/icu/source/i18n/unicode/regex.h"
32 30
33 using namespace signin_internals_util; 31 using namespace signin_internals_util;
34 32
35 using content::ChildProcessHost;
36 using content::RenderProcessHost;
37
38 namespace { 33 namespace {
39 34
40 const char kChromiumSyncService[] = "service=chromiumsync"; 35 const char kChromiumSyncService[] = "service=chromiumsync";
41 36
42 } // namespace 37 } // namespace
43 38
44 // Under the covers, we use a dummy chrome-extension ID to serve the purposes 39 // Under the covers, we use a dummy chrome-extension ID to serve the purposes
45 // outlined in the .h file comment for this string. 40 // outlined in the .h file comment for this string.
46 const char SigninManager::kChromeSigninEffectiveSite[] = 41 const char SigninManager::kChromeSigninEffectiveSite[] =
47 "chrome-extension://acfccoigjajmmgbhpfbjnpckhjjegnih"; 42 "chrome-extension://acfccoigjajmmgbhpfbjnpckhjjegnih";
(...skipping 17 matching lines...) Expand all
65 url.query(), net::UnescapeRule::URL_SPECIAL_CHARS) 60 url.query(), net::UnescapeRule::URL_SPECIAL_CHARS)
66 .find(kChromiumSyncService) != std::string::npos; 61 .find(kChromiumSyncService) != std::string::npos;
67 } 62 }
68 63
69 SigninManager::SigninManager(SigninClient* client) 64 SigninManager::SigninManager(SigninClient* client)
70 : SigninManagerBase(client), 65 : SigninManagerBase(client),
71 profile_(NULL), 66 profile_(NULL),
72 prohibit_signout_(false), 67 prohibit_signout_(false),
73 type_(SIGNIN_TYPE_NONE), 68 type_(SIGNIN_TYPE_NONE),
74 weak_pointer_factory_(this), 69 weak_pointer_factory_(this),
75 signin_host_id_(ChildProcessHost::kInvalidUniqueID),
76 client_(client) {} 70 client_(client) {}
77 71
78 void SigninManager::SetSigninProcess(int process_id) {
79 if (process_id == signin_host_id_)
80 return;
81 DLOG_IF(WARNING,
82 signin_host_id_ != ChildProcessHost::kInvalidUniqueID)
83 << "Replacing in-use signin process.";
84 signin_host_id_ = process_id;
85 RenderProcessHost* host = RenderProcessHost::FromID(process_id);
86 DCHECK(host);
87 host->AddObserver(this);
88 signin_hosts_observed_.insert(host);
89 }
90
91 void SigninManager::ClearSigninProcess() {
92 signin_host_id_ = ChildProcessHost::kInvalidUniqueID;
93 }
94
95 bool SigninManager::IsSigninProcess(int process_id) const {
96 return process_id == signin_host_id_;
97 }
98
99 bool SigninManager::HasSigninProcess() const {
100 return signin_host_id_ != ChildProcessHost::kInvalidUniqueID;
101 }
102
103 void SigninManager::AddMergeSessionObserver( 72 void SigninManager::AddMergeSessionObserver(
104 MergeSessionHelper::Observer* observer) { 73 MergeSessionHelper::Observer* observer) {
105 if (merge_session_helper_) 74 if (merge_session_helper_)
106 merge_session_helper_->AddObserver(observer); 75 merge_session_helper_->AddObserver(observer);
107 } 76 }
108 77
109 void SigninManager::RemoveMergeSessionObserver( 78 void SigninManager::RemoveMergeSessionObserver(
110 MergeSessionHelper::Observer* observer) { 79 MergeSessionHelper::Observer* observer) {
111 if (merge_session_helper_) 80 if (merge_session_helper_)
112 merge_session_helper_->RemoveObserver(observer); 81 merge_session_helper_->RemoveObserver(observer);
113 } 82 }
114 83
115 SigninManager::~SigninManager() { 84 SigninManager::~SigninManager() {
116 std::set<RenderProcessHost*>::iterator i;
117 for (i = signin_hosts_observed_.begin();
118 i != signin_hosts_observed_.end();
119 ++i) {
120 (*i)->RemoveObserver(this);
121 }
122 } 85 }
123 86
124 void SigninManager::InitTokenService() { 87 void SigninManager::InitTokenService() {
125 ProfileOAuth2TokenService* token_service = 88 ProfileOAuth2TokenService* token_service =
126 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 89 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
127 const std::string& account_id = GetAuthenticatedUsername(); 90 const std::string& account_id = GetAuthenticatedUsername();
128 if (token_service && !account_id.empty()) 91 if (token_service && !account_id.empty())
129 token_service->LoadCredentials(account_id); 92 token_service->LoadCredentials(account_id);
130 } 93 }
131 94
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 FOR_EACH_OBSERVER(Observer, observer_list_, 401 FOR_EACH_OBSERVER(Observer, observer_list_,
439 GoogleSigninSucceeded(GetAuthenticatedUsername(), 402 GoogleSigninSucceeded(GetAuthenticatedUsername(),
440 password_)); 403 password_));
441 404
442 client_->GoogleSigninSucceeded(GetAuthenticatedUsername(), password_); 405 client_->GoogleSigninSucceeded(GetAuthenticatedUsername(), password_);
443 406
444 password_.clear(); // Don't need it anymore. 407 password_.clear(); // Don't need it anymore.
445 DisableOneClickSignIn(profile_); // Don't ever offer again. 408 DisableOneClickSignIn(profile_); // Don't ever offer again.
446 } 409 }
447 410
448 void SigninManager::RenderProcessHostDestroyed(RenderProcessHost* host) {
449 // It's possible we're listening to a "stale" renderer because it was replaced
450 // with a new process by process-per-site. In either case, stop observing it,
451 // but only reset signin_host_id_ tracking if this was from the current signin
452 // process.
453 signin_hosts_observed_.erase(host);
454 if (signin_host_id_ == host->GetID())
455 signin_host_id_ = ChildProcessHost::kInvalidUniqueID;
456 }
457
458 void SigninManager::ProhibitSignout(bool prohibit_signout) { 411 void SigninManager::ProhibitSignout(bool prohibit_signout) {
459 prohibit_signout_ = prohibit_signout; 412 prohibit_signout_ = prohibit_signout;
460 } 413 }
461 414
462 bool SigninManager::IsSignoutProhibited() const { 415 bool SigninManager::IsSignoutProhibited() const {
463 return prohibit_signout_; 416 return prohibit_signout_;
464 } 417 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager.h ('k') | chrome/browser/ui/sync/one_click_signin_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698