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 "content/browser/webui/web_ui.h" | 5 #include "content/browser/webui/web_ui.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/profiles/profile.h" | |
14 #include "chrome/browser/ui/webui/generic_handler.h" | |
15 #include "chrome/common/bindings_policy.h" | 13 #include "chrome/common/bindings_policy.h" |
16 #include "chrome/common/extensions/extension_messages.h" | 14 #include "chrome/common/extensions/extension_messages.h" |
17 #include "chrome/common/render_messages.h" | 15 #include "chrome/common/render_messages.h" |
18 #include "content/browser/renderer_host/render_view_host.h" | 16 #include "content/browser/renderer_host/render_view_host.h" |
19 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
20 #include "content/browser/tab_contents/tab_contents_view.h" | 18 #include "content/browser/tab_contents/tab_contents_view.h" |
| 19 #include "content/browser/webui/generic_handler.h" |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 string16 GetJavascript(const std::string& function_name, | 23 string16 GetJavascript(const std::string& function_name, |
25 const std::vector<const Value*>& arg_list) { | 24 const std::vector<const Value*>& arg_list) { |
26 string16 parameters; | 25 string16 parameters; |
27 std::string json; | 26 std::string json; |
28 for (size_t i = 0; i < arg_list.size(); ++i) { | 27 for (size_t i = 0; i < arg_list.size(); ++i) { |
29 if (i > 0) | 28 if (i > 0) |
30 parameters += char16(','); | 29 parameters += char16(','); |
(...skipping 21 matching lines...) Expand all Loading... |
52 } | 51 } |
53 | 52 |
54 WebUI::~WebUI() { | 53 WebUI::~WebUI() { |
55 STLDeleteContainerPairSecondPointers(message_callbacks_.begin(), | 54 STLDeleteContainerPairSecondPointers(message_callbacks_.begin(), |
56 message_callbacks_.end()); | 55 message_callbacks_.end()); |
57 STLDeleteContainerPointers(handlers_.begin(), handlers_.end()); | 56 STLDeleteContainerPointers(handlers_.begin(), handlers_.end()); |
58 } | 57 } |
59 | 58 |
60 // WebUI, public: ------------------------------------------------------------- | 59 // WebUI, public: ------------------------------------------------------------- |
61 | 60 |
| 61 const WebUI::TypeID WebUI::kNoWebUI = NULL; |
| 62 |
62 void WebUI::ProcessWebUIMessage( | 63 void WebUI::ProcessWebUIMessage( |
63 const ExtensionHostMsg_DomMessage_Params& params) { | 64 const ExtensionHostMsg_DomMessage_Params& params) { |
64 // Look up the callback for this message. | 65 // Look up the callback for this message. |
65 MessageCallbackMap::const_iterator callback = | 66 MessageCallbackMap::const_iterator callback = |
66 message_callbacks_.find(params.name); | 67 message_callbacks_.find(params.name); |
67 if (callback == message_callbacks_.end()) | 68 if (callback == message_callbacks_.end()) |
68 return; | 69 return; |
69 | 70 |
70 // Forward this message and content on. | 71 // Forward this message and content on. |
71 callback->second->Run(¶ms.arguments); | 72 callback->second->Run(¶ms.arguments); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 return false; | 211 return false; |
211 } | 212 } |
212 | 213 |
213 string16 WebUIMessageHandler::ExtractStringValue(const ListValue* value) { | 214 string16 WebUIMessageHandler::ExtractStringValue(const ListValue* value) { |
214 string16 string16_value; | 215 string16 string16_value; |
215 if (value->GetString(0, &string16_value)) | 216 if (value->GetString(0, &string16_value)) |
216 return string16_value; | 217 return string16_value; |
217 NOTREACHED(); | 218 NOTREACHED(); |
218 return string16(); | 219 return string16(); |
219 } | 220 } |
OLD | NEW |