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

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

Issue 12570005: Update user gesture related code to the new WebKit API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 9 months 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 | Annotate | Revision Log
OLDNEW
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" 175 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h"
176 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 176 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
177 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" 177 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
178 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" 178 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
179 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h" 179 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h"
180 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 180 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
181 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 181 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
182 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa lue.h" 182 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa lue.h"
183 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" 183 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
184 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h" 184 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h"
185 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserGestureIndicat or.h"
185 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" 186 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h"
186 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 187 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
187 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" 188 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h"
188 #include "third_party/WebKit/Source/WebKit/chromium/public/default/WebRenderThem e.h" 189 #include "third_party/WebKit/Source/WebKit/chromium/public/default/WebRenderThem e.h"
189 #include "ui/base/ui_base_switches.h" 190 #include "ui/base/ui_base_switches.h"
190 #include "ui/gfx/native_widget_types.h" 191 #include "ui/gfx/native_widget_types.h"
191 #include "ui/gfx/point.h" 192 #include "ui/gfx/point.h"
192 #include "ui/gfx/rect.h" 193 #include "ui/gfx/rect.h"
193 #include "ui/gfx/rect_conversions.h" 194 #include "ui/gfx/rect_conversions.h"
194 #include "ui/gfx/size_conversions.h" 195 #include "ui/gfx/size_conversions.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 using WebKit::WebStorageQuotaError; 317 using WebKit::WebStorageQuotaError;
317 using WebKit::WebStorageQuotaType; 318 using WebKit::WebStorageQuotaType;
318 using WebKit::WebString; 319 using WebKit::WebString;
319 using WebKit::WebTextAffinity; 320 using WebKit::WebTextAffinity;
320 using WebKit::WebTextDirection; 321 using WebKit::WebTextDirection;
321 using WebKit::WebTouchEvent; 322 using WebKit::WebTouchEvent;
322 using WebKit::WebURL; 323 using WebKit::WebURL;
323 using WebKit::WebURLError; 324 using WebKit::WebURLError;
324 using WebKit::WebURLRequest; 325 using WebKit::WebURLRequest;
325 using WebKit::WebURLResponse; 326 using WebKit::WebURLResponse;
327 using WebKit::WebUserGestureIndicator;
326 using WebKit::WebVector; 328 using WebKit::WebVector;
327 using WebKit::WebView; 329 using WebKit::WebView;
328 using WebKit::WebWidget; 330 using WebKit::WebWidget;
329 using WebKit::WebWindowFeatures; 331 using WebKit::WebWindowFeatures;
330 using appcache::WebApplicationCacheHostImpl; 332 using appcache::WebApplicationCacheHostImpl;
331 using base::Time; 333 using base::Time;
332 using base::TimeDelta; 334 using base::TimeDelta;
333 335
334 using webkit_glue::AltErrorPageResourceFetcher; 336 using webkit_glue::AltErrorPageResourceFetcher;
335 using webkit_glue::ResourceFetcher; 337 using webkit_glue::ResourceFetcher;
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 const WebURLRequest& request, 1915 const WebURLRequest& request,
1914 const WebWindowFeatures& features, 1916 const WebWindowFeatures& features,
1915 const WebString& frame_name, 1917 const WebString& frame_name,
1916 WebNavigationPolicy policy) { 1918 WebNavigationPolicy policy) {
1917 // Check to make sure we aren't overloading on popups. 1919 // Check to make sure we aren't overloading on popups.
1918 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) 1920 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups)
1919 return NULL; 1921 return NULL;
1920 1922
1921 ViewHostMsg_CreateWindow_Params params; 1923 ViewHostMsg_CreateWindow_Params params;
1922 params.opener_id = routing_id_; 1924 params.opener_id = routing_id_;
1923 params.user_gesture = creator->isProcessingUserGesture(); 1925 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
1924 params.window_container_type = WindowFeaturesToContainerType(features); 1926 params.window_container_type = WindowFeaturesToContainerType(features);
1925 params.session_storage_namespace_id = session_storage_namespace_id_; 1927 params.session_storage_namespace_id = session_storage_namespace_id_;
1926 if (frame_name != "_blank") 1928 if (frame_name != "_blank")
1927 params.frame_name = frame_name; 1929 params.frame_name = frame_name;
1928 params.opener_frame_id = creator->identifier(); 1930 params.opener_frame_id = creator->identifier();
1929 params.opener_url = creator->document().url(); 1931 params.opener_url = creator->document().url();
1930 GURL security_url(creator->document().securityOrigin().toString().utf8()); 1932 GURL security_url(creator->document().securityOrigin().toString().utf8());
1931 if (!security_url.is_valid()) 1933 if (!security_url.is_valid())
1932 security_url = GURL(); 1934 security_url = GURL();
1933 params.opener_security_origin = security_url; 1935 params.opener_security_origin = security_url;
1934 params.opener_suppressed = creator->willSuppressOpenerInNewFrame(); 1936 params.opener_suppressed = creator->willSuppressOpenerInNewFrame();
1935 params.disposition = NavigationPolicyToDisposition(policy); 1937 params.disposition = NavigationPolicyToDisposition(policy);
1936 if (!request.isNull()) 1938 if (!request.isNull())
1937 params.target_url = request.url(); 1939 params.target_url = request.url();
1938 1940
1939 int32 routing_id = MSG_ROUTING_NONE; 1941 int32 routing_id = MSG_ROUTING_NONE;
1940 int32 surface_id = 0; 1942 int32 surface_id = 0;
1941 int64 cloned_session_storage_namespace_id; 1943 int64 cloned_session_storage_namespace_id;
1942 1944
1943 RenderThread::Get()->Send( 1945 RenderThread::Get()->Send(
1944 new ViewHostMsg_CreateWindow(params, 1946 new ViewHostMsg_CreateWindow(params,
1945 &routing_id, 1947 &routing_id,
1946 &surface_id, 1948 &surface_id,
1947 &cloned_session_storage_namespace_id)); 1949 &cloned_session_storage_namespace_id));
1948 if (routing_id == MSG_ROUTING_NONE) 1950 if (routing_id == MSG_ROUTING_NONE)
1949 return NULL; 1951 return NULL;
1950 1952
1951 creator->consumeUserGesture(); 1953 WebUserGestureIndicator::consumeUserGesture();
1952 1954
1953 RenderViewImpl* view = RenderViewImpl::Create( 1955 RenderViewImpl* view = RenderViewImpl::Create(
1954 routing_id_, 1956 routing_id_,
1955 renderer_preferences_, 1957 renderer_preferences_,
1956 webkit_preferences_, 1958 webkit_preferences_,
1957 shared_popup_counter_, 1959 shared_popup_counter_,
1958 routing_id, 1960 routing_id,
1959 surface_id, 1961 surface_id,
1960 cloned_session_storage_namespace_id, 1962 cloned_session_storage_namespace_id,
1961 string16(), // WebCore will take care of setting the correct name. 1963 string16(), // WebCore will take care of setting the correct name.
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 key.utf8(), 2523 key.utf8(),
2522 value.utf8())); 2524 value.utf8()));
2523 } 2525 }
2524 2526
2525 // WebKit::WebWidgetClient ---------------------------------------------------- 2527 // WebKit::WebWidgetClient ----------------------------------------------------
2526 2528
2527 void RenderViewImpl::didFocus() { 2529 void RenderViewImpl::didFocus() {
2528 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed 2530 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed
2529 // we won't have to test for user gesture anymore and we can 2531 // we won't have to test for user gesture anymore and we can
2530 // move that code back to render_widget.cc 2532 // move that code back to render_widget.cc
2531 if (webview() && webview()->mainFrame() && 2533 if (WebUserGestureIndicator::isProcessingUserGesture() &&
2532 webview()->mainFrame()->isProcessingUserGesture() &&
2533 RenderThreadImpl::current()->should_send_focus_ipcs()) { 2534 RenderThreadImpl::current()->should_send_focus_ipcs()) {
2534 Send(new ViewHostMsg_Focus(routing_id_)); 2535 Send(new ViewHostMsg_Focus(routing_id_));
2535 } 2536 }
2536 } 2537 }
2537 2538
2538 void RenderViewImpl::didBlur() { 2539 void RenderViewImpl::didBlur() {
2539 // TODO(jcivelli): see TODO above in didFocus(). 2540 // TODO(jcivelli): see TODO above in didFocus().
2540 if (webview() && webview()->mainFrame() && 2541 if (WebUserGestureIndicator::isProcessingUserGesture() &&
2541 webview()->mainFrame()->isProcessingUserGesture() &&
2542 RenderThreadImpl::current()->should_send_focus_ipcs()) { 2542 RenderThreadImpl::current()->should_send_focus_ipcs()) {
2543 Send(new ViewHostMsg_Blur(routing_id_)); 2543 Send(new ViewHostMsg_Blur(routing_id_));
2544 } 2544 }
2545 } 2545 }
2546 2546
2547 // 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
2548 // that was created via RenderViewImpl::CreateWebView. So, we wait until this 2548 // that was created via RenderViewImpl::CreateWebView. So, we wait until this
2549 // point to dispatch the ShowView message. 2549 // point to dispatch the ShowView message.
2550 // 2550 //
2551 // 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
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
3423 double event_time = ds->triggeringEventTime(); 3423 double event_time = ds->triggeringEventTime();
3424 if (event_time != 0.0) 3424 if (event_time != 0.0)
3425 document_state->set_request_time(Time::FromDoubleT(event_time)); 3425 document_state->set_request_time(Time::FromDoubleT(event_time));
3426 } 3426 }
3427 3427
3428 // Start time is only set after request time. 3428 // Start time is only set after request time.
3429 document_state->set_start_load_time(Time::Now()); 3429 document_state->set_start_load_time(Time::Now());
3430 3430
3431 bool is_top_most = !frame->parent(); 3431 bool is_top_most = !frame->parent();
3432 if (is_top_most) { 3432 if (is_top_most) {
3433 navigation_gesture_ = frame->isProcessingUserGesture() ? 3433 navigation_gesture_ = WebUserGestureIndicator::isProcessingUserGesture() ?
3434 NavigationGestureUser : NavigationGestureAuto; 3434 NavigationGestureUser : NavigationGestureAuto;
3435 3435
3436 // Make sure redirect tracking state is clear for the new load. 3436 // Make sure redirect tracking state is clear for the new load.
3437 completed_client_redirect_src_ = Referrer(); 3437 completed_client_redirect_src_ = Referrer();
3438 } else if (frame->parent()->isLoading()) { 3438 } else if (frame->parent()->isLoading()) {
3439 // Take note of AUTO_SUBFRAME loads here, so that we can know how to 3439 // Take note of AUTO_SUBFRAME loads here, so that we can know how to
3440 // load an error page. See didFailProvisionalLoad. 3440 // load an error page. See didFailProvisionalLoad.
3441 document_state->navigation_state()->set_transition_type( 3441 document_state->navigation_state()->set_transition_type(
3442 PAGE_TRANSITION_AUTO_SUBFRAME); 3442 PAGE_TRANSITION_AUTO_SUBFRAME);
3443 } 3443 }
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3858 3858
3859 DocumentState* top_document_state = 3859 DocumentState* top_document_state =
3860 DocumentState::FromDataSource(top_data_source); 3860 DocumentState::FromDataSource(top_data_source);
3861 // TODO(gavinp): separate out prefetching and prerender field trials 3861 // TODO(gavinp): separate out prefetching and prerender field trials
3862 // if the rel=prerender rel type is sticking around. 3862 // if the rel=prerender rel type is sticking around.
3863 if (top_document_state && 3863 if (top_document_state &&
3864 request.targetType() == WebURLRequest::TargetIsPrefetch) 3864 request.targetType() == WebURLRequest::TargetIsPrefetch)
3865 top_document_state->set_was_prefetcher(true); 3865 top_document_state->set_was_prefetcher(true);
3866 3866
3867 request.setRequestorID(routing_id_); 3867 request.setRequestorID(routing_id_);
3868 request.setHasUserGesture(frame->isProcessingUserGesture()); 3868 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture());
3869 3869
3870 if (!renderer_preferences_.enable_referrers) 3870 if (!renderer_preferences_.enable_referrers)
3871 request.clearHTTPHeaderField("Referer"); 3871 request.clearHTTPHeaderField("Referer");
3872 } 3872 }
3873 3873
3874 void RenderViewImpl::didReceiveResponse( 3874 void RenderViewImpl::didReceiveResponse(
3875 WebFrame* frame, unsigned identifier, const WebURLResponse& response) { 3875 WebFrame* frame, unsigned identifier, const WebURLResponse& response) {
3876 3876
3877 // Only do this for responses that correspond to a provisional data source 3877 // Only do this for responses that correspond to a provisional data source
3878 // of the top-most frame. If we have a provisional data source, then we 3878 // of the top-most frame. If we have a provisional data source, then we
(...skipping 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after
6455 // saved values if necessary 6455 // saved values if necessary
6456 Send(new ViewHostMsg_DidZoomURL( 6456 Send(new ViewHostMsg_DidZoomURL(
6457 routing_id_, zoom_level, remember, 6457 routing_id_, zoom_level, remember,
6458 GURL(webview()->mainFrame()->document().url()))); 6458 GURL(webview()->mainFrame()->document().url())));
6459 } 6459 }
6460 6460
6461 void RenderViewImpl::registerProtocolHandler(const WebString& scheme, 6461 void RenderViewImpl::registerProtocolHandler(const WebString& scheme,
6462 const WebString& base_url, 6462 const WebString& base_url,
6463 const WebString& url, 6463 const WebString& url,
6464 const WebString& title) { 6464 const WebString& title) {
6465 bool user_gesture = (webview()->focusedFrame() && 6465 bool user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
6466 webview()->focusedFrame()->isProcessingUserGesture());
6467 GURL base(base_url); 6466 GURL base(base_url);
6468 GURL absolute_url = base.Resolve(UTF16ToUTF8(url)); 6467 GURL absolute_url = base.Resolve(UTF16ToUTF8(url));
6469 if (base.GetOrigin() != absolute_url.GetOrigin()) { 6468 if (base.GetOrigin() != absolute_url.GetOrigin()) {
6470 return; 6469 return;
6471 } 6470 }
6472 Send(new ViewHostMsg_RegisterProtocolHandler(routing_id_, 6471 Send(new ViewHostMsg_RegisterProtocolHandler(routing_id_,
6473 UTF16ToUTF8(scheme), 6472 UTF16ToUTF8(scheme),
6474 absolute_url, 6473 absolute_url,
6475 title, 6474 title,
6476 user_gesture)); 6475 user_gesture));
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
6754 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); 6753 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle);
6755 RenderProcess::current()->ReleaseTransportDIB(dib); 6754 RenderProcess::current()->ReleaseTransportDIB(dib);
6756 } 6755 }
6757 6756
6758 void RenderViewImpl::DidCommitCompositorFrame() { 6757 void RenderViewImpl::DidCommitCompositorFrame() {
6759 RenderWidget::DidCommitCompositorFrame(); 6758 RenderWidget::DidCommitCompositorFrame();
6760 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); 6759 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame());
6761 } 6760 }
6762 6761
6763 } // namespace content 6762 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/notification_provider.cc ('k') | content/renderer/render_view_mouse_lock_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698