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 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 PendingFileChooser(const content::FileChooserParams& p, | 440 PendingFileChooser(const content::FileChooserParams& p, |
| 441 WebFileChooserCompletion* c) | 441 WebFileChooserCompletion* c) |
| 442 : params(p), | 442 : params(p), |
| 443 completion(c) { | 443 completion(c) { |
| 444 } | 444 } |
| 445 content::FileChooserParams params; | 445 content::FileChooserParams params; |
| 446 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. | 446 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
| 447 }; | 447 }; |
| 448 | 448 |
| 449 namespace { | 449 namespace { |
| 450 | 450 |
|
scheib
2012/05/29 21:47:14
Consider moving to a new implementation file? rend
yzshen1
2012/05/30 06:41:30
Good point. Thanks!
On 2012/05/29 21:47:14, schei
| |
| 451 // RenderViewMouseLockDispatcher is owned by RenderViewImpl. | |
| 452 class RenderViewMouseLockDispatcher : public MouseLockDispatcher, | |
|
brettw
2012/05/29 21:27:10
Could you move this to a separate file for just th
yzshen1
2012/05/30 06:41:30
Done. Thanks!
On 2012/05/29 21:27:10, brettw wrot
| |
| 453 public content::RenderViewObserver { | |
| 454 public: | |
| 455 explicit RenderViewMouseLockDispatcher(RenderViewImpl* render_view_impl); | |
| 456 virtual ~RenderViewMouseLockDispatcher(); | |
| 457 | |
| 458 private: | |
| 459 // MouseLockDispatcher implementation. | |
| 460 virtual void SendLockMouseRequest() OVERRIDE; | |
| 461 virtual void SendUnlockMouseRequest() OVERRIDE; | |
| 462 | |
| 463 // RenderView::Observer implementation. | |
| 464 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 465 | |
| 466 void OnMsgLockMouseACK(bool succeeded); | |
| 467 | |
| 468 RenderViewImpl* render_view_impl_; | |
| 469 | |
| 470 DISALLOW_COPY_AND_ASSIGN(RenderViewMouseLockDispatcher); | |
| 471 }; | |
| 472 | |
| 473 RenderViewMouseLockDispatcher::RenderViewMouseLockDispatcher( | |
| 474 RenderViewImpl* render_view_impl) | |
| 475 : content::RenderViewObserver(render_view_impl), | |
| 476 render_view_impl_(render_view_impl) { | |
| 477 } | |
| 478 | |
| 479 RenderViewMouseLockDispatcher::~RenderViewMouseLockDispatcher() { | |
| 480 } | |
| 481 | |
| 482 void RenderViewMouseLockDispatcher::SendLockMouseRequest() { | |
| 483 bool user_gesture = | |
| 484 render_view_impl_->webview() && | |
| 485 render_view_impl_->webview()->mainFrame() && | |
| 486 render_view_impl_->webview()->mainFrame()->isProcessingUserGesture(); | |
| 487 | |
| 488 Send(new ViewHostMsg_LockMouse(routing_id(), user_gesture, false)); | |
| 489 } | |
| 490 | |
| 491 void RenderViewMouseLockDispatcher::SendUnlockMouseRequest() { | |
| 492 Send(new ViewHostMsg_UnlockMouse(routing_id())); | |
| 493 } | |
| 494 | |
| 495 bool RenderViewMouseLockDispatcher::OnMessageReceived( | |
| 496 const IPC::Message& message) { | |
| 497 bool handled = true; | |
| 498 IPC_BEGIN_MESSAGE_MAP(RenderViewMouseLockDispatcher, message) | |
| 499 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnMsgLockMouseACK) | |
| 500 IPC_MESSAGE_FORWARD(ViewMsg_MouseLockLost, | |
| 501 static_cast<MouseLockDispatcher*>(this), | |
| 502 MouseLockDispatcher::OnMouseLockLost) | |
| 503 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 504 IPC_END_MESSAGE_MAP() | |
| 505 return handled; | |
| 506 } | |
| 507 | |
| 508 void RenderViewMouseLockDispatcher::OnMsgLockMouseACK(bool succeeded) { | |
| 509 // Notify the base class. | |
| 510 OnLockMouseACK(succeeded); | |
| 511 | |
| 512 // Mouse Lock removes the system cursor and provides all mouse motion as | |
| 513 // .movementX/Y values on events all sent to a fixed target. This requires | |
| 514 // content to specifically request the mode to be entered. | |
| 515 // Mouse Capture is implicitly given for the duration of a drag event, and | |
| 516 // sends all mouse events to the initial target of the drag. | |
| 517 // If Lock is entered it supercedes any in progress Capture. | |
| 518 if (succeeded && render_view_impl_->webwidget()) | |
| 519 render_view_impl_->webwidget()->mouseCaptureLost(); | |
| 520 } | |
| 521 | |
| 451 class WebWidgetLockTarget : public MouseLockDispatcher::LockTarget { | 522 class WebWidgetLockTarget : public MouseLockDispatcher::LockTarget { |
| 452 public: | 523 public: |
| 453 explicit WebWidgetLockTarget(WebKit::WebWidget* webwidget) | 524 explicit WebWidgetLockTarget(WebKit::WebWidget* webwidget) |
| 454 : webwidget_(webwidget) {} | 525 : webwidget_(webwidget) {} |
| 455 | 526 |
| 456 virtual void OnLockMouseACK(bool succeeded) OVERRIDE { | 527 virtual void OnLockMouseACK(bool succeeded) OVERRIDE { |
| 457 if (succeeded) | 528 if (succeeded) |
| 458 webwidget_->didAcquirePointerLock(); | 529 webwidget_->didAcquirePointerLock(); |
| 459 else | 530 else |
| 460 webwidget_->didNotAcquirePointerLock(); | 531 webwidget_->didNotAcquirePointerLock(); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 | 683 |
| 613 new MHTMLGenerator(this); | 684 new MHTMLGenerator(this); |
| 614 #if defined(OS_MACOSX) | 685 #if defined(OS_MACOSX) |
| 615 new TextInputClientObserver(this); | 686 new TextInputClientObserver(this); |
| 616 #endif // defined(OS_MACOSX) | 687 #endif // defined(OS_MACOSX) |
| 617 | 688 |
| 618 // The next group of objects all implement RenderViewObserver, so are deleted | 689 // The next group of objects all implement RenderViewObserver, so are deleted |
| 619 // along with the RenderView automatically. | 690 // along with the RenderView automatically. |
| 620 devtools_agent_ = new DevToolsAgent(this); | 691 devtools_agent_ = new DevToolsAgent(this); |
| 621 renderer_accessibility_ = new RendererAccessibility(this, accessibility_mode); | 692 renderer_accessibility_ = new RendererAccessibility(this, accessibility_mode); |
| 622 mouse_lock_dispatcher_ = new MouseLockDispatcher(this); | 693 mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
| 623 intents_host_ = new WebIntentsHost(this); | 694 intents_host_ = new WebIntentsHost(this); |
| 624 | 695 |
| 625 new IdleUserDetector(this); | 696 new IdleUserDetector(this); |
| 626 | 697 |
| 627 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 698 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 628 if (command_line.HasSwitch(switches::kDomAutomationController)) | 699 if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 629 enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; | 700 enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; |
| 630 | 701 |
| 631 ProcessViewLayoutFlags(command_line); | 702 ProcessViewLayoutFlags(command_line); |
| 632 | 703 |
| (...skipping 4903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5536 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5607 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
| 5537 return !!RenderThreadImpl::current()->compositor_thread(); | 5608 return !!RenderThreadImpl::current()->compositor_thread(); |
| 5538 } | 5609 } |
| 5539 | 5610 |
| 5540 void RenderViewImpl::OnJavaBridgeInit() { | 5611 void RenderViewImpl::OnJavaBridgeInit() { |
| 5541 DCHECK(!java_bridge_dispatcher_); | 5612 DCHECK(!java_bridge_dispatcher_); |
| 5542 #if defined(ENABLE_JAVA_BRIDGE) | 5613 #if defined(ENABLE_JAVA_BRIDGE) |
| 5543 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); | 5614 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
| 5544 #endif | 5615 #endif |
| 5545 } | 5616 } |
| OLD | NEW |