| 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 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h" | 5 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 class SupervisedUserRegistrationUtilityImpl | 42 class SupervisedUserRegistrationUtilityImpl |
| 43 : public SupervisedUserRegistrationUtility, | 43 : public SupervisedUserRegistrationUtility, |
| 44 public SupervisedUserSyncServiceObserver { | 44 public SupervisedUserSyncServiceObserver { |
| 45 public: | 45 public: |
| 46 SupervisedUserRegistrationUtilityImpl( | 46 SupervisedUserRegistrationUtilityImpl( |
| 47 PrefService* prefs, | 47 PrefService* prefs, |
| 48 scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher, | 48 scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher, |
| 49 SupervisedUserSyncService* service, | 49 SupervisedUserSyncService* service, |
| 50 SupervisedUserSharedSettingsService* shared_settings_service); | 50 SupervisedUserSharedSettingsService* shared_settings_service); |
| 51 | 51 |
| 52 virtual ~SupervisedUserRegistrationUtilityImpl(); | 52 ~SupervisedUserRegistrationUtilityImpl() override; |
| 53 | 53 |
| 54 // Registers a new supervised user with the server. |supervised_user_id| is a | 54 // Registers a new supervised user with the server. |supervised_user_id| is a |
| 55 // new unique ID for the new supervised user. If its value is the same as that | 55 // new unique ID for the new supervised user. If its value is the same as that |
| 56 // of one of the existing supervised users, then the same user will be created | 56 // of one of the existing supervised users, then the same user will be created |
| 57 // on this machine (and if he has no avatar in sync, his avatar will be | 57 // on this machine (and if he has no avatar in sync, his avatar will be |
| 58 // updated). |info| contains necessary information like the display name of | 58 // updated). |info| contains necessary information like the display name of |
| 59 // the user and his avatar. |callback| is called with the result of the | 59 // the user and his avatar. |callback| is called with the result of the |
| 60 // registration. We use the info here and not the profile, because on Chrome | 60 // registration. We use the info here and not the profile, because on Chrome |
| 61 // OS the profile of the supervised user does not yet exist. | 61 // OS the profile of the supervised user does not yet exist. |
| 62 virtual void Register(const std::string& supervised_user_id, | 62 void Register(const std::string& supervised_user_id, |
| 63 const SupervisedUserRegistrationInfo& info, | 63 const SupervisedUserRegistrationInfo& info, |
| 64 const RegistrationCallback& callback) override; | 64 const RegistrationCallback& callback) override; |
| 65 | 65 |
| 66 // SupervisedUserSyncServiceObserver: | 66 // SupervisedUserSyncServiceObserver: |
| 67 virtual void OnSupervisedUserAcknowledged( | 67 void OnSupervisedUserAcknowledged( |
| 68 const std::string& supervised_user_id) override; | 68 const std::string& supervised_user_id) override; |
| 69 virtual void OnSupervisedUsersSyncingStopped() override; | 69 void OnSupervisedUsersSyncingStopped() override; |
| 70 virtual void OnSupervisedUsersChanged() override; | 70 void OnSupervisedUsersChanged() override; |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 // Fetches the supervised user token when we have the device name. | 73 // Fetches the supervised user token when we have the device name. |
| 74 void FetchToken(const std::string& client_name); | 74 void FetchToken(const std::string& client_name); |
| 75 | 75 |
| 76 // Called when we have received a token for the supervised user. | 76 // Called when we have received a token for the supervised user. |
| 77 void OnReceivedToken(const GoogleServiceAuthError& error, | 77 void OnReceivedToken(const GoogleServiceAuthError& error, |
| 78 const std::string& token); | 78 const std::string& token); |
| 79 | 79 |
| 80 // Dispatches the callback and cleans up if all the conditions have been met. | 80 // Dispatches the callback and cleans up if all the conditions have been met. |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 pending_supervised_user_id_); | 408 pending_supervised_user_id_); |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 | 411 |
| 412 if (run_callback) | 412 if (run_callback) |
| 413 callback_.Run(error, pending_supervised_user_token_); | 413 callback_.Run(error, pending_supervised_user_token_); |
| 414 callback_.Reset(); | 414 callback_.Reset(); |
| 415 } | 415 } |
| 416 | 416 |
| 417 } // namespace | 417 } // namespace |
| OLD | NEW |