• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_
6 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_
7 #pragma once
8 
9 #include "chrome/browser/ui/views/notifications/balloon_view_host.h"
10 
11 #include <map>
12 #include <string>
13 
14 #include "base/callback.h"
15 #include "ui/gfx/native_widget_types.h"
16 
17 class ListValue;
18 class GURL;
19 
20 namespace chromeos {
21 
22 typedef Callback1<const ListValue*>::Type MessageCallback;
23 
24 class BalloonViewHost : public ::BalloonViewHost {
25  public:
BalloonViewHost(Balloon * balloon)26   explicit BalloonViewHost(Balloon* balloon) : ::BalloonViewHost(balloon) {}
27   virtual ~BalloonViewHost();
28 
29   // Adds a callback for WebUI message. Returns true if the callback
30   // is succssfully registered, or false otherwise. It fails to add if
31   // a callback for given message already exists. The callback object
32   // is owned and deleted by callee.
33   bool AddWebUIMessageCallback(const std::string& message,
34                                MessageCallback* callback);
35 
36   // Process WebUI message.
37   virtual void ProcessWebUIMessage(
38       const ExtensionHostMsg_DomMessage_Params& params);
39 
40  private:
41   // A map of message name -> message handling callback.
42   typedef std::map<std::string, MessageCallback*> MessageCallbackMap;
43   MessageCallbackMap message_callbacks_;
44 
45   DISALLOW_COPY_AND_ASSIGN(BalloonViewHost);
46 };
47 
48 }  // namespace chromeos
49 
50 #endif  // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_
51