OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ |
6 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" | 9 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 | 17 |
| 18 class GURL; |
| 19 |
| 20 namespace base { |
18 class ListValue; | 21 class ListValue; |
19 class GURL; | 22 } |
20 | 23 |
21 namespace chromeos { | 24 namespace chromeos { |
22 | 25 |
23 typedef Callback1<const ListValue*>::Type MessageCallback; | 26 typedef Callback1<const base::ListValue*>::Type MessageCallback; |
24 | 27 |
25 class BalloonViewHost : public ::BalloonViewHost { | 28 class BalloonViewHost : public ::BalloonViewHost { |
26 public: | 29 public: |
27 explicit BalloonViewHost(Balloon* balloon); | 30 explicit BalloonViewHost(Balloon* balloon); |
28 virtual ~BalloonViewHost(); | 31 virtual ~BalloonViewHost(); |
29 | 32 |
30 // Adds a callback for WebUI message. Returns true if the callback | 33 // Adds a callback for WebUI message. Returns true if the callback |
31 // is succssfully registered, or false otherwise. It fails to add if | 34 // is succssfully registered, or false otherwise. It fails to add if |
32 // a callback for given message already exists. The callback object | 35 // a callback for given message already exists. The callback object |
33 // is owned and deleted by callee. | 36 // is owned and deleted by callee. |
34 bool AddWebUIMessageCallback(const std::string& message, | 37 bool AddWebUIMessageCallback(const std::string& message, |
35 MessageCallback* callback); | 38 MessageCallback* callback); |
36 | 39 |
37 private: | 40 private: |
38 // RenderViewHostDelegate | 41 // RenderViewHostDelegate |
39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
40 | 43 |
41 // A map of message name -> message handling callback. | 44 // A map of message name -> message handling callback. |
42 typedef std::map<std::string, MessageCallback*> MessageCallbackMap; | 45 typedef std::map<std::string, MessageCallback*> MessageCallbackMap; |
43 MessageCallbackMap message_callbacks_; | 46 MessageCallbackMap message_callbacks_; |
44 | 47 |
45 // Message handlers. | 48 // Message handlers. |
46 virtual void OnWebUISend(const GURL& source_url, | 49 virtual void OnWebUISend(const GURL& source_url, |
47 const std::string& name, | 50 const std::string& name, |
48 const ListValue& args); | 51 const base::ListValue& args); |
49 | 52 |
50 DISALLOW_COPY_AND_ASSIGN(BalloonViewHost); | 53 DISALLOW_COPY_AND_ASSIGN(BalloonViewHost); |
51 }; | 54 }; |
52 | 55 |
53 } // namespace chromeos | 56 } // namespace chromeos |
54 | 57 |
55 #endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ | 58 #endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ |
OLD | NEW |