| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 10 |
| 10 namespace chromeos { | 11 namespace chromeos { |
| 11 | 12 |
| 12 BalloonViewHost::~BalloonViewHost() { | 13 BalloonViewHost::~BalloonViewHost() { |
| 13 STLDeleteContainerPairSecondPointers(message_callbacks_.begin(), | 14 STLDeleteContainerPairSecondPointers(message_callbacks_.begin(), |
| 14 message_callbacks_.end()); | 15 message_callbacks_.end()); |
| 15 } | 16 } |
| 16 | 17 |
| 17 bool BalloonViewHost::AddDOMUIMessageCallback( | 18 bool BalloonViewHost::AddDOMUIMessageCallback( |
| 18 const std::string& message, | 19 const std::string& message, |
| 19 MessageCallback* callback) { | 20 MessageCallback* callback) { |
| 20 std::pair<MessageCallbackMap::iterator, bool> ret; | 21 std::pair<MessageCallbackMap::iterator, bool> ret; |
| 21 ret = message_callbacks_.insert(std::make_pair(message, callback)); | 22 ret = message_callbacks_.insert(std::make_pair(message, callback)); |
| 22 if (!ret.second) | 23 if (!ret.second) |
| 23 delete callback; | 24 delete callback; |
| 24 return ret.second; | 25 return ret.second; |
| 25 } | 26 } |
| 26 | 27 |
| 27 void BalloonViewHost::ProcessDOMUIMessage(const std::string& message, | 28 void BalloonViewHost::ProcessDOMUIMessage( |
| 28 const ListValue* content, | 29 const ViewHostMsg_DomMessage_Params& params) { |
| 29 const GURL& source_url, | 30 ::BalloonViewHost::ProcessDOMUIMessage(params); |
| 30 int request_id, | 31 |
| 31 bool has_callback) { | |
| 32 ::BalloonViewHost::ProcessDOMUIMessage(message, | |
| 33 content, | |
| 34 source_url, | |
| 35 request_id, | |
| 36 has_callback); | |
| 37 // Look up the callback for this message. | 32 // Look up the callback for this message. |
| 38 MessageCallbackMap::const_iterator callback = | 33 MessageCallbackMap::const_iterator callback = |
| 39 message_callbacks_.find(message); | 34 message_callbacks_.find(params.name); |
| 40 if (callback == message_callbacks_.end()) | 35 if (callback == message_callbacks_.end()) |
| 41 return; | 36 return; |
| 42 | 37 |
| 43 // Run callback. | 38 // Run callback. |
| 44 callback->second->Run(content); | 39 callback->second->Run(¶ms.arguments); |
| 45 } | 40 } |
| 46 | 41 |
| 47 } // namespace chromeos | 42 } // namespace chromeos |
| OLD | NEW |