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

Side by Side Diff: services/authenticating_url_loader/authenticating_url_loader_factory_impl.cc

Issue 1163483004: Make the authentication service remember selected usernames. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 5 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/authenticating_url_loader/authenticating_url_loader_factory_i mpl.h" 5 #include "services/authenticating_url_loader/authenticating_url_loader_factory_i mpl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // Clear the cached token in case the request is due to that token being 46 // Clear the cached token in case the request is due to that token being
47 // stale. 47 // stale.
48 authentication_service_->ClearOAuth2Token((*cached_tokens_)[origin]); 48 authentication_service_->ClearOAuth2Token((*cached_tokens_)[origin]);
49 cached_tokens_->erase(origin); 49 cached_tokens_->erase(origin);
50 } 50 }
51 if (cached_accounts_.find(origin) != cached_accounts_.end()) { 51 if (cached_accounts_.find(origin) != cached_accounts_.end()) {
52 OnAccountSelected(origin, cached_accounts_[origin], mojo::String()); 52 OnAccountSelected(origin, cached_accounts_[origin], mojo::String());
53 return; 53 return;
54 } 54 }
55 authentication_service_->SelectAccount( 55 authentication_service_->SelectAccount(
56 base::Bind(&AuthenticatingURLLoaderFactoryImpl::OnAccountSelected, 56 true, base::Bind(&AuthenticatingURLLoaderFactoryImpl::OnAccountSelected,
57 base::Unretained(this), origin)); 57 base::Unretained(this), origin));
58 } 58 }
59 pendings_retrieve_token_[origin].push_back(callback); 59 pendings_retrieve_token_[origin].push_back(callback);
60 } 60 }
61 61
62 void AuthenticatingURLLoaderFactoryImpl::OnURLLoaderError( 62 void AuthenticatingURLLoaderFactoryImpl::OnURLLoaderError(
63 AuthenticatingURLLoaderImpl* url_loader) { 63 AuthenticatingURLLoaderImpl* url_loader) {
64 auto it = std::find_if( 64 auto it = std::find_if(
65 url_loaders_.begin(), url_loaders_.end(), 65 url_loaders_.begin(), url_loaders_.end(),
66 [url_loader](const std::unique_ptr<AuthenticatingURLLoaderImpl>& p) { 66 [url_loader](const std::unique_ptr<AuthenticatingURLLoaderImpl>& p) {
67 return p.get() == url_loader; 67 return p.get() == url_loader;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void AuthenticatingURLLoaderFactoryImpl::ExecuteCallbacks( 129 void AuthenticatingURLLoaderFactoryImpl::ExecuteCallbacks(
130 const GURL& origin, 130 const GURL& origin,
131 const std::string& result) { 131 const std::string& result) {
132 for (auto& callback : pendings_retrieve_token_[origin]) { 132 for (auto& callback : pendings_retrieve_token_[origin]) {
133 callback.Run(result); 133 callback.Run(result);
134 } 134 }
135 pendings_retrieve_token_.erase(origin); 135 pendings_retrieve_token_.erase(origin);
136 } 136 }
137 137
138 } // namespace mojo 138 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/authentication/public/interfaces/authentication.mojom ('k') | services/authentication/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698