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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/ui/webui/options/options_ui.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
14 class DictionaryValue
;
20 // Handler for the 'import existing managed user' dialog.
21 class ManagedUserImportHandler
: public OptionsPageUIHandler
{
23 ManagedUserImportHandler();
24 virtual ~ManagedUserImportHandler();
26 // OptionsPageUIHandler implementation.
27 virtual void GetLocalizedValues(
28 base::DictionaryValue
* localized_strings
) OVERRIDE
;
29 virtual void InitializeHandler() OVERRIDE
;
31 // WebUIMessageHandler implementation.
32 virtual void RegisterMessages() OVERRIDE
;
34 // content::NotificationObserver implementation.
35 virtual void Observe(int type
,
36 const content::NotificationSource
& source
,
37 const content::NotificationDetails
& details
) OVERRIDE
;
39 // Callback for the "requestManagedUserImportUpdate" message.
40 // Checks the sign-in status of the custodian and accordingly
41 // sends an update to the WebUI. The update can be to show/hide
42 // an error bubble and update/clear the managed user list.
43 void RequestManagedUserImportUpdate(const base::ListValue
* args
);
45 // Sends an array of managed users to WebUI. Each entry is of the form:
47 // id: "Managed User ID",
48 // name: "Managed User Name",
49 // iconURL: "chrome://path/to/icon/image",
50 // onCurrentDevice: true or false,
51 // needAvatar: true or false
53 // The array holds all existing managed users attached to the
54 // custodian's profile which initiated the request.
55 void SendExistingManagedUsers(const base::DictionaryValue
* dict
);
57 // Sends messages to the JS side to clear managed users and show an error
59 void ClearManagedUsersAndShowError();
61 bool IsAccountConnected() const;
62 bool HasAuthError() const;
64 base::WeakPtrFactory
<ManagedUserImportHandler
> weak_ptr_factory_
;
66 DISALLOW_COPY_AND_ASSIGN(ManagedUserImportHandler
);
69 } // namespace options
71 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_