OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/dom_ui/dom_ui_host.h" | 5 #include "chrome/browser/dom_ui/dom_ui_host.h" |
6 | 6 |
7 #include "base/json_reader.h" | 7 #include "base/json_reader.h" |
8 #include "base/json_writer.h" | 8 #include "base/json_writer.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/navigation_entry.h" | 10 #include "chrome/browser/navigation_entry.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 void DOMUIHost::ExecuteJavascript(const std::wstring& javascript) { | 104 void DOMUIHost::ExecuteJavascript(const std::wstring& javascript) { |
105 // We're taking a string and making a javascript URL out of it. This means | 105 // We're taking a string and making a javascript URL out of it. This means |
106 // that escaping will follow the rules of a URL. Yet, the JSON text may have | 106 // that escaping will follow the rules of a URL. Yet, the JSON text may have |
107 // stuff in it that would be interpreted as escaped characters in a URL, but | 107 // stuff in it that would be interpreted as escaped characters in a URL, but |
108 // we want to preserve them literally. | 108 // we want to preserve them literally. |
109 // | 109 // |
110 // We just escape all the percents to avoid this, since when this javascript | 110 // We just escape all the percents to avoid this, since when this javascript |
111 // URL is interpreted, it will be unescaped. | 111 // URL is interpreted, it will be unescaped. |
112 std::wstring escaped_js(javascript); | 112 std::wstring escaped_js(javascript); |
113 ReplaceSubstringsAfterOffset(&escaped_js, 0, L"%", L"%25"); | 113 ReplaceSubstringsAfterOffset(&escaped_js, 0, L"%", L"%25"); |
114 ExecuteJavascriptInWebFrame(L"", L"javascript:" + escaped_js); | 114 render_view_host()->ExecuteJavascriptInWebFrame(std::wstring(), |
| 115 L"javascript:" + escaped_js); |
115 } | 116 } |
116 | 117 |
OLD | NEW |