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_MANAGED_USER_IMPORT_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_SUPERVISED_USER_IMPORT_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_SUPERVISED_USER_IMPORT_HANDLER_H_ |
7 | 7 |
8 #include "base/callback_list.h" | 8 #include "base/callback_list.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
11 #include "chrome/browser/supervised_user/supervised_user_sync_service_observer.h
" | 11 #include "chrome/browser/supervised_user/supervised_user_sync_service_observer.h
" |
12 #include "chrome/browser/ui/webui/options/options_ui.h" | 12 #include "chrome/browser/ui/webui/options/options_ui.h" |
13 #include "components/signin/core/browser/signin_error_controller.h" | 13 #include "components/signin/core/browser/signin_error_controller.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class DictionaryValue; | 16 class DictionaryValue; |
17 class ListValue; | 17 class ListValue; |
18 } | 18 } |
19 | 19 |
20 namespace options { | 20 namespace options { |
21 | 21 |
22 // Handler for the 'import existing managed user' dialog. | 22 // Handler for the 'import existing supervised user' dialog. |
23 class ManagedUserImportHandler : public OptionsPageUIHandler, | 23 class SupervisedUserImportHandler : public OptionsPageUIHandler, |
24 public SupervisedUserSyncServiceObserver, | 24 public SupervisedUserSyncServiceObserver, |
25 public SigninErrorController::Observer { | 25 public SigninErrorController::Observer { |
26 public: | 26 public: |
27 typedef base::CallbackList<void(const std::string&, const std::string&)> | 27 typedef base::CallbackList<void(const std::string&, const std::string&)> |
28 CallbackList; | 28 CallbackList; |
29 | 29 |
30 ManagedUserImportHandler(); | 30 SupervisedUserImportHandler(); |
31 virtual ~ManagedUserImportHandler(); | 31 virtual ~SupervisedUserImportHandler(); |
32 | 32 |
33 // OptionsPageUIHandler implementation. | 33 // OptionsPageUIHandler implementation. |
34 virtual void GetLocalizedValues( | 34 virtual void GetLocalizedValues( |
35 base::DictionaryValue* localized_strings) OVERRIDE; | 35 base::DictionaryValue* localized_strings) OVERRIDE; |
36 virtual void InitializeHandler() OVERRIDE; | 36 virtual void InitializeHandler() OVERRIDE; |
37 | 37 |
38 // WebUIMessageHandler implementation. | 38 // WebUIMessageHandler implementation. |
39 virtual void RegisterMessages() OVERRIDE; | 39 virtual void RegisterMessages() OVERRIDE; |
40 | 40 |
41 // SupervisedUserSyncServiceObserver implementation. | 41 // SupervisedUserSyncServiceObserver implementation. |
42 virtual void OnSupervisedUserAcknowledged( | 42 virtual void OnSupervisedUserAcknowledged( |
43 const std::string& supervised_user_id) OVERRIDE {} | 43 const std::string& supervised_user_id) OVERRIDE {} |
44 virtual void OnSupervisedUsersSyncingStopped() OVERRIDE {} | 44 virtual void OnSupervisedUsersSyncingStopped() OVERRIDE {} |
45 virtual void OnSupervisedUsersChanged() OVERRIDE; | 45 virtual void OnSupervisedUsersChanged() OVERRIDE; |
46 | 46 |
47 // SigninErrorController::Observer implementation. | 47 // SigninErrorController::Observer implementation. |
48 virtual void OnErrorChanged() OVERRIDE; | 48 virtual void OnErrorChanged() OVERRIDE; |
49 | 49 |
50 private: | 50 private: |
51 // Clears the cached list of managed users and fetches the new list of managed | 51 // Clears the cached list of supervised users and fetches the new list of |
52 // users. | 52 // supervised users. |
53 void FetchManagedUsers(); | 53 void FetchSupervisedUsers(); |
54 | 54 |
55 // Callback for the "requestManagedUserImportUpdate" message. | 55 // Callback for the "requestManagedUserImportUpdate" message. |
56 // Checks the sign-in status of the custodian and accordingly | 56 // Checks the sign-in status of the custodian and accordingly |
57 // sends an update to the WebUI. The update can be to show/hide | 57 // sends an update to the WebUI. The update can be to show/hide |
58 // an error bubble and update/clear the managed user list. | 58 // an error bubble and update/clear the supervised user list. |
59 void RequestManagedUserImportUpdate(const base::ListValue* args); | 59 void RequestSupervisedUserImportUpdate(const base::ListValue* args); |
60 | 60 |
61 // Sends an array of managed users to WebUI. Each entry is of the form: | 61 // Sends an array of supervised users to WebUI. Each entry is of the form: |
62 // managedProfile = { | 62 // supervisedProfile = { |
63 // id: "Managed User ID", | 63 // id: "Supervised User ID", |
64 // name: "Managed User Name", | 64 // name: "Supervised User Name", |
65 // iconURL: "chrome://path/to/icon/image", | 65 // iconURL: "chrome://path/to/icon/image", |
66 // onCurrentDevice: true or false, | 66 // onCurrentDevice: true or false, |
67 // needAvatar: true or false | 67 // needAvatar: true or false |
68 // } | 68 // } |
69 // The array holds all existing managed users attached to the | 69 // The array holds all existing supervised users attached to the |
70 // custodian's profile which initiated the request. | 70 // custodian's profile which initiated the request. |
71 void SendExistingManagedUsers(const base::DictionaryValue* dict); | 71 void SendExistingSupervisedUsers(const base::DictionaryValue* dict); |
72 | 72 |
73 // Sends messages to the JS side to clear managed users and show an error | 73 // Sends messages to the JS side to clear supervised users and show an error |
74 // bubble. | 74 // bubble. |
75 void ClearManagedUsersAndShowError(); | 75 void ClearSupervisedUsersAndShowError(); |
76 | 76 |
77 bool IsAccountConnected() const; | 77 bool IsAccountConnected() const; |
78 bool HasAuthError() const; | 78 bool HasAuthError() const; |
79 | 79 |
80 // Called when a managed user shared setting is changed. If the avatar was | 80 // Called when a supervised user shared setting is changed. If the avatar was |
81 // changed, FetchManagedUsers() is called. | 81 // changed, FetchSupervisedUsers() is called. |
82 void OnSharedSettingChanged(const std::string& managed_user_id, | 82 void OnSharedSettingChanged(const std::string& supervised_user_id, |
83 const std::string& key); | 83 const std::string& key); |
84 | 84 |
85 scoped_ptr<CallbackList::Subscription> subscription_; | 85 scoped_ptr<CallbackList::Subscription> subscription_; |
86 | 86 |
87 ScopedObserver<SigninErrorController, ManagedUserImportHandler> observer_; | 87 ScopedObserver<SigninErrorController, SupervisedUserImportHandler> observer_; |
88 | 88 |
89 base::WeakPtrFactory<ManagedUserImportHandler> weak_ptr_factory_; | 89 base::WeakPtrFactory<SupervisedUserImportHandler> weak_ptr_factory_; |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(ManagedUserImportHandler); | 91 DISALLOW_COPY_AND_ASSIGN(SupervisedUserImportHandler); |
92 }; | 92 }; |
93 | 93 |
94 } // namespace options | 94 } // namespace options |
95 | 95 |
96 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_ | 96 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_SUPERVISED_USER_IMPORT_HANDLER_H_ |
OLD | NEW |