| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_impl.h" | 5 #include "content/browser/webui/web_ui_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // static | 32 // static |
| 33 string16 WebUI::GetJavascriptCall( | 33 string16 WebUI::GetJavascriptCall( |
| 34 const std::string& function_name, | 34 const std::string& function_name, |
| 35 const std::vector<const Value*>& arg_list) { | 35 const std::vector<const Value*>& arg_list) { |
| 36 string16 parameters; | 36 string16 parameters; |
| 37 std::string json; | 37 std::string json; |
| 38 for (size_t i = 0; i < arg_list.size(); ++i) { | 38 for (size_t i = 0; i < arg_list.size(); ++i) { |
| 39 if (i > 0) | 39 if (i > 0) |
| 40 parameters += char16(','); | 40 parameters += char16(','); |
| 41 | 41 |
| 42 base::JSONWriter::Write(arg_list[i], false, &json); | 42 base::JSONWriter::Write(arg_list[i], &json); |
| 43 parameters += UTF8ToUTF16(json); | 43 parameters += UTF8ToUTF16(json); |
| 44 } | 44 } |
| 45 return ASCIIToUTF16(function_name) + | 45 return ASCIIToUTF16(function_name) + |
| 46 char16('(') + parameters + char16(')') + char16(';'); | 46 char16('(') + parameters + char16(')') + char16(';'); |
| 47 } | 47 } |
| 48 | 48 |
| 49 } | 49 } |
| 50 | 50 |
| 51 WebUIImpl::WebUIImpl(WebContents* contents) | 51 WebUIImpl::WebUIImpl(WebContents* contents) |
| 52 : hide_favicon_(false), | 52 : hide_favicon_(false), |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 handler->set_web_ui(this); | 258 handler->set_web_ui(this); |
| 259 handler->RegisterMessages(); | 259 handler->RegisterMessages(); |
| 260 handlers_.push_back(handler); | 260 handlers_.push_back(handler); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void WebUIImpl::ExecuteJavascript(const string16& javascript) { | 263 void WebUIImpl::ExecuteJavascript(const string16& javascript) { |
| 264 static_cast<RenderViewHostImpl*>( | 264 static_cast<RenderViewHostImpl*>( |
| 265 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame( | 265 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame( |
| 266 ASCIIToUTF16(frame_xpath_), javascript); | 266 ASCIIToUTF16(frame_xpath_), javascript); |
| 267 } | 267 } |
| OLD | NEW |