dafb416d7f9f7f8b3e460554933817eda75b9d8d
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / options / managed_user_import_handler.h
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.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_
7
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"
12
13 namespace base {
14 class DictionaryValue;
15 class ListValue;
16 }
17
18 namespace options {
19
20 // Handler for the 'import existing managed user' dialog.
21 class ManagedUserImportHandler : public OptionsPageUIHandler {
22  public:
23   ManagedUserImportHandler();
24   virtual ~ManagedUserImportHandler();
25
26   // OptionsPageUIHandler implementation.
27   virtual void GetLocalizedValues(
28       base::DictionaryValue* localized_strings) OVERRIDE;
29   virtual void InitializeHandler() OVERRIDE;
30
31   // WebUIMessageHandler implementation.
32   virtual void RegisterMessages() OVERRIDE;
33
34   // content::NotificationObserver implementation.
35   virtual void Observe(int type,
36                        const content::NotificationSource& source,
37                        const content::NotificationDetails& details) OVERRIDE;
38  private:
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);
44
45   // Sends an array of managed users to WebUI. Each entry is of the form:
46   //   managedProfile = {
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
52   //   }
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);
56
57   // Sends messages to the JS side to clear managed users and show an error
58   // bubble.
59   void ClearManagedUsersAndShowError();
60
61   bool IsAccountConnected() const;
62   bool HasAuthError() const;
63
64   base::WeakPtrFactory<ManagedUserImportHandler> weak_ptr_factory_;
65
66   DISALLOW_COPY_AND_ASSIGN(ManagedUserImportHandler);
67 };
68
69 }  // namespace options
70
71 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGED_USER_IMPORT_HANDLER_H_