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 #include "chrome/browser/chromeos/notifications/balloon_view_host.h" | 5 #include "chrome/browser/chromeos/notifications/balloon_view_host.h" |
6 | 6 |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/extensions/extension_messages.h" |
10 #include "chrome/common/render_messages_params.h" | |
11 | 10 |
12 namespace chromeos { | 11 namespace chromeos { |
13 | 12 |
14 BalloonViewHost::~BalloonViewHost() { | 13 BalloonViewHost::~BalloonViewHost() { |
15 STLDeleteContainerPairSecondPointers(message_callbacks_.begin(), | 14 STLDeleteContainerPairSecondPointers(message_callbacks_.begin(), |
16 message_callbacks_.end()); | 15 message_callbacks_.end()); |
17 } | 16 } |
18 | 17 |
19 bool BalloonViewHost::AddWebUIMessageCallback( | 18 bool BalloonViewHost::AddWebUIMessageCallback( |
20 const std::string& message, | 19 const std::string& message, |
21 MessageCallback* callback) { | 20 MessageCallback* callback) { |
22 std::pair<MessageCallbackMap::iterator, bool> ret; | 21 std::pair<MessageCallbackMap::iterator, bool> ret; |
23 ret = message_callbacks_.insert(std::make_pair(message, callback)); | 22 ret = message_callbacks_.insert(std::make_pair(message, callback)); |
24 if (!ret.second) | 23 if (!ret.second) |
25 delete callback; | 24 delete callback; |
26 return ret.second; | 25 return ret.second; |
27 } | 26 } |
28 | 27 |
29 void BalloonViewHost::ProcessWebUIMessage( | 28 void BalloonViewHost::ProcessWebUIMessage( |
30 const ViewHostMsg_DomMessage_Params& params) { | 29 const ExtensionHostMsg_DomMessage_Params& params) { |
31 ::BalloonViewHost::ProcessWebUIMessage(params); | 30 ::BalloonViewHost::ProcessWebUIMessage(params); |
32 | 31 |
33 // Look up the callback for this message. | 32 // Look up the callback for this message. |
34 MessageCallbackMap::const_iterator callback = | 33 MessageCallbackMap::const_iterator callback = |
35 message_callbacks_.find(params.name); | 34 message_callbacks_.find(params.name); |
36 if (callback == message_callbacks_.end()) | 35 if (callback == message_callbacks_.end()) |
37 return; | 36 return; |
38 | 37 |
39 // Run callback. | 38 // Run callback. |
40 callback->second->Run(¶ms.arguments); | 39 callback->second->Run(¶ms.arguments); |
41 } | 40 } |
42 | 41 |
43 } // namespace chromeos | 42 } // namespace chromeos |
OLD | NEW |