| 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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) | 958 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
| 959 // TODO(viettrungluu): Move to a separate message filter. | 959 // TODO(viettrungluu): Move to a separate message filter. |
| 960 #if defined(OS_MACOSX) | 960 #if defined(OS_MACOSX) |
| 961 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 961 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 962 #endif | 962 #endif |
| 963 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 963 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
| 964 OnSetHistoryLengthAndPrune) | 964 OnSetHistoryLengthAndPrune) |
| 965 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 965 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
| 966 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) | 966 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
| 967 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) | 967 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) |
| 968 IPC_MESSAGE_HANDLER(ViewMsg_DocumentHasImages, OnDocumentHasImagesRequest) |
| 968 | 969 |
| 969 // Have the super handle all other messages. | 970 // Have the super handle all other messages. |
| 970 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 971 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
| 971 IPC_END_MESSAGE_MAP() | 972 IPC_END_MESSAGE_MAP() |
| 972 | 973 |
| 973 if (!msg_is_ok) { | 974 if (!msg_is_ok) { |
| 974 // The message had a handler, but its deserialization failed. | 975 // The message had a handler, but its deserialization failed. |
| 975 // Kill the renderer to avoid potential spoofing attacks. | 976 // Kill the renderer to avoid potential spoofing attacks. |
| 976 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; | 977 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
| 977 } | 978 } |
| (...skipping 3474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4452 // We must pass in the target_origin to do the security check on this side, | 4453 // We must pass in the target_origin to do the security check on this side, |
| 4453 // since it may have changed since the original postMessage call was made. | 4454 // since it may have changed since the original postMessage call was made. |
| 4454 WebSecurityOrigin target_origin; | 4455 WebSecurityOrigin target_origin; |
| 4455 if (!params.target_origin.empty()) { | 4456 if (!params.target_origin.empty()) { |
| 4456 target_origin = | 4457 target_origin = |
| 4457 WebSecurityOrigin::createFromString(WebString(params.target_origin)); | 4458 WebSecurityOrigin::createFromString(WebString(params.target_origin)); |
| 4458 } | 4459 } |
| 4459 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event); | 4460 frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
| 4460 } | 4461 } |
| 4461 | 4462 |
| 4463 void RenderViewImpl::OnDocumentHasImagesRequest(int id) { |
| 4464 bool hasImages = false; |
| 4465 if (webview()) { |
| 4466 WebVector<WebElement> images; |
| 4467 webview()->mainFrame()->document().images(images); |
| 4468 hasImages = !images.isEmpty(); |
| 4469 } |
| 4470 Send(new ViewHostMsg_DocumentHasImagesResponse(routing_id_, id, hasImages)); |
| 4471 } |
| 4472 |
| 4462 void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath, | 4473 void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath, |
| 4463 const std::string& css) { | 4474 const std::string& css) { |
| 4464 WebFrame* frame = GetChildFrame(frame_xpath); | 4475 WebFrame* frame = GetChildFrame(frame_xpath); |
| 4465 if (!frame) | 4476 if (!frame) |
| 4466 return; | 4477 return; |
| 4467 | 4478 |
| 4468 frame->document().insertUserStyleSheet( | 4479 frame->document().insertUserStyleSheet( |
| 4469 WebString::fromUTF8(css), | 4480 WebString::fromUTF8(css), |
| 4470 WebDocument::UserStyleAuthorLevel); | 4481 WebDocument::UserStyleAuthorLevel); |
| 4471 } | 4482 } |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5661 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5672 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
| 5662 return !!RenderThreadImpl::current()->compositor_thread(); | 5673 return !!RenderThreadImpl::current()->compositor_thread(); |
| 5663 } | 5674 } |
| 5664 | 5675 |
| 5665 void RenderViewImpl::OnJavaBridgeInit() { | 5676 void RenderViewImpl::OnJavaBridgeInit() { |
| 5666 DCHECK(!java_bridge_dispatcher_); | 5677 DCHECK(!java_bridge_dispatcher_); |
| 5667 #if defined(ENABLE_JAVA_BRIDGE) | 5678 #if defined(ENABLE_JAVA_BRIDGE) |
| 5668 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); | 5679 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
| 5669 #endif | 5680 #endif |
| 5670 } | 5681 } |
| OLD | NEW |