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/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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 // WebContentsViewAura, private: | 714 // WebContentsViewAura, private: |
715 | 715 |
716 WebContentsViewAura::~WebContentsViewAura() { | 716 WebContentsViewAura::~WebContentsViewAura() { |
717 if (!window_) | 717 if (!window_) |
718 return; | 718 return; |
719 | 719 |
720 window_observer_.reset(); | 720 window_observer_.reset(); |
721 | 721 |
722 // Window needs a valid delegate during its destructor, so we explicitly | 722 // Window needs a valid delegate during its destructor, so we explicitly |
723 // delete it here. | 723 // delete it here. |
724 window_->RemoveObserver(this); | |
724 window_.reset(); | 725 window_.reset(); |
725 } | 726 } |
726 | 727 |
727 void WebContentsViewAura::SetupOverlayWindowForTesting() { | 728 void WebContentsViewAura::SetupOverlayWindowForTesting() { |
728 if (navigation_overlay_) | 729 if (navigation_overlay_) |
729 navigation_overlay_->SetupForTesting(); | 730 navigation_overlay_->SetupForTesting(); |
730 } | 731 } |
731 | 732 |
732 void WebContentsViewAura::SetTouchEditableForTest( | 733 void WebContentsViewAura::SetTouchEditableForTest( |
733 TouchEditableImplAura* touch_editable) { | 734 TouchEditableImplAura* touch_editable) { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1038 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as | 1039 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as |
1039 // if the bookmark bar is not shown and you create a new tab). The right | 1040 // if the bookmark bar is not shown and you create a new tab). The right |
1040 // value is set shortly after this, so its safe to ignore. | 1041 // value is set shortly after this, so its safe to ignore. |
1041 | 1042 |
1042 aura::Env::CreateInstance(true); | 1043 aura::Env::CreateInstance(true); |
1043 window_.reset(new aura::Window(this)); | 1044 window_.reset(new aura::Window(this)); |
1044 window_->set_owned_by_parent(false); | 1045 window_->set_owned_by_parent(false); |
1045 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 1046 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
1046 window_->SetTransparent(false); | 1047 window_->SetTransparent(false); |
1047 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); | 1048 window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
1049 window_->AddObserver(this); | |
1048 aura::Window* root_window = context ? context->GetRootWindow() : NULL; | 1050 aura::Window* root_window = context ? context->GetRootWindow() : NULL; |
1049 if (root_window) { | 1051 if (root_window) { |
1050 // There are places where there is no context currently because object | 1052 // There are places where there is no context currently because object |
1051 // hierarchies are built before they're attached to a Widget. (See | 1053 // hierarchies are built before they're attached to a Widget. (See |
1052 // views::WebView as an example; GetWidget() returns NULL at the point | 1054 // views::WebView as an example; GetWidget() returns NULL at the point |
1053 // where we are created.) | 1055 // where we are created.) |
1054 // | 1056 // |
1055 // It should be OK to not set a default parent since such users will | 1057 // It should be OK to not set a default parent since such users will |
1056 // explicitly add this WebContentsViewAura to their tree after they create | 1058 // explicitly add this WebContentsViewAura to their tree after they create |
1057 // us. | 1059 // us. |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1421 // then destroying it in the WebContentsViewAura destructor can trigger other | 1423 // then destroying it in the WebContentsViewAura destructor can trigger other |
1422 // virtual functions to be called (e.g. OnImplicitAnimationsCompleted()). So | 1424 // virtual functions to be called (e.g. OnImplicitAnimationsCompleted()). So |
1423 // destroy the overscroll window here. | 1425 // destroy the overscroll window here. |
1424 navigation_overlay_.reset(); | 1426 navigation_overlay_.reset(); |
1425 overscroll_window_.reset(); | 1427 overscroll_window_.reset(); |
1426 } | 1428 } |
1427 | 1429 |
1428 void WebContentsViewAura::OnWindowDestroyed(aura::Window* window) { | 1430 void WebContentsViewAura::OnWindowDestroyed(aura::Window* window) { |
1429 } | 1431 } |
1430 | 1432 |
1431 void WebContentsViewAura::OnWindowTargetVisibilityChanged(bool visible) { | 1433 void WebContentsViewAura::OnWindowTargetVisibilityChanged(bool visible) { |
sky
2014/05/16 20:14:58
I don't think you want this anymore.
| |
1432 if (visible) | 1434 if (visible) |
1433 web_contents_->WasShown(); | 1435 web_contents_->WasShown(); |
1434 else | 1436 else |
1435 web_contents_->WasHidden(); | 1437 web_contents_->WasHidden(); |
1436 } | 1438 } |
1437 | 1439 |
1438 bool WebContentsViewAura::HasHitTestMask() const { | 1440 bool WebContentsViewAura::HasHitTestMask() const { |
1439 return false; | 1441 return false; |
1440 } | 1442 } |
1441 | 1443 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1548 web_contents_->GetRenderViewHost()->DragTargetDrop( | 1550 web_contents_->GetRenderViewHost()->DragTargetDrop( |
1549 event.location(), | 1551 event.location(), |
1550 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1552 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1551 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1553 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1552 if (drag_dest_delegate_) | 1554 if (drag_dest_delegate_) |
1553 drag_dest_delegate_->OnDrop(); | 1555 drag_dest_delegate_->OnDrop(); |
1554 current_drop_data_.reset(); | 1556 current_drop_data_.reset(); |
1555 return ConvertFromWeb(current_drag_op_); | 1557 return ConvertFromWeb(current_drag_op_); |
1556 } | 1558 } |
1557 | 1559 |
1560 void WebContentsViewAura::OnWindowParentChanged(aura::Window* window, | |
1561 aura::Window* parent) { | |
1562 if (!parent || parent->IsVisible()) | |
sky
2014/05/16 20:14:58
I don't get why you're tracking visibility of the
| |
1563 web_contents_->WasShown(); | |
1564 else | |
1565 web_contents_->WasHidden(); | |
1566 } | |
1567 | |
1568 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, | |
1569 bool visible) { | |
1570 aura::Window* parent = window_->parent(); | |
1571 if (!parent) | |
1572 return; | |
1573 | |
1574 // Follow the visibility of the parent window since e.g. navigation | |
1575 // operations could otherwise cause a flash. | |
1576 if (parent->IsVisible()) | |
1577 web_contents_->WasShown(); | |
1578 else | |
1579 web_contents_->WasHidden(); | |
1580 } | |
1581 | |
1558 } // namespace content | 1582 } // namespace content |
OLD | NEW |