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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 void InspectorFrontendHost::sendMessageToBackend(const String& message) | 163 void InspectorFrontendHost::sendMessageToBackend(const String& message) |
| 164 { | 164 { |
| 165 if (m_client) | 165 if (m_client) |
| 166 m_client->sendMessageToBackend(message); | 166 m_client->sendMessageToBackend(message); |
|
pfeldman
2014/03/04 11:45:46
Lets use it here as well.
yurys
2014/03/04 12:15:35
Done.
| |
| 167 } | 167 } |
| 168 | 168 |
| 169 static String escapeUnicodeNonCharacters(const String& str) | |
| 170 { | |
| 171 StringBuilder dst; | |
| 172 for (unsigned i = 0; i < str.length(); ++i) { | |
| 173 UChar c = str[i]; | |
| 174 if (c < 32 || c > 126) { | |
| 175 unsigned symbol = static_cast<unsigned>(c); | |
| 176 String symbolCode = String::format("\\u%04X", symbol); | |
| 177 dst.append(symbolCode); | |
| 178 } else { | |
| 179 dst.append(c); | |
| 180 } | |
| 181 | |
| 182 } | |
| 183 return dst.toString(); | |
| 184 } | |
| 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 |