b02181c9386d1f0ad8da8447d5dd7826524d31f8
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / chromeos / cryptohome_web_ui_handler.h
1 // Copyright (c) 2012 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_CHROMEOS_CRYPTOHOME_WEB_UI_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CRYPTOHOME_WEB_UI_HANDLER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chromeos/dbus/dbus_method_call_status.h"
13 #include "content/public/browser/web_ui_message_handler.h"
14
15 namespace base {
16
17 class Value;
18
19 }  // base
20
21 namespace chromeos {
22
23 // Class to handle messages from chrome://cryptohome.
24 class CryptohomeWebUIHandler : public content::WebUIMessageHandler {
25  public:
26   CryptohomeWebUIHandler();
27
28   virtual ~CryptohomeWebUIHandler();
29
30   // WebUIMessageHandler override.
31   virtual void RegisterMessages() OVERRIDE;
32
33  private:
34   // This method is called from JavaScript.
35   void OnPageLoaded(const base::ListValue* args);
36
37   void DidGetNSSUtilInfoOnUIThread(bool is_tpm_token_ready);
38
39   // Returns a callback to handle Cryptohome property values.
40   BoolDBusMethodCallback GetCryptohomeBoolCallback(
41       const std::string& destination_id);
42
43   // This method is called when Cryptohome D-Bus method call completes.
44   void OnCryptohomeBoolProperty(const std::string& destination_id,
45                                 DBusMethodCallStatus call_status,
46                                 bool value);
47
48   // Sets textcontent of the element whose id is |destination_id| to |value|.
49   void SetCryptohomeProperty(const std::string& destination_id,
50                              const base::Value& value);
51
52   base::WeakPtrFactory<CryptohomeWebUIHandler> weak_ptr_factory_;
53   DISALLOW_COPY_AND_ASSIGN(CryptohomeWebUIHandler);
54 };
55
56 }  // namespace chromeos
57
58 #endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CRYPTOHOME_WEB_UI_HANDLER_H_