Chromium Code Reviews| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 | 374 |
| 375 #if defined(OS_ANDROID) | 375 #if defined(OS_ANDROID) |
| 376 // Delay between tapping in content and launching the associated android intent. | 376 // Delay between tapping in content and launching the associated android intent. |
| 377 // Used to allow users see what has been recognized as content. | 377 // Used to allow users see what has been recognized as content. |
| 378 static const size_t kContentIntentDelayMilliseconds = 700; | 378 static const size_t kContentIntentDelayMilliseconds = 700; |
| 379 #endif | 379 #endif |
| 380 | 380 |
| 381 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = | 381 static RenderViewImpl* (*g_create_render_view_impl)(RenderViewImplParams*) = |
| 382 NULL; | 382 NULL; |
| 383 | 383 |
| 384 static bool g_require_user_gesture_for_focus = true; | |
|
piman
2013/02/26 21:11:35
nit: could we move this to RenderThreadImpl to avo
jochen (gone - plz use gerrit)
2013/02/27 16:24:14
Done.
| |
| 385 | |
| 384 static WebKit::WebFrame* FindFrameByID(WebKit::WebFrame* root, int frame_id) { | 386 static WebKit::WebFrame* FindFrameByID(WebKit::WebFrame* root, int frame_id) { |
| 385 for (WebFrame* frame = root; frame; frame = frame->traverseNext(false)) { | 387 for (WebFrame* frame = root; frame; frame = frame->traverseNext(false)) { |
| 386 if (frame->identifier() == frame_id) | 388 if (frame->identifier() == frame_id) |
| 387 return frame; | 389 return frame; |
| 388 } | 390 } |
| 389 return NULL; | 391 return NULL; |
| 390 } | 392 } |
| 391 | 393 |
| 392 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 394 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 393 // Replace any occurrences of swappedout:// with about:blank. | 395 // Replace any occurrences of swappedout:// with about:blank. |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 return render_view; | 916 return render_view; |
| 915 } | 917 } |
| 916 | 918 |
| 917 // static | 919 // static |
| 918 void RenderViewImpl::InstallCreateHook( | 920 void RenderViewImpl::InstallCreateHook( |
| 919 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) { | 921 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*)) { |
| 920 CHECK(!g_create_render_view_impl); | 922 CHECK(!g_create_render_view_impl); |
| 921 g_create_render_view_impl = create_render_view_impl; | 923 g_create_render_view_impl = create_render_view_impl; |
| 922 } | 924 } |
| 923 | 925 |
| 926 // static | |
| 927 void RenderViewImpl::DoNotRequireUserGestureForFocusChangesForTesting() { | |
| 928 g_require_user_gesture_for_focus = false; | |
| 929 } | |
| 930 | |
| 924 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { | 931 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
| 925 observers_.AddObserver(observer); | 932 observers_.AddObserver(observer); |
| 926 } | 933 } |
| 927 | 934 |
| 928 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { | 935 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 929 observer->RenderViewGone(); | 936 observer->RenderViewGone(); |
| 930 observers_.RemoveObserver(observer); | 937 observers_.RemoveObserver(observer); |
| 931 } | 938 } |
| 932 | 939 |
| 933 WebKit::WebView* RenderViewImpl::webview() const { | 940 WebKit::WebView* RenderViewImpl::webview() const { |
| (...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2512 key.utf8(), | 2519 key.utf8(), |
| 2513 value.utf8())); | 2520 value.utf8())); |
| 2514 } | 2521 } |
| 2515 | 2522 |
| 2516 // WebKit::WebWidgetClient ---------------------------------------------------- | 2523 // WebKit::WebWidgetClient ---------------------------------------------------- |
| 2517 | 2524 |
| 2518 void RenderViewImpl::didFocus() { | 2525 void RenderViewImpl::didFocus() { |
| 2519 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed | 2526 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 2520 // we won't have to test for user gesture anymore and we can | 2527 // we won't have to test for user gesture anymore and we can |
| 2521 // move that code back to render_widget.cc | 2528 // move that code back to render_widget.cc |
| 2522 if (webview() && webview()->mainFrame() && | 2529 if (webview() && webview()->mainFrame()) { |
| 2523 webview()->mainFrame()->isProcessingUserGesture()) { | 2530 if (webview()->mainFrame()->isProcessingUserGesture() || |
| 2524 Send(new ViewHostMsg_Focus(routing_id_)); | 2531 !g_require_user_gesture_for_focus) { |
| 2532 Send(new ViewHostMsg_Focus(routing_id_)); | |
| 2533 } | |
| 2525 } | 2534 } |
| 2526 } | 2535 } |
| 2527 | 2536 |
| 2528 void RenderViewImpl::didBlur() { | 2537 void RenderViewImpl::didBlur() { |
| 2529 // TODO(jcivelli): see TODO above in didFocus(). | 2538 // TODO(jcivelli): see TODO above in didFocus(). |
| 2530 if (webview() && webview()->mainFrame() && | 2539 if (webview() && webview()->mainFrame()) { |
| 2531 webview()->mainFrame()->isProcessingUserGesture()) { | 2540 if (webview()->mainFrame()->isProcessingUserGesture() || |
| 2532 Send(new ViewHostMsg_Blur(routing_id_)); | 2541 !g_require_user_gesture_for_focus) { |
| 2542 Send(new ViewHostMsg_Blur(routing_id_)); | |
| 2543 } | |
| 2533 } | 2544 } |
| 2534 } | 2545 } |
| 2535 | 2546 |
| 2536 // We are supposed to get a single call to Show for a newly created RenderView | 2547 // We are supposed to get a single call to Show for a newly created RenderView |
| 2537 // that was created via RenderViewImpl::CreateWebView. So, we wait until this | 2548 // that was created via RenderViewImpl::CreateWebView. So, we wait until this |
| 2538 // point to dispatch the ShowView message. | 2549 // point to dispatch the ShowView message. |
| 2539 // | 2550 // |
| 2540 // This method provides us with the information about how to display the newly | 2551 // This method provides us with the information about how to display the newly |
| 2541 // created RenderView (i.e., as a blocked popup or as a new tab). | 2552 // created RenderView (i.e., as a blocked popup or as a new tab). |
| 2542 // | 2553 // |
| (...skipping 4163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6706 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6717 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
| 6707 RenderProcess::current()->ReleaseTransportDIB(dib); | 6718 RenderProcess::current()->ReleaseTransportDIB(dib); |
| 6708 } | 6719 } |
| 6709 | 6720 |
| 6710 void RenderViewImpl::DidCommitCompositorFrame() { | 6721 void RenderViewImpl::DidCommitCompositorFrame() { |
| 6711 RenderWidget::DidCommitCompositorFrame(); | 6722 RenderWidget::DidCommitCompositorFrame(); |
| 6712 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); | 6723 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); |
| 6713 } | 6724 } |
| 6714 | 6725 |
| 6715 } // namespace content | 6726 } // namespace content |
| OLD | NEW |