| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_window.h" | 11 #include "chrome/browser/profiles/profile_window.h" |
| 12 #include "chrome/browser/ui/host_desktop.h" | 12 #include "chrome/browser/ui/host_desktop.h" |
| 13 #include "chrome/browser/ui/webui/options/options_ui.h" | 13 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 14 #include "google_apis/gaia/google_service_auth_error.h" | 14 #include "google_apis/gaia/google_service_auth_error.h" |
| 15 | 15 |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class DictionaryValue; | 18 class DictionaryValue; |
| 19 class ListValue; | 19 class ListValue; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace user_manager { |
| 23 class UserID; |
| 24 } |
| 25 |
| 22 #if defined(ENABLE_SUPERVISED_USERS) | 26 #if defined(ENABLE_SUPERVISED_USERS) |
| 23 class SupervisedUserRegistrationUtility; | 27 class SupervisedUserRegistrationUtility; |
| 24 #endif | 28 #endif |
| 25 | 29 |
| 26 namespace options { | 30 namespace options { |
| 27 | 31 |
| 28 // Handler for the 'create profile' overlay. | 32 // Handler for the 'create profile' overlay. |
| 29 class CreateProfileHandler: public OptionsPageUIHandler { | 33 class CreateProfileHandler: public OptionsPageUIHandler { |
| 30 public: | 34 public: |
| 31 CreateProfileHandler(); | 35 CreateProfileHandler(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // 4: a string representing the supervised user ID. | 72 // 4: a string representing the supervised user ID. |
| 69 void CreateProfile(const base::ListValue* args); | 73 void CreateProfile(const base::ListValue* args); |
| 70 | 74 |
| 71 // If a local error occurs during profile creation, then show an appropriate | 75 // If a local error occurs during profile creation, then show an appropriate |
| 72 // error message. However, if profile creation succeeded and the | 76 // error message. However, if profile creation succeeded and the |
| 73 // profile being created/imported is a supervised user profile, | 77 // profile being created/imported is a supervised user profile, |
| 74 // then proceed with the registration step. Otherwise, update the UI | 78 // then proceed with the registration step. Otherwise, update the UI |
| 75 // as the final task after a new profile has been created. | 79 // as the final task after a new profile has been created. |
| 76 void OnProfileCreated(bool create_shortcut, | 80 void OnProfileCreated(bool create_shortcut, |
| 77 chrome::HostDesktopType desktop_type, | 81 chrome::HostDesktopType desktop_type, |
| 78 const std::string& supervised_user_id, | 82 const user_manager::UserID& supervised_user_id, |
| 79 Profile* profile, | 83 Profile* profile, |
| 80 Profile::CreateStatus status); | 84 Profile::CreateStatus status); |
| 81 | 85 |
| 82 void HandleProfileCreationSuccess(bool create_shortcut, | 86 void HandleProfileCreationSuccess(bool create_shortcut, |
| 83 chrome::HostDesktopType desktop_type, | 87 chrome::HostDesktopType desktop_type, |
| 84 const std::string& supervised_user_id, | 88 const user_manager::UserID& supervised_user_
id, |
| 85 Profile* profile); | 89 Profile* profile); |
| 86 | 90 |
| 87 // Creates desktop shortcut and updates the UI to indicate success | 91 // Creates desktop shortcut and updates the UI to indicate success |
| 88 // when creating a profile. | 92 // when creating a profile. |
| 89 void CreateShortcutAndShowSuccess(bool create_shortcut, | 93 void CreateShortcutAndShowSuccess(bool create_shortcut, |
| 90 chrome::HostDesktopType desktop_type, | 94 chrome::HostDesktopType desktop_type, |
| 91 Profile* profile); | 95 Profile* profile); |
| 92 | 96 |
| 93 // Updates the UI to show an error when creating a profile. | 97 // Updates the UI to show an error when creating a profile. |
| 94 void ShowProfileCreationError(Profile* profile, const base::string16& error); | 98 void ShowProfileCreationError(Profile* profile, const base::string16& error); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 118 | 122 |
| 119 // Indicates the type of the in progress profile creation operation. | 123 // Indicates the type of the in progress profile creation operation. |
| 120 // The value is only relevant while we are creating/importing a profile. | 124 // The value is only relevant while we are creating/importing a profile. |
| 121 ProfileCreationOperationType profile_creation_type_; | 125 ProfileCreationOperationType profile_creation_type_; |
| 122 | 126 |
| 123 #if defined(ENABLE_SUPERVISED_USERS) | 127 #if defined(ENABLE_SUPERVISED_USERS) |
| 124 // Extracts the supervised user ID from the args passed into CreateProfile, | 128 // Extracts the supervised user ID from the args passed into CreateProfile, |
| 125 // sets |profile_creation_type_| if necessary, and returns true if the | 129 // sets |profile_creation_type_| if necessary, and returns true if the |
| 126 // supervised user id specified in |args| are valid. | 130 // supervised user id specified in |args| are valid. |
| 127 bool ProcessSupervisedCreateProfileArgs(const base::ListValue* args, | 131 bool ProcessSupervisedCreateProfileArgs(const base::ListValue* args, |
| 128 std::string* supervised_user_id); | 132 user_manager::UserID* supervised_user_
id); |
| 129 | 133 |
| 130 // Cancels creation of a supervised-user profile currently in progress, as | 134 // Cancels creation of a supervised-user profile currently in progress, as |
| 131 // indicated by profile_path_being_created_, removing the object and files | 135 // indicated by profile_path_being_created_, removing the object and files |
| 132 // and canceling supervised-user registration. This is the handler for the | 136 // and canceling supervised-user registration. This is the handler for the |
| 133 // "cancelCreateProfile" message. |args| is not used. | 137 // "cancelCreateProfile" message. |args| is not used. |
| 134 void HandleCancelProfileCreation(const base::ListValue* args); | 138 void HandleCancelProfileCreation(const base::ListValue* args); |
| 135 | 139 |
| 136 // Internal implementation. This may safely be called whether profile creation | 140 // Internal implementation. This may safely be called whether profile creation |
| 137 // or registration is in progress or not. |user_initiated| should be true if | 141 // or registration is in progress or not. |user_initiated| should be true if |
| 138 // the cancellation was deliberately requested by the user, and false if it | 142 // the cancellation was deliberately requested by the user, and false if it |
| 139 // was caused implicitly, e.g. by shutting down the browser. | 143 // was caused implicitly, e.g. by shutting down the browser. |
| 140 void CancelProfileRegistration(bool user_initiated); | 144 void CancelProfileRegistration(bool user_initiated); |
| 141 | 145 |
| 142 // After a new supervised-user profile has been created, registers the user | 146 // After a new supervised-user profile has been created, registers the user |
| 143 // with the management server. | 147 // with the management server. |
| 144 void RegisterSupervisedUser(bool create_shortcut, | 148 void RegisterSupervisedUser(bool create_shortcut, |
| 145 chrome::HostDesktopType desktop_type, | 149 chrome::HostDesktopType desktop_type, |
| 146 const std::string& managed_user_id, | 150 const user_manager::UserID& managed_user_id, |
| 147 Profile* new_profile); | 151 Profile* new_profile); |
| 148 | 152 |
| 149 // Called back with the result of the supervised user registration. | 153 // Called back with the result of the supervised user registration. |
| 150 void OnSupervisedUserRegistered(bool create_shortcut, | 154 void OnSupervisedUserRegistered(bool create_shortcut, |
| 151 chrome::HostDesktopType desktop_type, | 155 chrome::HostDesktopType desktop_type, |
| 152 Profile* profile, | 156 Profile* profile, |
| 153 const GoogleServiceAuthError& error); | 157 const GoogleServiceAuthError& error); |
| 154 | 158 |
| 155 // Records UMA histograms relevant to supervised user profiles | 159 // Records UMA histograms relevant to supervised user profiles |
| 156 // creation and registration. | 160 // creation and registration. |
| 157 void RecordSupervisedProfileCreationMetrics( | 161 void RecordSupervisedProfileCreationMetrics( |
| 158 GoogleServiceAuthError::State error_state); | 162 GoogleServiceAuthError::State error_state); |
| 159 | 163 |
| 160 bool IsValidExistingSupervisedUserId( | 164 bool IsValidExistingSupervisedUserId( |
| 161 const std::string& existing_supervised_user_id) const; | 165 const user_manager::UserID& existing_supervised_user_id) const; |
| 162 | 166 |
| 163 scoped_ptr<SupervisedUserRegistrationUtility> | 167 scoped_ptr<SupervisedUserRegistrationUtility> |
| 164 supervised_user_registration_utility_; | 168 supervised_user_registration_utility_; |
| 165 #endif | 169 #endif |
| 166 | 170 |
| 167 base::WeakPtrFactory<CreateProfileHandler> weak_ptr_factory_; | 171 base::WeakPtrFactory<CreateProfileHandler> weak_ptr_factory_; |
| 168 | 172 |
| 169 DISALLOW_COPY_AND_ASSIGN(CreateProfileHandler); | 173 DISALLOW_COPY_AND_ASSIGN(CreateProfileHandler); |
| 170 }; | 174 }; |
| 171 | 175 |
| 172 } // namespace options | 176 } // namespace options |
| 173 | 177 |
| 174 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ | 178 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CREATE_PROFILE_HANDLER_H_ |
| OLD | NEW |