summaryrefslogtreecommitdiff
path: root/chromium/content/renderer/web_ui_extension_data.cc
blob: 9d8c5ed379da41bf9ef99b2c52a3509d904d9203 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/renderer/web_ui_extension_data.h"

#include "content/common/view_messages.h"
#include "content/public/renderer/render_view.h"

namespace content {

WebUIExtensionData::WebUIExtensionData(RenderView* render_view)
    : RenderViewObserver(render_view),
      RenderViewObserverTracker<WebUIExtensionData>(render_view) {
}

WebUIExtensionData::~WebUIExtensionData() {
}

std::string WebUIExtensionData::GetValue(const std::string& key) const {
  auto it = variable_map_.find(key);
  if (it == variable_map_.end())
    return std::string();
  return it->second;
}

bool WebUIExtensionData::OnMessageReceived(const IPC::Message& message) {
  bool handled = true;
  IPC_BEGIN_MESSAGE_MAP(WebUIExtensionData, message)
    IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty)
    IPC_MESSAGE_UNHANDLED(handled = false)
  IPC_END_MESSAGE_MAP()
  return handled;
}

void WebUIExtensionData::OnSetWebUIProperty(const std::string& name,
                                            const std::string& value) {
  variable_map_[name] = value;
}

void WebUIExtensionData::OnDestruct() {
  delete this;
}

}  // namespace content