Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 void InspectorFrontendHost::setInjectedScriptForOrigin(const String& origin, con st String& script) | 153 void InspectorFrontendHost::setInjectedScriptForOrigin(const String& origin, con st String& script) |
| 154 { | 154 { |
| 155 m_frontendPage->inspectorController().setInjectedScriptForOrigin(origin, scr ipt); | 155 m_frontendPage->inspectorController().setInjectedScriptForOrigin(origin, scr ipt); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void InspectorFrontendHost::copyText(const String& text) | 158 void InspectorFrontendHost::copyText(const String& text) |
| 159 { | 159 { |
| 160 Pasteboard::generalPasteboard()->writePlainText(text, Pasteboard::CannotSmar tReplace); | 160 Pasteboard::generalPasteboard()->writePlainText(text, Pasteboard::CannotSmar tReplace); |
| 161 } | 161 } |
| 162 | 162 |
| 163 static String escapeUnicodeNonCharacters(const String& str) | |
| 164 { | |
| 165 StringBuilder dst; | |
| 166 for (unsigned i = 0; i < str.length(); ++i) { | |
| 167 UChar c = str[i]; | |
| 168 if (c > 126) { | |
|
alph
2014/03/05 09:01:54
126 seems to be too conservative. I'd suggest esca
yurys
2014/03/05 11:33:37
PTAL: https://codereview.chromium.org/180113008/
| |
| 169 unsigned symbol = static_cast<unsigned>(c); | |
| 170 String symbolCode = String::format("\\u%04X", symbol); | |
| 171 dst.append(symbolCode); | |
| 172 } else { | |
| 173 dst.append(c); | |
| 174 } | |
| 175 | |
| 176 } | |
| 177 return dst.toString(); | |
| 178 } | |
| 179 | |
| 163 void InspectorFrontendHost::sendMessageToBackend(const String& message) | 180 void InspectorFrontendHost::sendMessageToBackend(const String& message) |
| 164 { | 181 { |
| 165 if (m_client) | 182 if (m_client) |
| 166 m_client->sendMessageToBackend(message); | 183 m_client->sendMessageToBackend(escapeUnicodeNonCharacters(message)); |
| 167 } | 184 } |
| 168 | 185 |
| 169 void InspectorFrontendHost::sendMessageToEmbedder(const String& message) | 186 void InspectorFrontendHost::sendMessageToEmbedder(const String& message) |
| 170 { | 187 { |
| 171 if (m_client) | 188 if (m_client) |
| 172 m_client->sendMessageToEmbedder(message); | 189 m_client->sendMessageToEmbedder(escapeUnicodeNonCharacters(message)); |
| 173 } | 190 } |
| 174 | 191 |
| 175 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe nuItem>& items) | 192 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe nuItem>& items) |
| 176 { | 193 { |
| 177 if (!event) | 194 if (!event) |
| 178 return; | 195 return; |
| 179 | 196 |
| 180 ASSERT(m_frontendPage); | 197 ASSERT(m_frontendPage); |
| 181 ScriptState* frontendScriptState = mainWorldScriptState(m_frontendPage->main Frame()); | 198 ScriptState* frontendScriptState = mainWorldScriptState(m_frontendPage->main Frame()); |
| 182 ScriptObject frontendApiObject; | 199 ScriptObject frontendApiObject; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 198 { | 215 { |
| 199 return RenderTheme::theme().activeSelectionForegroundColor().serialized(); | 216 return RenderTheme::theme().activeSelectionForegroundColor().serialized(); |
| 200 } | 217 } |
| 201 | 218 |
| 202 bool InspectorFrontendHost::isUnderTest() | 219 bool InspectorFrontendHost::isUnderTest() |
| 203 { | 220 { |
| 204 return m_client && m_client->isUnderTest(); | 221 return m_client && m_client->isUnderTest(); |
| 205 } | 222 } |
| 206 | 223 |
| 207 } // namespace WebCore | 224 } // namespace WebCore |
| OLD | NEW |