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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 235983016: Add support for setting password value gated on user's gesture in a page (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: OVERRIDE added Created 6 years, 8 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 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent:: ShiftKey; 232 platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent:: ShiftKey;
233 if (webInputEventKeyState & WebInputEvent::ControlKey) 233 if (webInputEventKeyState & WebInputEvent::ControlKey)
234 platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent:: CtrlKey; 234 platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent:: CtrlKey;
235 if (webInputEventKeyState & WebInputEvent::AltKey) 235 if (webInputEventKeyState & WebInputEvent::AltKey)
236 platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent:: AltKey; 236 platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent:: AltKey;
237 if (webInputEventKeyState & WebInputEvent::MetaKey) 237 if (webInputEventKeyState & WebInputEvent::MetaKey)
238 platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent:: MetaKey; 238 platformEventKeyState = platformEventKeyState | WebCore::PlatformEvent:: MetaKey;
239 return platformEventKeyState; 239 return platformEventKeyState;
240 } 240 }
241 241
242 namespace {
243
244 class UserGestureNotifier {
245 public:
246 // If a UserGestureIndicator is created for a user gesture during the
247 // lifetime of a UserGestureNotifier and *userGestureObserved is false,
248 // the object will notify the client and set *userGestureObserved to true.
249 UserGestureNotifier(WebAutofillClient*, bool* userGestureObserved);
250 ~UserGestureNotifier();
251
252 private:
253 WebAutofillClient* const m_client;
254 bool* const m_userGestureObserved;
255 };
256
257 UserGestureNotifier::UserGestureNotifier(WebAutofillClient* client, bool* userGe stureObserved)
258 : m_client(client)
259 , m_userGestureObserved(userGestureObserved)
260 {
261 ASSERT(m_userGestureObserved);
262 if (m_client)
263 UserGestureIndicator::clearProcessedUserGestureInPast();
264 }
265
266 UserGestureNotifier::~UserGestureNotifier()
267 {
268 if (!*m_userGestureObserved && UserGestureIndicator::processedUserGestureInP ast()) {
269 *m_userGestureObserved = true;
270 if (m_client)
271 m_client->firstUserGestureObserved();
272 }
273 }
274
275 } // namespace
276
242 // WebView ---------------------------------------------------------------- 277 // WebView ----------------------------------------------------------------
243 278
244 WebView* WebView::create(WebViewClient* client) 279 WebView* WebView::create(WebViewClient* client)
245 { 280 {
246 // Pass the WebViewImpl's self-reference to the caller. 281 // Pass the WebViewImpl's self-reference to the caller.
247 return WebViewImpl::create(client); 282 return WebViewImpl::create(client);
248 } 283 }
249 284
250 WebViewImpl* WebViewImpl::create(WebViewClient* client) 285 WebViewImpl* WebViewImpl::create(WebViewClient* client)
251 { 286 {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 , m_flingSourceDevice(false) 400 , m_flingSourceDevice(false)
366 , m_fullscreenController(FullscreenController::create(this)) 401 , m_fullscreenController(FullscreenController::create(this))
367 , m_showFPSCounter(false) 402 , m_showFPSCounter(false)
368 , m_showPaintRects(false) 403 , m_showPaintRects(false)
369 , m_showDebugBorders(false) 404 , m_showDebugBorders(false)
370 , m_continuousPaintingEnabled(false) 405 , m_continuousPaintingEnabled(false)
371 , m_showScrollBottleneckRects(false) 406 , m_showScrollBottleneckRects(false)
372 , m_baseBackgroundColor(Color::white) 407 , m_baseBackgroundColor(Color::white)
373 , m_backgroundColorOverride(Color::transparent) 408 , m_backgroundColorOverride(Color::transparent)
374 , m_zoomFactorOverride(0) 409 , m_zoomFactorOverride(0)
410 , m_userGestureObserved(false)
375 { 411 {
376 Page::PageClients pageClients; 412 Page::PageClients pageClients;
377 pageClients.chromeClient = &m_chromeClientImpl; 413 pageClients.chromeClient = &m_chromeClientImpl;
378 pageClients.contextMenuClient = &m_contextMenuClientImpl; 414 pageClients.contextMenuClient = &m_contextMenuClientImpl;
379 pageClients.editorClient = &m_editorClientImpl; 415 pageClients.editorClient = &m_editorClientImpl;
380 pageClients.dragClient = &m_dragClientImpl; 416 pageClients.dragClient = &m_dragClientImpl;
381 pageClients.inspectorClient = &m_inspectorClientImpl; 417 pageClients.inspectorClient = &m_inspectorClientImpl;
382 pageClients.backForwardClient = &m_backForwardClientImpl; 418 pageClients.backForwardClient = &m_backForwardClientImpl;
383 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; 419 pageClients.spellCheckerClient = &m_spellCheckerClientImpl;
384 pageClients.storageClient = &m_storageClientImpl; 420 pageClients.storageClient = &m_storageClientImpl;
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 1832
1797 bool WebViewImpl::hasVerticalScrollbar() 1833 bool WebViewImpl::hasVerticalScrollbar()
1798 { 1834 {
1799 return mainFrameImpl()->frameView()->verticalScrollbar(); 1835 return mainFrameImpl()->frameView()->verticalScrollbar();
1800 } 1836 }
1801 1837
1802 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0; 1838 const WebInputEvent* WebViewImpl::m_currentInputEvent = 0;
1803 1839
1804 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent) 1840 bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
1805 { 1841 {
1842 UserGestureNotifier notifier(m_autofillClient, &m_userGestureObserved);
1843
1806 TRACE_EVENT0("input", "WebViewImpl::handleInputEvent"); 1844 TRACE_EVENT0("input", "WebViewImpl::handleInputEvent");
1807 // If we've started a drag and drop operation, ignore input events until 1845 // If we've started a drag and drop operation, ignore input events until
1808 // we're done. 1846 // we're done.
1809 if (m_doingDragAndDrop) 1847 if (m_doingDragAndDrop)
1810 return true; 1848 return true;
1811 1849
1812 if (m_devToolsAgent && m_devToolsAgent->handleInputEvent(m_page.get(), input Event)) 1850 if (m_devToolsAgent && m_devToolsAgent->handleInputEvent(m_page.get(), input Event))
1813 return true; 1851 return true;
1814 1852
1815 // Report the event to be NOT processed by WebKit, so that the browser can h andle it appropriately. 1853 // Report the event to be NOT processed by WebKit, so that the browser can h andle it appropriately.
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
3127 m_dragOperation = WebDragOperationNone; 3165 m_dragOperation = WebDragOperationNone;
3128 m_currentDragData = nullptr; 3166 m_currentDragData = nullptr;
3129 } 3167 }
3130 3168
3131 void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint, 3169 void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
3132 const WebPoint& screenPoint, 3170 const WebPoint& screenPoint,
3133 int keyModifiers) 3171 int keyModifiers)
3134 { 3172 {
3135 ASSERT(m_currentDragData); 3173 ASSERT(m_currentDragData);
3136 3174
3175 UserGestureNotifier notifier(m_autofillClient, &m_userGestureObserved);
3176
3137 // If this webview transitions from the "drop accepting" state to the "not 3177 // If this webview transitions from the "drop accepting" state to the "not
3138 // accepting" state, then our IPC message reply indicating that may be in- 3178 // accepting" state, then our IPC message reply indicating that may be in-
3139 // flight, or else delayed by javascript processing in this webview. If a 3179 // flight, or else delayed by javascript processing in this webview. If a
3140 // drop happens before our IPC reply has reached the browser process, then 3180 // drop happens before our IPC reply has reached the browser process, then
3141 // the browser forwards the drop to this webview. So only allow a drop to 3181 // the browser forwards the drop to this webview. So only allow a drop to
3142 // proceed if our webview m_dragOperation state is not DragOperationNone. 3182 // proceed if our webview m_dragOperation state is not DragOperationNone.
3143 3183
3144 if (m_dragOperation == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop. 3184 if (m_dragOperation == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop.
3145 dragTargetDragLeave(); 3185 dragTargetDragLeave();
3146 return; 3186 return;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 3483
3444 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag e) 3484 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag e)
3445 { 3485 {
3446 if (isNewNavigation && !isNavigationWithinPage) 3486 if (isNewNavigation && !isNavigationWithinPage)
3447 m_pageScaleConstraintsSet.setNeedsReset(true); 3487 m_pageScaleConstraintsSet.setNeedsReset(true);
3448 3488
3449 // Make sure link highlight from previous page is cleared. 3489 // Make sure link highlight from previous page is cleared.
3450 m_linkHighlights.clear(); 3490 m_linkHighlights.clear();
3451 endActiveFlingAnimation(); 3491 endActiveFlingAnimation();
3452 resetSavedScrollAndScaleState(); 3492 resetSavedScrollAndScaleState();
3493 m_userGestureObserved = false;
3453 } 3494 }
3454 3495
3455 void WebViewImpl::willInsertBody(WebFrameImpl* webframe) 3496 void WebViewImpl::willInsertBody(WebFrameImpl* webframe)
3456 { 3497 {
3457 if (webframe != mainFrameImpl()) 3498 if (webframe != mainFrameImpl())
3458 return; 3499 return;
3459 3500
3460 // If we get to the <body> tag and we have no pending stylesheet and import load, we 3501 // If we get to the <body> tag and we have no pending stylesheet and import load, we
3461 // can be fairly confident we'll have something sensible to paint soon and 3502 // can be fairly confident we'll have something sensible to paint soon and
3462 // can turn off deferred commits. 3503 // can turn off deferred commits.
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
4002 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4043 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4003 4044
4004 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4045 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4005 return false; 4046 return false;
4006 4047
4007 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4048 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4008 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4049 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4009 } 4050 }
4010 4051
4011 } // namespace blink 4052 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698