[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 1 | // Copyright 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 | #include "content/renderer/web_ui_extension_data.h" |
| 6 | |
| 7 | #include "content/common/view_messages.h" |
| 8 | #include "content/public/renderer/render_view.h" |
| 9 | |
| 10 | namespace content { |
| 11 | |
| 12 | WebUIExtensionData::WebUIExtensionData(RenderView* render_view) |
| 13 | : RenderViewObserver(render_view), |
| 14 | RenderViewObserverTracker<WebUIExtensionData>(render_view) { |
| 15 | } |
| 16 | |
| 17 | WebUIExtensionData::~WebUIExtensionData() { |
| 18 | } |
| 19 | |
| 20 | std::string WebUIExtensionData::GetValue(const std::string& key) const { |
| 21 | std::map<std::string, std::string>::const_iterator it = |
| 22 | variable_map_.find(key); |
| 23 | if (it == variable_map_.end()) |
| 24 | return std::string(); |
| 25 | return it->second; |
| 26 | } |
| 27 | |
| 28 | bool WebUIExtensionData::OnMessageReceived(const IPC::Message& message) { |
| 29 | bool handled = true; |
| 30 | IPC_BEGIN_MESSAGE_MAP(WebUIExtensionData, message) |
| 31 | IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) |
| 32 | IPC_MESSAGE_UNHANDLED(handled = false) |
| 33 | IPC_END_MESSAGE_MAP() |
| 34 | return handled; |
| 35 | } |
| 36 | |
| 37 | void WebUIExtensionData::OnSetWebUIProperty(const std::string& name, |
| 38 | const std::string& value) { |
| 39 | variable_map_[name] = value; |
| 40 | } |
| 41 | |
| 42 | } // namespace content |