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

Side by Side Diff: google_apis/gaia/fake_gaia.h

Issue 473153002: Inline sign in extracts gaia id from HTTP header and seeds account tracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 1 month 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef GOOGLE_APIS_GAIA_FAKE_GAIA_H_ 5 #ifndef GOOGLE_APIS_GAIA_FAKE_GAIA_H_
6 #define GOOGLE_APIS_GAIA_FAKE_GAIA_H_ 6 #define GOOGLE_APIS_GAIA_FAKE_GAIA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 FakeGaia(); 79 FakeGaia();
80 virtual ~FakeGaia(); 80 virtual ~FakeGaia();
81 81
82 void SetFakeMergeSessionParams(const std::string& email, 82 void SetFakeMergeSessionParams(const std::string& email,
83 const std::string& auth_sid_cookie, 83 const std::string& auth_sid_cookie,
84 const std::string& auth_lsid_cookie); 84 const std::string& auth_lsid_cookie);
85 85
86 // Sets the initial value of tokens and cookies. 86 // Sets the initial value of tokens and cookies.
87 void SetMergeSessionParams(const MergeSessionParams& params); 87 void SetMergeSessionParams(const MergeSessionParams& params);
88 88
89 // Sets the specified |gaia_id| as corresponding to the given |email|
90 // address when setting GAIA response headers. If no mapping is given for
91 // an email address, a default GAIA Id is used.
92 void MapEmailToGaiaId(const std::string& email, const std::string& gaia_id);
93
89 // Initializes HTTP request handlers. Should be called after switches 94 // Initializes HTTP request handlers. Should be called after switches
90 // for tweaking GaiaUrls are in place. 95 // for tweaking GaiaUrls are in place.
91 void Initialize(); 96 void Initialize();
92 97
93 // Handles a request and returns a response if the request was recognized as a 98 // Handles a request and returns a response if the request was recognized as a
94 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so 99 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so
95 // that this can used with EmbeddedTestServer::RegisterRequestHandler(). 100 // that this can used with EmbeddedTestServer::RegisterRequestHandler().
96 scoped_ptr<net::test_server::HttpResponse> HandleRequest( 101 scoped_ptr<net::test_server::HttpResponse> HandleRequest(
97 const net::test_server::HttpRequest& request); 102 const net::test_server::HttpRequest& request);
98 103
(...skipping 15 matching lines...) Expand all
114 const std::string& key, 119 const std::string& key,
115 std::string* value); 120 std::string* value);
116 protected: 121 protected:
117 // HTTP handler for /MergeSession. 122 // HTTP handler for /MergeSession.
118 virtual void HandleMergeSession( 123 virtual void HandleMergeSession(
119 const net::test_server::HttpRequest& request, 124 const net::test_server::HttpRequest& request,
120 net::test_server::BasicHttpResponse* http_response); 125 net::test_server::BasicHttpResponse* http_response);
121 126
122 private: 127 private:
123 typedef std::multimap<std::string, AccessTokenInfo> AccessTokenInfoMap; 128 typedef std::multimap<std::string, AccessTokenInfo> AccessTokenInfoMap;
129 typedef std::map<std::string, std::string> EmailToGaiaIdMap;
124 typedef std::map<std::string, GURL> SamlAccountIdpMap; 130 typedef std::map<std::string, GURL> SamlAccountIdpMap;
125 131
132 std::string GetGaiaIdOfEmail(const std::string& email) const;
133
134 void AddGoogleAccountsSigninHeader(
135 net::test_server::BasicHttpResponse* http_response,
136 const std::string& email) const;
137
126 // Formats a JSON response with the data in |response_dict|. 138 // Formats a JSON response with the data in |response_dict|.
127 void FormatJSONResponse(const base::DictionaryValue& response_dict, 139 void FormatJSONResponse(const base::DictionaryValue& response_dict,
128 net::test_server::BasicHttpResponse* http_response); 140 net::test_server::BasicHttpResponse* http_response);
129 141
130 typedef base::Callback<void( 142 typedef base::Callback<void(
131 const net::test_server::HttpRequest& request, 143 const net::test_server::HttpRequest& request,
132 net::test_server::BasicHttpResponse* http_response)> 144 net::test_server::BasicHttpResponse* http_response)>
133 HttpRequestHandlerCallback; 145 HttpRequestHandlerCallback;
134 typedef std::map<std::string, HttpRequestHandlerCallback> RequestHandlerMap; 146 typedef std::map<std::string, HttpRequestHandlerCallback> RequestHandlerMap;
135 147
(...skipping 26 matching lines...) Expand all
162 // Returns the access token associated with |auth_token| that matches the 174 // Returns the access token associated with |auth_token| that matches the
163 // given |client_id| and |scope_string|. If |scope_string| is empty, the first 175 // given |client_id| and |scope_string|. If |scope_string| is empty, the first
164 // token satisfying the other criteria is returned. Returns NULL if no token 176 // token satisfying the other criteria is returned. Returns NULL if no token
165 // matches. 177 // matches.
166 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, 178 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token,
167 const std::string& client_id, 179 const std::string& client_id,
168 const std::string& scope_string) 180 const std::string& scope_string)
169 const; 181 const;
170 182
171 MergeSessionParams merge_session_params_; 183 MergeSessionParams merge_session_params_;
184 EmailToGaiaIdMap email_to_gaia_id_map_;
172 AccessTokenInfoMap access_token_info_map_; 185 AccessTokenInfoMap access_token_info_map_;
173 RequestHandlerMap request_handlers_; 186 RequestHandlerMap request_handlers_;
174 std::string service_login_response_; 187 std::string service_login_response_;
175 SamlAccountIdpMap saml_account_idp_map_; 188 SamlAccountIdpMap saml_account_idp_map_;
176 189
177 DISALLOW_COPY_AND_ASSIGN(FakeGaia); 190 DISALLOW_COPY_AND_ASSIGN(FakeGaia);
178 }; 191 };
179 192
180 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_ 193 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698