Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2537953003: WebString: makes string16 conversions explicit (part 1: blink, content) (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 void RenderFrameImpl::OnPasteAndMatchStyle() { 1834 void RenderFrameImpl::OnPasteAndMatchStyle() {
1835 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); 1835 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1836 frame_->executeCommand(WebString::fromUTF8("PasteAndMatchStyle")); 1836 frame_->executeCommand(WebString::fromUTF8("PasteAndMatchStyle"));
1837 } 1837 }
1838 1838
1839 #if defined(OS_MACOSX) 1839 #if defined(OS_MACOSX)
1840 void RenderFrameImpl::OnCopyToFindPboard() { 1840 void RenderFrameImpl::OnCopyToFindPboard() {
1841 // Since the find pasteboard supports only plain text, this can be simpler 1841 // Since the find pasteboard supports only plain text, this can be simpler
1842 // than the |OnCopy()| case. 1842 // than the |OnCopy()| case.
1843 if (frame_->hasSelection()) { 1843 if (frame_->hasSelection()) {
1844 base::string16 selection = frame_->selectionAsText(); 1844 base::string16 selection = frame_->selectionAsText().utf16();
1845 RenderThread::Get()->Send( 1845 RenderThread::Get()->Send(
1846 new ClipboardHostMsg_FindPboardWriteStringAsync(selection)); 1846 new ClipboardHostMsg_FindPboardWriteStringAsync(selection));
1847 } 1847 }
1848 } 1848 }
1849 #endif 1849 #endif
1850 1850
1851 void RenderFrameImpl::OnDelete() { 1851 void RenderFrameImpl::OnDelete() {
1852 frame_->executeCommand(WebString::fromUTF8("Delete")); 1852 frame_->executeCommand(WebString::fromUTF8("Delete"));
1853 } 1853 }
1854 1854
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 1899
1900 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); 1900 base::AutoReset<bool> handling_select_range(&handling_select_range_, true);
1901 frame_->moveRangeSelectionExtent( 1901 frame_->moveRangeSelectionExtent(
1902 render_view_->ConvertWindowPointToViewport(point)); 1902 render_view_->ConvertWindowPointToViewport(point));
1903 } 1903 }
1904 1904
1905 void RenderFrameImpl::OnReplace(const base::string16& text) { 1905 void RenderFrameImpl::OnReplace(const base::string16& text) {
1906 if (!frame_->hasSelection()) 1906 if (!frame_->hasSelection())
1907 frame_->selectWordAroundCaret(); 1907 frame_->selectWordAroundCaret();
1908 1908
1909 frame_->replaceSelection(text); 1909 frame_->replaceSelection(WebString::fromUTF16(text));
1910 SyncSelectionIfRequired(); 1910 SyncSelectionIfRequired();
1911 } 1911 }
1912 1912
1913 void RenderFrameImpl::OnReplaceMisspelling(const base::string16& text) { 1913 void RenderFrameImpl::OnReplaceMisspelling(const base::string16& text) {
1914 if (!frame_->hasSelection()) 1914 if (!frame_->hasSelection())
1915 return; 1915 return;
1916 1916
1917 frame_->replaceMisspelledRange(text); 1917 frame_->replaceMisspelledRange(WebString::fromUTF16(text));
1918 } 1918 }
1919 1919
1920 void RenderFrameImpl::OnCopyImageAt(int x, int y) { 1920 void RenderFrameImpl::OnCopyImageAt(int x, int y) {
1921 frame_->copyImageAt(WebPoint(x, y)); 1921 frame_->copyImageAt(WebPoint(x, y));
1922 } 1922 }
1923 1923
1924 void RenderFrameImpl::OnSaveImageAt(int x, int y) { 1924 void RenderFrameImpl::OnSaveImageAt(int x, int y) {
1925 frame_->saveImageAt(WebPoint(x, y)); 1925 frame_->saveImageAt(WebPoint(x, y));
1926 } 1926 }
1927 1927
1928 void RenderFrameImpl::OnAddMessageToConsole(ConsoleMessageLevel level, 1928 void RenderFrameImpl::OnAddMessageToConsole(ConsoleMessageLevel level,
1929 const std::string& message) { 1929 const std::string& message) {
1930 AddMessageToConsole(level, message); 1930 AddMessageToConsole(level, message);
1931 } 1931 }
1932 1932
1933 void RenderFrameImpl::OnJavaScriptExecuteRequest( 1933 void RenderFrameImpl::OnJavaScriptExecuteRequest(
1934 const base::string16& jscript, 1934 const base::string16& jscript,
1935 int id, 1935 int id,
1936 bool notify_result) { 1936 bool notify_result) {
1937 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequest", 1937 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequest",
1938 TRACE_EVENT_SCOPE_THREAD); 1938 TRACE_EVENT_SCOPE_THREAD);
1939 1939
1940 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); 1940 v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
1941 v8::Local<v8::Value> result = 1941 v8::Local<v8::Value> result = frame_->executeScriptAndReturnValue(
1942 frame_->executeScriptAndReturnValue(WebScriptSource(jscript)); 1942 WebScriptSource(WebString::fromUTF16(jscript)));
1943 1943
1944 HandleJavascriptExecutionResult(jscript, id, notify_result, result); 1944 HandleJavascriptExecutionResult(jscript, id, notify_result, result);
1945 } 1945 }
1946 1946
1947 void RenderFrameImpl::OnJavaScriptExecuteRequestForTests( 1947 void RenderFrameImpl::OnJavaScriptExecuteRequestForTests(
1948 const base::string16& jscript, 1948 const base::string16& jscript,
1949 int id, 1949 int id,
1950 bool notify_result, 1950 bool notify_result,
1951 bool has_user_gesture) { 1951 bool has_user_gesture) {
1952 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequestForTests", 1952 TRACE_EVENT_INSTANT0("test_tracing", "OnJavaScriptExecuteRequestForTests",
1953 TRACE_EVENT_SCOPE_THREAD); 1953 TRACE_EVENT_SCOPE_THREAD);
1954 1954
1955 // A bunch of tests expect to run code in the context of a user gesture, which 1955 // A bunch of tests expect to run code in the context of a user gesture, which
1956 // can grant additional privileges (e.g. the ability to create popups). 1956 // can grant additional privileges (e.g. the ability to create popups).
1957 std::unique_ptr<blink::WebScopedUserGesture> gesture( 1957 std::unique_ptr<blink::WebScopedUserGesture> gesture(
1958 has_user_gesture ? new blink::WebScopedUserGesture(frame_) : nullptr); 1958 has_user_gesture ? new blink::WebScopedUserGesture(frame_) : nullptr);
1959 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 1959 v8::HandleScope handle_scope(blink::mainThreadIsolate());
1960 v8::Local<v8::Value> result = 1960 v8::Local<v8::Value> result = frame_->executeScriptAndReturnValue(
1961 frame_->executeScriptAndReturnValue(WebScriptSource(jscript)); 1961 WebScriptSource(WebString::fromUTF16(jscript)));
1962 1962
1963 HandleJavascriptExecutionResult(jscript, id, notify_result, result); 1963 HandleJavascriptExecutionResult(jscript, id, notify_result, result);
1964 } 1964 }
1965 1965
1966 void RenderFrameImpl::OnJavaScriptExecuteRequestInIsolatedWorld( 1966 void RenderFrameImpl::OnJavaScriptExecuteRequestInIsolatedWorld(
1967 const base::string16& jscript, 1967 const base::string16& jscript,
1968 int id, 1968 int id,
1969 bool notify_result, 1969 bool notify_result,
1970 int world_id) { 1970 int world_id) {
1971 TRACE_EVENT_INSTANT0("test_tracing", 1971 TRACE_EVENT_INSTANT0("test_tracing",
1972 "OnJavaScriptExecuteRequestInIsolatedWorld", 1972 "OnJavaScriptExecuteRequestInIsolatedWorld",
1973 TRACE_EVENT_SCOPE_THREAD); 1973 TRACE_EVENT_SCOPE_THREAD);
1974 1974
1975 if (world_id <= ISOLATED_WORLD_ID_GLOBAL || 1975 if (world_id <= ISOLATED_WORLD_ID_GLOBAL ||
1976 world_id > ISOLATED_WORLD_ID_MAX) { 1976 world_id > ISOLATED_WORLD_ID_MAX) {
1977 // Return if the world_id is not valid. world_id is passed as a plain int 1977 // Return if the world_id is not valid. world_id is passed as a plain int
1978 // over IPC and needs to be verified here, in the IPC endpoint. 1978 // over IPC and needs to be verified here, in the IPC endpoint.
1979 NOTREACHED(); 1979 NOTREACHED();
1980 return; 1980 return;
1981 } 1981 }
1982 1982
1983 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); 1983 v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
1984 WebScriptSource script = WebScriptSource(jscript); 1984 WebScriptSource script = WebScriptSource(WebString::fromUTF16(jscript));
1985 JavaScriptIsolatedWorldRequest* request = new JavaScriptIsolatedWorldRequest( 1985 JavaScriptIsolatedWorldRequest* request = new JavaScriptIsolatedWorldRequest(
1986 id, notify_result, routing_id_, weak_factory_.GetWeakPtr()); 1986 id, notify_result, routing_id_, weak_factory_.GetWeakPtr());
1987 frame_->requestExecuteScriptInIsolatedWorld(world_id, &script, 1, 0, false, 1987 frame_->requestExecuteScriptInIsolatedWorld(world_id, &script, 1, 0, false,
1988 request); 1988 request);
1989 } 1989 }
1990 1990
1991 RenderFrameImpl::JavaScriptIsolatedWorldRequest::JavaScriptIsolatedWorldRequest( 1991 RenderFrameImpl::JavaScriptIsolatedWorldRequest::JavaScriptIsolatedWorldRequest(
1992 int id, 1992 int id,
1993 bool notify_result, 1993 bool notify_result,
1994 int routing_id, 1994 int routing_id,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); 2218 v8::Local<v8::Context> context = frame_->mainWorldScriptContext();
2219 v8::Context::Scope context_scope(context); 2219 v8::Context::Scope context_scope(context);
2220 V8ValueConverterImpl converter; 2220 V8ValueConverterImpl converter;
2221 converter.SetDateAllowed(true); 2221 converter.SetDateAllowed(true);
2222 converter.SetRegExpAllowed(true); 2222 converter.SetRegExpAllowed(true);
2223 std::unique_ptr<base::Value> value(new base::StringValue(params.data)); 2223 std::unique_ptr<base::Value> value(new base::StringValue(params.data));
2224 v8::Local<v8::Value> result_value = converter.ToV8Value(value.get(), 2224 v8::Local<v8::Value> result_value = converter.ToV8Value(value.get(),
2225 context); 2225 context);
2226 serialized_script_value = WebSerializedScriptValue::serialize(result_value); 2226 serialized_script_value = WebSerializedScriptValue::serialize(result_value);
2227 } else { 2227 } else {
2228 serialized_script_value = WebSerializedScriptValue::fromString(params.data); 2228 serialized_script_value =
2229 WebSerializedScriptValue::fromString(WebString::fromUTF16(params.data));
2229 } 2230 }
2230 2231
2231 // We must pass in the target_origin to do the security check on this side, 2232 // We must pass in the target_origin to do the security check on this side,
2232 // since it may have changed since the original postMessage call was made. 2233 // since it may have changed since the original postMessage call was made.
2233 WebSecurityOrigin target_origin; 2234 WebSecurityOrigin target_origin;
2234 if (!params.target_origin.empty()) { 2235 if (!params.target_origin.empty()) {
2235 target_origin = 2236 target_origin = WebSecurityOrigin::createFromString(
2236 WebSecurityOrigin::createFromString(WebString(params.target_origin)); 2237 WebString::fromUTF16(params.target_origin));
2237 } 2238 }
2238 2239
2239 WebDOMMessageEvent msg_event(serialized_script_value, 2240 WebDOMMessageEvent msg_event(serialized_script_value,
2240 params.source_origin, 2241 WebString::fromUTF16(params.source_origin),
2241 source_frame, 2242 source_frame, frame_->document(), channels);
2242 frame_->document(),
2243 channels);
2244 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); 2243 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event);
2245 } 2244 }
2246 2245
2247 void RenderFrameImpl::OnReload(bool bypass_cache) { 2246 void RenderFrameImpl::OnReload(bool bypass_cache) {
2248 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache 2247 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache
2249 : WebFrameLoadType::Reload); 2248 : WebFrameLoadType::Reload);
2250 } 2249 }
2251 2250
2252 void RenderFrameImpl::OnReloadLoFiImages() { 2251 void RenderFrameImpl::OnReloadLoFiImages() {
2253 is_using_lofi_ = false; 2252 is_using_lofi_ = false;
2254 GetWebFrame()->reloadLoFiImages(); 2253 GetWebFrame()->reloadLoFiImages();
2255 } 2254 }
2256 2255
2257 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) { 2256 void RenderFrameImpl::OnTextSurroundingSelectionRequest(uint32_t max_length) {
2258 blink::WebSurroundingText surroundingText; 2257 blink::WebSurroundingText surroundingText;
2259 surroundingText.initializeFromCurrentSelection(frame_, max_length); 2258 surroundingText.initializeFromCurrentSelection(frame_, max_length);
2260 2259
2261 if (surroundingText.isNull()) { 2260 if (surroundingText.isNull()) {
2262 // |surroundingText| might not be correctly initialized, for example if 2261 // |surroundingText| might not be correctly initialized, for example if
2263 // |frame_->selectionRange().isNull()|, in other words, if there was no 2262 // |frame_->selectionRange().isNull()|, in other words, if there was no
2264 // selection. 2263 // selection.
2265 Send(new FrameHostMsg_TextSurroundingSelectionResponse( 2264 Send(new FrameHostMsg_TextSurroundingSelectionResponse(
2266 routing_id_, base::string16(), 0, 0)); 2265 routing_id_, base::string16(), 0, 0));
2267 return; 2266 return;
2268 } 2267 }
2269 2268
2270 Send(new FrameHostMsg_TextSurroundingSelectionResponse( 2269 Send(new FrameHostMsg_TextSurroundingSelectionResponse(
2271 routing_id_, 2270 routing_id_, surroundingText.textContent().utf16(),
2272 surroundingText.textContent(),
2273 surroundingText.startOffsetInTextContent(), 2271 surroundingText.startOffsetInTextContent(),
2274 surroundingText.endOffsetInTextContent())); 2272 surroundingText.endOffsetInTextContent()));
2275 } 2273 }
2276 2274
2277 void RenderFrameImpl::OnFocusedFormFieldDataRequest(int request_id) { 2275 void RenderFrameImpl::OnFocusedFormFieldDataRequest(int request_id) {
2278 DCHECK(frame_); 2276 DCHECK(frame_);
2279 2277
2280 // In case of early return, the IPC response message is always needed in 2278 // In case of early return, the IPC response message is always needed in
2281 // order to avoid leaks in the browser for unacknowledged requests. 2279 // order to avoid leaks in the browser for unacknowledged requests.
2282 if (frame_ != render_view_->GetWebView()->focusedFrame() || 2280 if (frame_ != render_view_->GetWebView()->focusedFrame() ||
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 blink::WebPlugin* RenderFrameImpl::createPlugin( 2689 blink::WebPlugin* RenderFrameImpl::createPlugin(
2692 blink::WebLocalFrame* frame, 2690 blink::WebLocalFrame* frame,
2693 const blink::WebPluginParams& params) { 2691 const blink::WebPluginParams& params) {
2694 DCHECK_EQ(frame_, frame); 2692 DCHECK_EQ(frame_, frame);
2695 blink::WebPlugin* plugin = NULL; 2693 blink::WebPlugin* plugin = NULL;
2696 if (GetContentClient()->renderer()->OverrideCreatePlugin( 2694 if (GetContentClient()->renderer()->OverrideCreatePlugin(
2697 this, frame, params, &plugin)) { 2695 this, frame, params, &plugin)) {
2698 return plugin; 2696 return plugin;
2699 } 2697 }
2700 2698
2701 if (base::UTF16ToUTF8(base::StringPiece16(params.mimeType)) == 2699 if (params.mimeType.containsOnlyASCII() &&
2702 kBrowserPluginMimeType) { 2700 params.mimeType.ascii() == kBrowserPluginMimeType) {
2703 return BrowserPluginManager::Get()->CreateBrowserPlugin( 2701 return BrowserPluginManager::Get()->CreateBrowserPlugin(
2704 this, GetContentClient() 2702 this, GetContentClient()
2705 ->renderer() 2703 ->renderer()
2706 ->CreateBrowserPluginDelegate(this, kBrowserPluginMimeType, 2704 ->CreateBrowserPluginDelegate(this, kBrowserPluginMimeType,
2707 GURL(params.url)) 2705 GURL(params.url))
2708 ->GetWeakPtr()); 2706 ->GetWeakPtr());
2709 } 2707 }
2710 2708
2711 #if BUILDFLAG(ENABLE_PLUGINS) 2709 #if BUILDFLAG(ENABLE_PLUGINS)
2712 WebPluginInfo info; 2710 WebPluginInfo info;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 const blink::WebString& name, 2968 const blink::WebString& name,
2971 const blink::WebString& unique_name, 2969 const blink::WebString& unique_name,
2972 blink::WebSandboxFlags sandbox_flags, 2970 blink::WebSandboxFlags sandbox_flags,
2973 const blink::WebFrameOwnerProperties& frame_owner_properties) { 2971 const blink::WebFrameOwnerProperties& frame_owner_properties) {
2974 // Synchronously notify the browser of a child frame creation to get the 2972 // Synchronously notify the browser of a child frame creation to get the
2975 // routing_id for the RenderFrame. 2973 // routing_id for the RenderFrame.
2976 int child_routing_id = MSG_ROUTING_NONE; 2974 int child_routing_id = MSG_ROUTING_NONE;
2977 FrameHostMsg_CreateChildFrame_Params params; 2975 FrameHostMsg_CreateChildFrame_Params params;
2978 params.parent_routing_id = routing_id_; 2976 params.parent_routing_id = routing_id_;
2979 params.scope = scope; 2977 params.scope = scope;
2980 params.frame_name = base::UTF16ToUTF8(base::StringPiece16(name)); 2978 params.frame_name = name.utf8();
2981 params.frame_unique_name = 2979 params.frame_unique_name = unique_name.utf8();
2982 base::UTF16ToUTF8(base::StringPiece16(unique_name));
2983 params.sandbox_flags = sandbox_flags; 2980 params.sandbox_flags = sandbox_flags;
2984 params.frame_owner_properties = FrameOwnerProperties(frame_owner_properties); 2981 params.frame_owner_properties = FrameOwnerProperties(frame_owner_properties);
2985 Send(new FrameHostMsg_CreateChildFrame(params, &child_routing_id)); 2982 Send(new FrameHostMsg_CreateChildFrame(params, &child_routing_id));
2986 2983
2987 // Allocation of routing id failed, so we can't create a child frame. This can 2984 // Allocation of routing id failed, so we can't create a child frame. This can
2988 // happen if the synchronous IPC message above has failed. This can 2985 // happen if the synchronous IPC message above has failed. This can
2989 // legitimately happen when the browser process has already destroyed 2986 // legitimately happen when the browser process has already destroyed
2990 // RenderProcessHost, but the renderer process hasn't quit yet. 2987 // RenderProcessHost, but the renderer process hasn't quit yet.
2991 if (child_routing_id == MSG_ROUTING_NONE) 2988 if (child_routing_id == MSG_ROUTING_NONE)
2992 return nullptr; 2989 return nullptr;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 // TODO(alexmos): According to https://crbug.com/169110, sending window.name 3098 // TODO(alexmos): According to https://crbug.com/169110, sending window.name
3102 // updates may have performance implications for benchmarks like SunSpider. 3099 // updates may have performance implications for benchmarks like SunSpider.
3103 // For now, send these updates only for --site-per-process, which needs to 3100 // For now, send these updates only for --site-per-process, which needs to
3104 // replicate frame names to frame proxies, and when 3101 // replicate frame names to frame proxies, and when
3105 // |report_frame_name_changes| is set (used by <webview>). If needed, this 3102 // |report_frame_name_changes| is set (used by <webview>). If needed, this
3106 // can be optimized further by only sending the update if there are any 3103 // can be optimized further by only sending the update if there are any
3107 // remote frames in the frame tree, or delaying and batching up IPCs if 3104 // remote frames in the frame tree, or delaying and batching up IPCs if
3108 // updates are happening too frequently. 3105 // updates are happening too frequently.
3109 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() || 3106 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() ||
3110 render_view_->renderer_preferences_.report_frame_name_changes) { 3107 render_view_->renderer_preferences_.report_frame_name_changes) {
3111 Send(new FrameHostMsg_DidChangeName( 3108 Send(new FrameHostMsg_DidChangeName(routing_id_, name.utf8(),
3112 routing_id_, base::UTF16ToUTF8(base::StringPiece16(name)), 3109 unique_name.utf8()));
3113 base::UTF16ToUTF8(base::StringPiece16(unique_name))));
3114 } 3110 }
3115 3111
3116 if (!committed_first_load_) 3112 if (!committed_first_load_)
3117 name_changed_before_first_commit_ = true; 3113 name_changed_before_first_commit_ = true;
3118 } 3114 }
3119 3115
3120 void RenderFrameImpl::didEnforceInsecureRequestPolicy( 3116 void RenderFrameImpl::didEnforceInsecureRequestPolicy(
3121 blink::WebInsecureRequestPolicy policy) { 3117 blink::WebInsecureRequestPolicy policy) {
3122 Send(new FrameHostMsg_EnforceInsecureRequestPolicy(routing_id_, policy)); 3118 Send(new FrameHostMsg_EnforceInsecureRequestPolicy(routing_id_, policy));
3123 } 3119 }
(...skipping 17 matching lines...) Expand all
3141 } 3137 }
3142 3138
3143 void RenderFrameImpl::didAddContentSecurityPolicy( 3139 void RenderFrameImpl::didAddContentSecurityPolicy(
3144 const blink::WebString& header_value, 3140 const blink::WebString& header_value,
3145 blink::WebContentSecurityPolicyType type, 3141 blink::WebContentSecurityPolicyType type,
3146 blink::WebContentSecurityPolicySource source) { 3142 blink::WebContentSecurityPolicySource source) {
3147 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) 3143 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible())
3148 return; 3144 return;
3149 3145
3150 ContentSecurityPolicyHeader header; 3146 ContentSecurityPolicyHeader header;
3151 header.header_value = base::UTF16ToUTF8(base::StringPiece16(header_value)); 3147 header.header_value = header_value.utf8();
3152 header.type = type; 3148 header.type = type;
3153 header.source = source; 3149 header.source = source;
3154 Send(new FrameHostMsg_DidAddContentSecurityPolicy(routing_id_, header)); 3150 Send(new FrameHostMsg_DidAddContentSecurityPolicy(routing_id_, header));
3155 } 3151 }
3156 3152
3157 void RenderFrameImpl::didChangeFrameOwnerProperties( 3153 void RenderFrameImpl::didChangeFrameOwnerProperties(
3158 blink::WebFrame* child_frame, 3154 blink::WebFrame* child_frame,
3159 const blink::WebFrameOwnerProperties& frame_owner_properties) { 3155 const blink::WebFrameOwnerProperties& frame_owner_properties) {
3160 Send(new FrameHostMsg_DidChangeFrameOwnerProperties( 3156 Send(new FrameHostMsg_DidChangeFrameOwnerProperties(
3161 routing_id_, GetRoutingIdForFrameOrProxy(child_frame), 3157 routing_id_, GetRoutingIdForFrameOrProxy(child_frame),
3162 FrameOwnerProperties(frame_owner_properties))); 3158 FrameOwnerProperties(frame_owner_properties)));
3163 } 3159 }
3164 3160
3165 void RenderFrameImpl::didMatchCSS( 3161 void RenderFrameImpl::didMatchCSS(
3166 blink::WebLocalFrame* frame, 3162 blink::WebLocalFrame* frame,
3167 const blink::WebVector<blink::WebString>& newly_matching_selectors, 3163 const blink::WebVector<blink::WebString>& newly_matching_selectors,
3168 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { 3164 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
3169 DCHECK_EQ(frame_, frame); 3165 DCHECK_EQ(frame_, frame);
3170 3166
3171 for (auto& observer : observers_) 3167 for (auto& observer : observers_)
3172 observer.DidMatchCSS(newly_matching_selectors, stopped_matching_selectors); 3168 observer.DidMatchCSS(newly_matching_selectors, stopped_matching_selectors);
3173 } 3169 }
3174 3170
3175 bool RenderFrameImpl::shouldReportDetailedMessageForSource( 3171 bool RenderFrameImpl::shouldReportDetailedMessageForSource(
3176 const blink::WebString& source) { 3172 const blink::WebString& source) {
3177 return GetContentClient()->renderer()->ShouldReportDetailedMessageForSource( 3173 return GetContentClient()->renderer()->ShouldReportDetailedMessageForSource(
3178 source); 3174 source.utf16());
3179 } 3175 }
3180 3176
3181 void RenderFrameImpl::didAddMessageToConsole( 3177 void RenderFrameImpl::didAddMessageToConsole(
3182 const blink::WebConsoleMessage& message, 3178 const blink::WebConsoleMessage& message,
3183 const blink::WebString& source_name, 3179 const blink::WebString& source_name,
3184 unsigned source_line, 3180 unsigned source_line,
3185 const blink::WebString& stack_trace) { 3181 const blink::WebString& stack_trace) {
3186 logging::LogSeverity log_severity = logging::LOG_VERBOSE; 3182 logging::LogSeverity log_severity = logging::LOG_VERBOSE;
3187 switch (message.level) { 3183 switch (message.level) {
3188 case blink::WebConsoleMessage::LevelDebug: 3184 case blink::WebConsoleMessage::LevelDebug:
3189 log_severity = logging::LOG_VERBOSE; 3185 log_severity = logging::LOG_VERBOSE;
3190 break; 3186 break;
3191 case blink::WebConsoleMessage::LevelLog: 3187 case blink::WebConsoleMessage::LevelLog:
3192 case blink::WebConsoleMessage::LevelInfo: 3188 case blink::WebConsoleMessage::LevelInfo:
3193 log_severity = logging::LOG_INFO; 3189 log_severity = logging::LOG_INFO;
3194 break; 3190 break;
3195 case blink::WebConsoleMessage::LevelWarning: 3191 case blink::WebConsoleMessage::LevelWarning:
3196 log_severity = logging::LOG_WARNING; 3192 log_severity = logging::LOG_WARNING;
3197 break; 3193 break;
3198 case blink::WebConsoleMessage::LevelError: 3194 case blink::WebConsoleMessage::LevelError:
3199 log_severity = logging::LOG_ERROR; 3195 log_severity = logging::LOG_ERROR;
3200 break; 3196 break;
3201 default: 3197 default:
3202 log_severity = logging::LOG_VERBOSE; 3198 log_severity = logging::LOG_VERBOSE;
3203 } 3199 }
3204 3200
3205 if (shouldReportDetailedMessageForSource(source_name)) { 3201 if (shouldReportDetailedMessageForSource(source_name)) {
3206 for (auto& observer : observers_) { 3202 for (auto& observer : observers_) {
3207 observer.DetailedConsoleMessageAdded(message.text, source_name, 3203 observer.DetailedConsoleMessageAdded(
3208 stack_trace, source_line, 3204 message.text.utf16(), source_name.utf16(), stack_trace.utf16(),
3209 static_cast<uint32_t>(log_severity)); 3205 source_line, static_cast<uint32_t>(log_severity));
3210 } 3206 }
3211 } 3207 }
3212 3208
3213 Send(new FrameHostMsg_DidAddMessageToConsole( 3209 Send(new FrameHostMsg_DidAddMessageToConsole(
3214 routing_id_, static_cast<int32_t>(log_severity), message.text, 3210 routing_id_, static_cast<int32_t>(log_severity), message.text.utf16(),
3215 static_cast<int32_t>(source_line), source_name)); 3211 static_cast<int32_t>(source_line), source_name.utf16()));
3216 } 3212 }
3217 3213
3218 void RenderFrameImpl::loadURLExternally(const blink::WebURLRequest& request, 3214 void RenderFrameImpl::loadURLExternally(const blink::WebURLRequest& request,
3219 blink::WebNavigationPolicy policy, 3215 blink::WebNavigationPolicy policy,
3220 const blink::WebString& suggested_name, 3216 const blink::WebString& suggested_name,
3221 bool should_replace_current_entry) { 3217 bool should_replace_current_entry) {
3222 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request)); 3218 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request));
3223 if (policy == blink::WebNavigationPolicyDownload) { 3219 if (policy == blink::WebNavigationPolicyDownload) {
3224 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(), 3220 Send(new FrameHostMsg_DownloadUrl(render_view_->GetRoutingID(),
3225 GetRoutingID(), request.url(), referrer, 3221 GetRoutingID(), request.url(), referrer,
3226 suggested_name)); 3222 suggested_name.utf16()));
3227 } else { 3223 } else {
3228 OpenURL(request.url(), IsHttpPost(request), 3224 OpenURL(request.url(), IsHttpPost(request),
3229 GetRequestBodyForWebURLRequest(request), 3225 GetRequestBodyForWebURLRequest(request),
3230 GetWebURLRequestHeaders(request), referrer, policy, 3226 GetWebURLRequestHeaders(request), referrer, policy,
3231 should_replace_current_entry, false); 3227 should_replace_current_entry, false);
3232 } 3228 }
3233 } 3229 }
3234 3230
3235 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { 3231 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() {
3236 // OOPIF enabled modes will punt this navigation to the browser in 3232 // OOPIF enabled modes will punt this navigation to the browser in
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
3745 GetContentClient()->renderer()->RunScriptsAtDocumentStart(this); 3741 GetContentClient()->renderer()->RunScriptsAtDocumentStart(this);
3746 // Do not use |this| or |frame|! ContentClient might have deleted them by now! 3742 // Do not use |this| or |frame|! ContentClient might have deleted them by now!
3747 } 3743 }
3748 3744
3749 void RenderFrameImpl::didReceiveTitle(blink::WebLocalFrame* frame, 3745 void RenderFrameImpl::didReceiveTitle(blink::WebLocalFrame* frame,
3750 const blink::WebString& title, 3746 const blink::WebString& title,
3751 blink::WebTextDirection direction) { 3747 blink::WebTextDirection direction) {
3752 DCHECK_EQ(frame_, frame); 3748 DCHECK_EQ(frame_, frame);
3753 // Ignore all but top level navigations. 3749 // Ignore all but top level navigations.
3754 if (!frame->parent()) { 3750 if (!frame->parent()) {
3755 base::string16 title16 = title;
3756 base::trace_event::TraceLog::GetInstance()->UpdateProcessLabel( 3751 base::trace_event::TraceLog::GetInstance()->UpdateProcessLabel(
3757 routing_id_, base::UTF16ToUTF8(title16)); 3752 routing_id_, title.utf8());
3758 3753
3754 base::string16 title16 = title.utf16();
3759 base::string16 shortened_title = title16.substr(0, kMaxTitleChars); 3755 base::string16 shortened_title = title16.substr(0, kMaxTitleChars);
3760 Send(new FrameHostMsg_UpdateTitle(routing_id_, 3756 Send(new FrameHostMsg_UpdateTitle(routing_id_,
3761 shortened_title, direction)); 3757 shortened_title, direction));
3762 } 3758 }
3763 3759
3764 // Also check whether we have new encoding name. 3760 // Also check whether we have new encoding name.
3765 UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); 3761 UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
3766 } 3762 }
3767 3763
3768 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame, 3764 void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame,
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
3983 new RendererWebColorChooserImpl(this, client); 3979 new RendererWebColorChooserImpl(this, client);
3984 std::vector<ColorSuggestion> color_suggestions; 3980 std::vector<ColorSuggestion> color_suggestions;
3985 for (size_t i = 0; i < suggestions.size(); i++) { 3981 for (size_t i = 0; i < suggestions.size(); i++) {
3986 color_suggestions.push_back(ColorSuggestion(suggestions[i])); 3982 color_suggestions.push_back(ColorSuggestion(suggestions[i]));
3987 } 3983 }
3988 color_chooser->Open(static_cast<SkColor>(initial_color), color_suggestions); 3984 color_chooser->Open(static_cast<SkColor>(initial_color), color_suggestions);
3989 return color_chooser; 3985 return color_chooser;
3990 } 3986 }
3991 3987
3992 void RenderFrameImpl::runModalAlertDialog(const blink::WebString& message) { 3988 void RenderFrameImpl::runModalAlertDialog(const blink::WebString& message) {
3993 RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_ALERT, 3989 RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_ALERT, message.utf16(),
3994 message, 3990 base::string16(), frame_->document().url(), NULL);
3995 base::string16(),
3996 frame_->document().url(),
3997 NULL);
3998 } 3991 }
3999 3992
4000 bool RenderFrameImpl::runModalConfirmDialog(const blink::WebString& message) { 3993 bool RenderFrameImpl::runModalConfirmDialog(const blink::WebString& message) {
4001 return RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_CONFIRM, 3994 return RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_CONFIRM, message.utf16(),
4002 message, 3995 base::string16(), frame_->document().url(), NULL);
4003 base::string16(),
4004 frame_->document().url(),
4005 NULL);
4006 } 3996 }
4007 3997
4008 bool RenderFrameImpl::runModalPromptDialog( 3998 bool RenderFrameImpl::runModalPromptDialog(
4009 const blink::WebString& message, 3999 const blink::WebString& message,
4010 const blink::WebString& default_value, 4000 const blink::WebString& default_value,
4011 blink::WebString* actual_value) { 4001 blink::WebString* actual_value) {
4012 base::string16 result; 4002 base::string16 result;
4013 bool ok = RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_PROMPT, 4003 bool ok = RunJavaScriptMessage(JAVASCRIPT_MESSAGE_TYPE_PROMPT,
4014 message, 4004 message.utf16(), default_value.utf16(),
4015 default_value, 4005 frame_->document().url(), &result);
4016 frame_->document().url(),
4017 &result);
4018 if (ok) 4006 if (ok)
4019 actual_value->assign(result); 4007 actual_value->assign(WebString::fromUTF16(result));
4020 return ok; 4008 return ok;
4021 } 4009 }
4022 4010
4023 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { 4011 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) {
4024 // Don't allow further dialogs if we are waiting to swap out, since the 4012 // Don't allow further dialogs if we are waiting to swap out, since the
4025 // ScopedPageLoadDeferrer in our stack prevents it. 4013 // ScopedPageLoadDeferrer in our stack prevents it.
4026 if (suppress_further_dialogs_) 4014 if (suppress_further_dialogs_)
4027 return false; 4015 return false;
4028 4016
4029 bool success = false; 4017 bool success = false;
(...skipping 12 matching lines...) Expand all
4042 4030
4043 FileChooserParams ipc_params; 4031 FileChooserParams ipc_params;
4044 if (params.directory) 4032 if (params.directory)
4045 ipc_params.mode = FileChooserParams::UploadFolder; 4033 ipc_params.mode = FileChooserParams::UploadFolder;
4046 else if (params.multiSelect) 4034 else if (params.multiSelect)
4047 ipc_params.mode = FileChooserParams::OpenMultiple; 4035 ipc_params.mode = FileChooserParams::OpenMultiple;
4048 else if (params.saveAs) 4036 else if (params.saveAs)
4049 ipc_params.mode = FileChooserParams::Save; 4037 ipc_params.mode = FileChooserParams::Save;
4050 else 4038 else
4051 ipc_params.mode = FileChooserParams::Open; 4039 ipc_params.mode = FileChooserParams::Open;
4052 ipc_params.title = params.title; 4040 ipc_params.title = params.title.utf16();
4053 ipc_params.accept_types.reserve(params.acceptTypes.size()); 4041 ipc_params.accept_types.reserve(params.acceptTypes.size());
4054 for (const auto& type : params.acceptTypes) 4042 for (const auto& type : params.acceptTypes)
4055 ipc_params.accept_types.push_back(type); 4043 ipc_params.accept_types.push_back(type.utf16());
4056 ipc_params.need_local_path = params.needLocalPath; 4044 ipc_params.need_local_path = params.needLocalPath;
4057 #if defined(OS_ANDROID) 4045 #if defined(OS_ANDROID)
4058 ipc_params.capture = params.useMediaCapture; 4046 ipc_params.capture = params.useMediaCapture;
4059 #endif 4047 #endif
4060 ipc_params.requestor = params.requestor; 4048 ipc_params.requestor = params.requestor;
4061 4049
4062 return ScheduleFileChooser(ipc_params, chooser_completion); 4050 return ScheduleFileChooser(ipc_params, chooser_completion);
4063 } 4051 }
4064 4052
4065 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) { 4053 void RenderFrameImpl::showContextMenu(const blink::WebContextMenuData& data) {
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
4603 } 4591 }
4604 4592
4605 void RenderFrameImpl::exitFullscreen() { 4593 void RenderFrameImpl::exitFullscreen() {
4606 Send(new FrameHostMsg_ToggleFullscreen(routing_id_, false)); 4594 Send(new FrameHostMsg_ToggleFullscreen(routing_id_, false));
4607 } 4595 }
4608 4596
4609 void RenderFrameImpl::registerProtocolHandler(const WebString& scheme, 4597 void RenderFrameImpl::registerProtocolHandler(const WebString& scheme,
4610 const WebURL& url, 4598 const WebURL& url,
4611 const WebString& title) { 4599 const WebString& title) {
4612 bool user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 4600 bool user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
4613 Send(new FrameHostMsg_RegisterProtocolHandler( 4601 Send(new FrameHostMsg_RegisterProtocolHandler(routing_id_, scheme.utf8(), url,
4614 routing_id_, 4602 title.utf16(), user_gesture));
4615 base::UTF16ToUTF8(base::StringPiece16(scheme)),
4616 url,
4617 title,
4618 user_gesture));
4619 } 4603 }
4620 4604
4621 void RenderFrameImpl::unregisterProtocolHandler(const WebString& scheme, 4605 void RenderFrameImpl::unregisterProtocolHandler(const WebString& scheme,
4622 const WebURL& url) { 4606 const WebURL& url) {
4623 bool user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 4607 bool user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
4624 Send(new FrameHostMsg_UnregisterProtocolHandler( 4608 Send(new FrameHostMsg_UnregisterProtocolHandler(routing_id_, scheme.utf8(),
4625 routing_id_, 4609 url, user_gesture));
4626 base::UTF16ToUTF8(base::StringPiece16(scheme)),
4627 url,
4628 user_gesture));
4629 } 4610 }
4630 4611
4631 blink::WebBluetooth* RenderFrameImpl::bluetooth() { 4612 blink::WebBluetooth* RenderFrameImpl::bluetooth() {
4632 if (!bluetooth_.get()) 4613 if (!bluetooth_.get())
4633 bluetooth_.reset(new WebBluetoothImpl(GetRemoteInterfaces())); 4614 bluetooth_.reset(new WebBluetoothImpl(GetRemoteInterfaces()));
4634 return bluetooth_.get(); 4615 return bluetooth_.get();
4635 } 4616 }
4636 4617
4637 void RenderFrameImpl::didSerializeDataForFrame( 4618 void RenderFrameImpl::didSerializeDataForFrame(
4638 const WebCString& data, 4619 const WebCString& data,
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
5468 const WebFindOptions& options) { 5449 const WebFindOptions& options) {
5469 DCHECK(!search_text.empty()); 5450 DCHECK(!search_text.empty());
5470 5451
5471 blink::WebPlugin* plugin = GetWebPluginForFind(); 5452 blink::WebPlugin* plugin = GetWebPluginForFind();
5472 // Check if the plugin still exists in the document. 5453 // Check if the plugin still exists in the document.
5473 if (plugin) { 5454 if (plugin) {
5474 if (options.findNext) { 5455 if (options.findNext) {
5475 // Just navigate back/forward. 5456 // Just navigate back/forward.
5476 plugin->selectFindResult(options.forward, request_id); 5457 plugin->selectFindResult(options.forward, request_id);
5477 } else { 5458 } else {
5478 if (!plugin->startFind(search_text, options.matchCase, request_id)) { 5459 if (!plugin->startFind(WebString::fromUTF16(search_text),
5460 options.matchCase, request_id)) {
5479 // Send "no results". 5461 // Send "no results".
5480 SendFindReply(request_id, 0 /* match_count */, 0 /* ordinal */, 5462 SendFindReply(request_id, 0 /* match_count */, 0 /* ordinal */,
5481 gfx::Rect(), true /* final_status_update */); 5463 gfx::Rect(), true /* final_status_update */);
5482 } 5464 }
5483 } 5465 }
5484 return; 5466 return;
5485 } 5467 }
5486 5468
5487 frame_->requestFind(request_id, search_text, options); 5469 frame_->requestFind(request_id, WebString::fromUTF16(search_text), options);
5488 } 5470 }
5489 5471
5490 void RenderFrameImpl::OnClearActiveFindMatch() { 5472 void RenderFrameImpl::OnClearActiveFindMatch() {
5491 frame_->executeCommand(WebString::fromUTF8("Unselect")); 5473 frame_->executeCommand(WebString::fromUTF8("Unselect"));
5492 frame_->clearActiveFindMatch(); 5474 frame_->clearActiveFindMatch();
5493 } 5475 }
5494 5476
5495 // Ensure that content::StopFindAction and blink::WebLocalFrame::StopFindAction 5477 // Ensure that content::StopFindAction and blink::WebLocalFrame::StopFindAction
5496 // are kept in sync. 5478 // are kept in sync.
5497 STATIC_ASSERT_ENUM(STOP_FIND_ACTION_CLEAR_SELECTION, 5479 STATIC_ASSERT_ENUM(STOP_FIND_ACTION_CLEAR_SELECTION,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5531 // This could happen if we navigated to a different page before the user 5513 // This could happen if we navigated to a different page before the user
5532 // closed the chooser. 5514 // closed the chooser.
5533 if (file_chooser_completions_.empty()) 5515 if (file_chooser_completions_.empty())
5534 return; 5516 return;
5535 5517
5536 // Convert Chrome's SelectedFileInfo list to WebKit's. 5518 // Convert Chrome's SelectedFileInfo list to WebKit's.
5537 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> selected_files( 5519 WebVector<blink::WebFileChooserCompletion::SelectedFileInfo> selected_files(
5538 files.size()); 5520 files.size());
5539 for (size_t i = 0; i < files.size(); ++i) { 5521 for (size_t i = 0; i < files.size(); ++i) {
5540 blink::WebFileChooserCompletion::SelectedFileInfo selected_file; 5522 blink::WebFileChooserCompletion::SelectedFileInfo selected_file;
5541 selected_file.path = files[i].file_path.AsUTF16Unsafe(); 5523 selected_file.path = blink::FilePathToWebString(files[i].file_path);
5542 selected_file.displayName = 5524 selected_file.displayName =
5543 base::FilePath(files[i].display_name).AsUTF16Unsafe(); 5525 blink::FilePathToWebString(base::FilePath(files[i].display_name));
5544 if (files[i].file_system_url.is_valid()) { 5526 if (files[i].file_system_url.is_valid()) {
5545 selected_file.fileSystemURL = files[i].file_system_url; 5527 selected_file.fileSystemURL = files[i].file_system_url;
5546 selected_file.length = files[i].length; 5528 selected_file.length = files[i].length;
5547 selected_file.modificationTime = files[i].modification_time.ToDoubleT(); 5529 selected_file.modificationTime = files[i].modification_time.ToDoubleT();
5548 selected_file.isDirectory = files[i].is_directory; 5530 selected_file.isDirectory = files[i].is_directory;
5549 } 5531 }
5550 selected_files[i] = selected_file; 5532 selected_files[i] = selected_file;
5551 } 5533 }
5552 5534
5553 if (file_chooser_completions_.front()->completion) { 5535 if (file_chooser_completions_.front()->completion) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
5962 blink::WebTextInputTypeNone) { 5944 blink::WebTextInputTypeNone) {
5963 // If current focused element is editable, we will send 100 more chars 5945 // If current focused element is editable, we will send 100 more chars
5964 // before and after selection. It is for input method surrounding text 5946 // before and after selection. It is for input method surrounding text
5965 // feature. 5947 // feature.
5966 if (selection.startOffset() > kExtraCharsBeforeAndAfterSelection) 5948 if (selection.startOffset() > kExtraCharsBeforeAndAfterSelection)
5967 offset = selection.startOffset() - kExtraCharsBeforeAndAfterSelection; 5949 offset = selection.startOffset() - kExtraCharsBeforeAndAfterSelection;
5968 else 5950 else
5969 offset = 0; 5951 offset = 0;
5970 size_t length = 5952 size_t length =
5971 selection.endOffset() - offset + kExtraCharsBeforeAndAfterSelection; 5953 selection.endOffset() - offset + kExtraCharsBeforeAndAfterSelection;
5972 text = frame_->rangeAsText(WebRange(offset, length)); 5954 text = frame_->rangeAsText(WebRange(offset, length)).utf16();
5973 } else { 5955 } else {
5974 offset = selection.startOffset(); 5956 offset = selection.startOffset();
5975 text = frame_->selectionAsText(); 5957 text = frame_->selectionAsText().utf16();
5976 // http://crbug.com/101435 5958 // http://crbug.com/101435
5977 // In some case, frame->selectionAsText() returned text's length is not 5959 // In some case, frame->selectionAsText() returned text's length is not
5978 // equal to the length returned from 5960 // equal to the length returned from
5979 // GetWebWidget()->caretOrSelectionRange(). 5961 // GetWebWidget()->caretOrSelectionRange().
5980 // So we have to set the range according to text.length(). 5962 // So we have to set the range according to text.length().
5981 range.set_end(range.start() + text.length()); 5963 range.set_end(range.start() + text.length());
5982 } 5964 }
5983 } 5965 }
5984 5966
5985 // TODO(dglazkov): Investigate if and why this would be happening, 5967 // TODO(dglazkov): Investigate if and why this would be happening,
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
6220 new MojoBindingsController(this, MojoBindingsType::FOR_HEADLESS); 6202 new MojoBindingsController(this, MojoBindingsType::FOR_HEADLESS);
6221 } 6203 }
6222 } 6204 }
6223 6205
6224 void RenderFrameImpl::SendFailedProvisionalLoad( 6206 void RenderFrameImpl::SendFailedProvisionalLoad(
6225 const blink::WebURLRequest& request, 6207 const blink::WebURLRequest& request,
6226 const blink::WebURLError& error, 6208 const blink::WebURLError& error,
6227 blink::WebLocalFrame* frame) { 6209 blink::WebLocalFrame* frame) {
6228 bool show_repost_interstitial = 6210 bool show_repost_interstitial =
6229 (error.reason == net::ERR_CACHE_MISS && 6211 (error.reason == net::ERR_CACHE_MISS &&
6230 base::EqualsASCII(base::StringPiece16(request.httpMethod()), "POST")); 6212 base::EqualsASCII(request.httpMethod().utf16(), "POST"));
6231 6213
6232 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; 6214 FrameHostMsg_DidFailProvisionalLoadWithError_Params params;
6233 params.error_code = error.reason; 6215 params.error_code = error.reason;
6234 GetContentClient()->renderer()->GetNavigationErrorStrings( 6216 GetContentClient()->renderer()->GetNavigationErrorStrings(
6235 this, request, error, nullptr, &params.error_description); 6217 this, request, error, nullptr, &params.error_description);
6236 params.url = error.unreachableURL; 6218 params.url = error.unreachableURL;
6237 params.showing_repost_interstitial = show_repost_interstitial; 6219 params.showing_repost_interstitial = show_repost_interstitial;
6238 params.was_ignored_by_handler = error.wasIgnoredByHandler; 6220 params.was_ignored_by_handler = error.wasIgnoredByHandler;
6239 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params)); 6221 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params));
6240 } 6222 }
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
6671 // event target. Potentially a Pepper plugin will receive the event. 6653 // event target. Potentially a Pepper plugin will receive the event.
6672 // In order to tell whether a plugin gets the last mouse event and which it 6654 // In order to tell whether a plugin gets the last mouse event and which it
6673 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6655 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6674 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6656 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6675 // |pepper_last_mouse_event_target_|. 6657 // |pepper_last_mouse_event_target_|.
6676 pepper_last_mouse_event_target_ = nullptr; 6658 pepper_last_mouse_event_target_ = nullptr;
6677 #endif 6659 #endif
6678 } 6660 }
6679 6661
6680 } // namespace content 6662 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/url_request_info_util.cc ('k') | content/renderer/render_frame_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698