| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_SIGNIN_CORE_BROWSER_GAIA_COOKIE_MANAGER_SERVICE_H | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_GAIA_COOKIE_MANAGER_SERVICE_H |
| 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_GAIA_COOKIE_MANAGER_SERVICE_H | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_GAIA_COOKIE_MANAGER_SERVICE_H |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 class Observer { | 81 class Observer { |
| 82 public: | 82 public: |
| 83 // Called whenever a merge session is completed. The account that was | 83 // Called whenever a merge session is completed. The account that was |
| 84 // merged is given by |account_id|. If |error| is equal to | 84 // merged is given by |account_id|. If |error| is equal to |
| 85 // GoogleServiceAuthError::AuthErrorNone() then the merge succeeeded. | 85 // GoogleServiceAuthError::AuthErrorNone() then the merge succeeeded. |
| 86 virtual void OnAddAccountToCookieCompleted( | 86 virtual void OnAddAccountToCookieCompleted( |
| 87 const std::string& account_id, | 87 const std::string& account_id, |
| 88 const GoogleServiceAuthError& error) = 0; | 88 const GoogleServiceAuthError& error) = 0; |
| 89 | 89 |
| 90 // Called when ExternalCcResultFetcher completes. From this moment | |
| 91 // forward calls to AddAccountToCookie() will use the result in merge | |
| 92 // session calls. If |succeeded| is false, not all connections were checked, | |
| 93 // but some may have been. AddAccountToCookie() will proceed with whatever | |
| 94 // partial results were retrieved. | |
| 95 virtual void GetCheckConnectionInfoCompleted(bool succeeded) {} | |
| 96 | |
| 97 protected: | 90 protected: |
| 98 virtual ~Observer() {} | 91 virtual ~Observer() {} |
| 99 }; | 92 }; |
| 100 | 93 |
| 101 // Class to retrieve the external connection check results from gaia. | 94 // Class to retrieve the external connection check results from gaia. |
| 102 // Declared publicly for unit tests. | 95 // Declared publicly for unit tests. |
| 103 class ExternalCcResultFetcher : public GaiaAuthConsumer, | 96 class ExternalCcResultFetcher : public GaiaAuthConsumer, |
| 104 public net::URLFetcherDelegate { | 97 public net::URLFetcherDelegate { |
| 105 public: | 98 public: |
| 106 // Maps connection URLs, as returned by StartGetCheckConnectionInfo() to | 99 // Maps connection URLs, as returned by StartGetCheckConnectionInfo() to |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 173 |
| 181 // Call observers when merge session completes. This public so that callers | 174 // Call observers when merge session completes. This public so that callers |
| 182 // that know that a given account is already in the cookie jar can simply | 175 // that know that a given account is already in the cookie jar can simply |
| 183 // inform the observers. | 176 // inform the observers. |
| 184 void SignalComplete(const std::string& account_id, | 177 void SignalComplete(const std::string& account_id, |
| 185 const GoogleServiceAuthError& error); | 178 const GoogleServiceAuthError& error); |
| 186 | 179 |
| 187 // Returns true of there are pending log ins or outs. | 180 // Returns true of there are pending log ins or outs. |
| 188 bool is_running() const { return requests_.size() > 0; } | 181 bool is_running() const { return requests_.size() > 0; } |
| 189 | 182 |
| 190 // Start the process of fetching the external check connection result so that | 183 // Access the internal object during tests. |
| 191 // its ready when we try to perform a merge session. | 184 ExternalCcResultFetcher* external_cc_result_fetcher_for_testing() { |
| 192 void StartFetchingExternalCcResult(); | 185 return &external_cc_result_fetcher_; |
| 186 } |
| 193 | 187 |
| 194 private: | 188 private: |
| 195 net::URLRequestContextGetter* request_context() { | 189 net::URLRequestContextGetter* request_context() { |
| 196 return signin_client_->GetURLRequestContext(); | 190 return signin_client_->GetURLRequestContext(); |
| 197 } | 191 } |
| 198 | 192 |
| 199 // Overridden from UbertokenConsumer. | 193 // Overridden from UbertokenConsumer. |
| 200 void OnUbertokenSuccess(const std::string& token) override; | 194 void OnUbertokenSuccess(const std::string& token) override; |
| 201 void OnUbertokenFailure(const GoogleServiceAuthError& error) override; | 195 void OnUbertokenFailure(const GoogleServiceAuthError& error) override; |
| 202 | 196 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // executed at a time. | 233 // executed at a time. |
| 240 std::deque<GaiaCookieRequest> requests_; | 234 std::deque<GaiaCookieRequest> requests_; |
| 241 | 235 |
| 242 // List of observers to notify when merge session completes. | 236 // List of observers to notify when merge session completes. |
| 243 // Makes sure list is empty on destruction. | 237 // Makes sure list is empty on destruction. |
| 244 ObserverList<Observer, true> observer_list_; | 238 ObserverList<Observer, true> observer_list_; |
| 245 | 239 |
| 246 // Source to use with GAIA endpoints for accounting. | 240 // Source to use with GAIA endpoints for accounting. |
| 247 std::string source_; | 241 std::string source_; |
| 248 | 242 |
| 243 // True once the ExternalCCResultFetcher has completed once. |
| 244 bool external_cc_result_fetched_; |
| 245 |
| 249 DISALLOW_COPY_AND_ASSIGN(GaiaCookieManagerService); | 246 DISALLOW_COPY_AND_ASSIGN(GaiaCookieManagerService); |
| 250 }; | 247 }; |
| 251 | 248 |
| 252 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_GAIA_COOKIE_MANAGER_SERVICE_H | 249 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_GAIA_COOKIE_MANAGER_SERVICE_H |
| OLD | NEW |