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

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 628213003: Replace OVERRIDE and FINAL with override and final in content/browser/web_contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void stop_forwarding_events() { forward_events_ = false; } 144 void stop_forwarding_events() { forward_events_ = false; }
145 145
146 private: 146 private:
147 virtual ~OverscrollWindowDelegate() {} 147 virtual ~OverscrollWindowDelegate() {}
148 148
149 aura::Window* web_contents_window() { 149 aura::Window* web_contents_window() {
150 return web_contents_->GetView()->GetContentNativeView(); 150 return web_contents_->GetView()->GetContentNativeView();
151 } 151 }
152 152
153 // Overridden from ui::EventHandler. 153 // Overridden from ui::EventHandler.
154 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE { 154 virtual void OnScrollEvent(ui::ScrollEvent* event) override {
155 if (forward_events_ && web_contents_window()) 155 if (forward_events_ && web_contents_window())
156 web_contents_window()->delegate()->OnScrollEvent(event); 156 web_contents_window()->delegate()->OnScrollEvent(event);
157 } 157 }
158 158
159 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { 159 virtual void OnGestureEvent(ui::GestureEvent* event) override {
160 if (forward_events_ && web_contents_window()) 160 if (forward_events_ && web_contents_window())
161 web_contents_window()->delegate()->OnGestureEvent(event); 161 web_contents_window()->delegate()->OnGestureEvent(event);
162 } 162 }
163 163
164 WebContentsImpl* web_contents_; 164 WebContentsImpl* web_contents_;
165 165
166 // The window is displayed both during the gesture, and after the gesture 166 // The window is displayed both during the gesture, and after the gesture
167 // while the navigation is in progress. During the gesture, it is necessary to 167 // while the navigation is in progress. During the gesture, it is necessary to
168 // forward input events to the content page (e.g. when the overscroll window 168 // forward input events to the content page (e.g. when the overscroll window
169 // slides under the cursor and starts receiving scroll events). However, once 169 // slides under the cursor and starts receiving scroll events). However, once
(...skipping 15 matching lines...) Expand all
185 NOTIFICATION_WEB_CONTENTS_DISCONNECTED, 185 NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
186 Source<WebContents>(contents)); 186 Source<WebContents>(contents));
187 } 187 }
188 188
189 virtual ~WebDragSourceAura() { 189 virtual ~WebDragSourceAura() {
190 } 190 }
191 191
192 // NotificationObserver: 192 // NotificationObserver:
193 virtual void Observe(int type, 193 virtual void Observe(int type,
194 const NotificationSource& source, 194 const NotificationSource& source,
195 const NotificationDetails& details) OVERRIDE { 195 const NotificationDetails& details) override {
196 if (type != NOTIFICATION_WEB_CONTENTS_DISCONNECTED) 196 if (type != NOTIFICATION_WEB_CONTENTS_DISCONNECTED)
197 return; 197 return;
198 198
199 // Cancel the drag if it is still in progress. 199 // Cancel the drag if it is still in progress.
200 aura::client::DragDropClient* dnd_client = 200 aura::client::DragDropClient* dnd_client =
201 aura::client::GetDragDropClient(window_->GetRootWindow()); 201 aura::client::GetDragDropClient(window_->GetRootWindow());
202 if (dnd_client && dnd_client->IsDragDropInProgress()) 202 if (dnd_client && dnd_client->IsDragDropInProgress())
203 dnd_client->DragCancel(); 203 dnd_client->DragCancel();
204 204
205 window_ = NULL; 205 window_ = NULL;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 root_window->RemoveObserver(this); 497 root_window->RemoveObserver(this);
498 const aura::Window::Windows& root_children = root_window->children(); 498 const aura::Window::Windows& root_children = root_window->children();
499 for (size_t i = 0; i < root_children.size(); ++i) 499 for (size_t i = 0; i < root_children.size(); ++i)
500 root_children[i]->RemoveObserver(this); 500 root_children[i]->RemoveObserver(this);
501 } 501 }
502 #endif 502 #endif
503 } 503 }
504 504
505 // Overridden from aura::WindowObserver: 505 // Overridden from aura::WindowObserver:
506 virtual void OnWindowHierarchyChanged( 506 virtual void OnWindowHierarchyChanged(
507 const aura::WindowObserver::HierarchyChangeParams& params) OVERRIDE { 507 const aura::WindowObserver::HierarchyChangeParams& params) override {
508 if (params.receiver != view_->window_.get() || 508 if (params.receiver != view_->window_.get() ||
509 !params.target->Contains(view_->window_.get())) { 509 !params.target->Contains(view_->window_.get())) {
510 return; 510 return;
511 } 511 }
512 512
513 // Use the new parent's root window for calculating HiDPI subpixel offset. 513 // Use the new parent's root window for calculating HiDPI subpixel offset.
514 RenderWidgetHostViewAura* rwhv = ToRenderWidgetHostViewAura( 514 RenderWidgetHostViewAura* rwhv = ToRenderWidgetHostViewAura(
515 view_->web_contents_->GetRenderWidgetHostView()); 515 view_->web_contents_->GetRenderWidgetHostView());
516 if (rwhv) 516 if (rwhv)
517 rwhv->SnapToPhysicalPixelBoundary(); 517 rwhv->SnapToPhysicalPixelBoundary();
518 } 518 }
519 519
520 #if defined(OS_WIN) 520 #if defined(OS_WIN)
521 // Constrained windows are added as children of the parent's parent's view 521 // Constrained windows are added as children of the parent's parent's view
522 // which may overlap with windowed NPAPI plugins. In that case, tell the RWHV 522 // which may overlap with windowed NPAPI plugins. In that case, tell the RWHV
523 // so that it can update the plugins' cutout rects accordingly. 523 // so that it can update the plugins' cutout rects accordingly.
524 // Note: this is hard coding how Chrome layer adds its dialogs. Since NPAPI is 524 // Note: this is hard coding how Chrome layer adds its dialogs. Since NPAPI is
525 // going to be deprecated in a year, this is ok for now. The test for this is 525 // going to be deprecated in a year, this is ok for now. The test for this is
526 // PrintPreviewTest.WindowedNPAPIPluginHidden. 526 // PrintPreviewTest.WindowedNPAPIPluginHidden.
527 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE { 527 virtual void OnWindowAdded(aura::Window* new_window) override {
528 if (!new_window->Contains(view_->window_.get())) { 528 if (!new_window->Contains(view_->window_.get())) {
529 // Skip the case when the parent moves to the root window. 529 // Skip the case when the parent moves to the root window.
530 if (new_window != host_window_) { 530 if (new_window != host_window_) {
531 // Observe sibling windows of the WebContents, or children of the root 531 // Observe sibling windows of the WebContents, or children of the root
532 // window. 532 // window.
533 if (new_window->parent() == host_window_ || 533 if (new_window->parent() == host_window_ ||
534 new_window->parent() == view_->window_->GetRootWindow()) { 534 new_window->parent() == view_->window_->GetRootWindow()) {
535 new_window->AddObserver(this); 535 new_window->AddObserver(this);
536 } 536 }
537 } 537 }
538 } 538 }
539 539
540 if (new_window->parent() == host_window_) { 540 if (new_window->parent() == host_window_) {
541 UpdateConstrainedWindows(NULL); 541 UpdateConstrainedWindows(NULL);
542 } 542 }
543 } 543 }
544 544
545 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE { 545 virtual void OnWillRemoveWindow(aura::Window* window) override {
546 if (window == view_->window_) 546 if (window == view_->window_)
547 return; 547 return;
548 548
549 window->RemoveObserver(this); 549 window->RemoveObserver(this);
550 UpdateConstrainedWindows(window); 550 UpdateConstrainedWindows(window);
551 } 551 }
552 552
553 virtual void OnWindowVisibilityChanged(aura::Window* window, 553 virtual void OnWindowVisibilityChanged(aura::Window* window,
554 bool visible) OVERRIDE { 554 bool visible) override {
555 if (window == view_->window_ || 555 if (window == view_->window_ ||
556 window->parent() == host_window_ || 556 window->parent() == host_window_ ||
557 window->parent() == view_->window_->GetRootWindow()) { 557 window->parent() == view_->window_->GetRootWindow()) {
558 UpdateConstrainedWindows(NULL); 558 UpdateConstrainedWindows(NULL);
559 } 559 }
560 } 560 }
561 #endif 561 #endif
562 562
563 virtual void OnWindowParentChanged(aura::Window* window, 563 virtual void OnWindowParentChanged(aura::Window* window,
564 aura::Window* parent) OVERRIDE { 564 aura::Window* parent) override {
565 if (window != view_->window_) 565 if (window != view_->window_)
566 return; 566 return;
567 567
568 aura::Window* host_window = 568 aura::Window* host_window =
569 window->GetProperty(aura::client::kHostWindowKey); 569 window->GetProperty(aura::client::kHostWindowKey);
570 if (!host_window) 570 if (!host_window)
571 host_window = parent; 571 host_window = parent;
572 572
573 if (host_window_) 573 if (host_window_)
574 host_window_->RemoveObserver(this); 574 host_window_->RemoveObserver(this);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 if (!children[i]->Contains(view_->window_.get())) 610 if (!children[i]->Contains(view_->window_.get()))
611 children[i]->AddObserver(this); 611 children[i]->AddObserver(this);
612 } 612 }
613 } 613 }
614 #endif 614 #endif
615 } 615 }
616 } 616 }
617 617
618 virtual void OnWindowBoundsChanged(aura::Window* window, 618 virtual void OnWindowBoundsChanged(aura::Window* window,
619 const gfx::Rect& old_bounds, 619 const gfx::Rect& old_bounds,
620 const gfx::Rect& new_bounds) OVERRIDE { 620 const gfx::Rect& new_bounds) override {
621 if (window == host_window_ || window == view_->window_) { 621 if (window == host_window_ || window == view_->window_) {
622 SendScreenRects(); 622 SendScreenRects();
623 if (view_->touch_editable_) 623 if (view_->touch_editable_)
624 view_->touch_editable_->UpdateEditingController(); 624 view_->touch_editable_->UpdateEditingController();
625 #if defined(OS_WIN) 625 #if defined(OS_WIN)
626 } else { 626 } else {
627 UpdateConstrainedWindows(NULL); 627 UpdateConstrainedWindows(NULL);
628 #endif 628 #endif
629 } 629 }
630 } 630 }
631 631
632 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { 632 virtual void OnWindowDestroying(aura::Window* window) override {
633 if (window == host_window_) { 633 if (window == host_window_) {
634 host_window_->RemoveObserver(this); 634 host_window_->RemoveObserver(this);
635 host_window_ = NULL; 635 host_window_ = NULL;
636 } 636 }
637 } 637 }
638 638
639 virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE { 639 virtual void OnWindowAddedToRootWindow(aura::Window* window) override {
640 if (window == view_->window_) { 640 if (window == view_->window_) {
641 window->GetHost()->AddObserver(this); 641 window->GetHost()->AddObserver(this);
642 #if defined(OS_WIN) 642 #if defined(OS_WIN)
643 if (!window->GetRootWindow()->HasObserver(this)) 643 if (!window->GetRootWindow()->HasObserver(this))
644 window->GetRootWindow()->AddObserver(this); 644 window->GetRootWindow()->AddObserver(this);
645 #endif 645 #endif
646 } 646 }
647 } 647 }
648 648
649 virtual void OnWindowRemovingFromRootWindow(aura::Window* window, 649 virtual void OnWindowRemovingFromRootWindow(aura::Window* window,
650 aura::Window* new_root) OVERRIDE { 650 aura::Window* new_root) override {
651 if (window == view_->window_) { 651 if (window == view_->window_) {
652 window->GetHost()->RemoveObserver(this); 652 window->GetHost()->RemoveObserver(this);
653 #if defined(OS_WIN) 653 #if defined(OS_WIN)
654 window->GetRootWindow()->RemoveObserver(this); 654 window->GetRootWindow()->RemoveObserver(this);
655 655
656 const aura::Window::Windows& root_children = 656 const aura::Window::Windows& root_children =
657 window->GetRootWindow()->children(); 657 window->GetRootWindow()->children();
658 for (size_t i = 0; i < root_children.size(); ++i) { 658 for (size_t i = 0; i < root_children.size(); ++i) {
659 if (root_children[i] != view_->window_ && 659 if (root_children[i] != view_->window_ &&
660 root_children[i] != host_window_) { 660 root_children[i] != host_window_) {
661 root_children[i]->RemoveObserver(this); 661 root_children[i]->RemoveObserver(this);
662 } 662 }
663 } 663 }
664 #endif 664 #endif
665 } 665 }
666 } 666 }
667 667
668 // Overridden WindowTreeHostObserver: 668 // Overridden WindowTreeHostObserver:
669 virtual void OnHostMoved(const aura::WindowTreeHost* host, 669 virtual void OnHostMoved(const aura::WindowTreeHost* host,
670 const gfx::Point& new_origin) OVERRIDE { 670 const gfx::Point& new_origin) override {
671 TRACE_EVENT1("ui", 671 TRACE_EVENT1("ui",
672 "WebContentsViewAura::WindowObserver::OnHostMoved", 672 "WebContentsViewAura::WindowObserver::OnHostMoved",
673 "new_origin", new_origin.ToString()); 673 "new_origin", new_origin.ToString());
674 674
675 // This is for the desktop case (i.e. Aura desktop). 675 // This is for the desktop case (i.e. Aura desktop).
676 SendScreenRects(); 676 SendScreenRects();
677 } 677 }
678 678
679 private: 679 private:
680 void SendScreenRects() { 680 void SendScreenRects() {
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 if (visible) { 1628 if (visible) {
1629 if (!web_contents_->should_normally_be_visible()) 1629 if (!web_contents_->should_normally_be_visible())
1630 web_contents_->WasShown(); 1630 web_contents_->WasShown();
1631 } else { 1631 } else {
1632 if (web_contents_->should_normally_be_visible()) 1632 if (web_contents_->should_normally_be_visible())
1633 web_contents_->WasHidden(); 1633 web_contents_->WasHidden();
1634 } 1634 }
1635 } 1635 }
1636 1636
1637 } // namespace content 1637 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698