| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 653 |
| 654 WebContentsViewAura::WebContentsViewAura(WebContentsImpl* web_contents, | 654 WebContentsViewAura::WebContentsViewAura(WebContentsImpl* web_contents, |
| 655 WebContentsViewDelegate* delegate) | 655 WebContentsViewDelegate* delegate) |
| 656 : web_contents_(web_contents), | 656 : web_contents_(web_contents), |
| 657 delegate_(delegate), | 657 delegate_(delegate), |
| 658 current_drag_op_(blink::WebDragOperationNone), | 658 current_drag_op_(blink::WebDragOperationNone), |
| 659 drag_dest_delegate_(NULL), | 659 drag_dest_delegate_(NULL), |
| 660 current_rvh_for_drag_(NULL), | 660 current_rvh_for_drag_(NULL), |
| 661 current_overscroll_gesture_(OVERSCROLL_NONE), | 661 current_overscroll_gesture_(OVERSCROLL_NONE), |
| 662 completed_overscroll_gesture_(OVERSCROLL_NONE), | 662 completed_overscroll_gesture_(OVERSCROLL_NONE), |
| 663 navigation_overlay_(nullptr), | 663 navigation_overlay_(nullptr) {} |
| 664 is_or_was_visible_(false) { | |
| 665 } | |
| 666 | 664 |
| 667 void WebContentsViewAura::SetDelegateForTesting( | 665 void WebContentsViewAura::SetDelegateForTesting( |
| 668 WebContentsViewDelegate* delegate) { | 666 WebContentsViewDelegate* delegate) { |
| 669 delegate_.reset(delegate); | 667 delegate_.reset(delegate); |
| 670 } | 668 } |
| 671 | 669 |
| 672 //////////////////////////////////////////////////////////////////////////////// | 670 //////////////////////////////////////////////////////////////////////////////// |
| 673 // WebContentsViewAura, private: | 671 // WebContentsViewAura, private: |
| 674 | 672 |
| 675 WebContentsViewAura::~WebContentsViewAura() { | 673 WebContentsViewAura::~WebContentsViewAura() { |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 current_drop_data_.reset(); | 1289 current_drop_data_.reset(); |
| 1292 return ConvertFromWeb(current_drag_op_); | 1290 return ConvertFromWeb(current_drag_op_); |
| 1293 } | 1291 } |
| 1294 | 1292 |
| 1295 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, | 1293 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, |
| 1296 bool visible) { | 1294 bool visible) { |
| 1297 // Ignore any visibility changes in the hierarchy below. | 1295 // Ignore any visibility changes in the hierarchy below. |
| 1298 if (window != window_.get() && window_->Contains(window)) | 1296 if (window != window_.get() && window_->Contains(window)) |
| 1299 return; | 1297 return; |
| 1300 | 1298 |
| 1301 UpdateWebContentsVisibility(visible); | 1299 web_contents_->UpdateWebContentsVisibility(visible); |
| 1302 } | |
| 1303 | |
| 1304 void WebContentsViewAura::UpdateWebContentsVisibility(bool visible) { | |
| 1305 if (!is_or_was_visible_) { | |
| 1306 // We should not hide the web contents before it was shown the first time, | |
| 1307 // since resources would immediately be destroyed and only re-created after | |
| 1308 // content got loaded. In this state the window content is undefined and can | |
| 1309 // show garbage. | |
| 1310 // However - the page load mechanism requires an activation call through a | |
| 1311 // visibility call to (re)load. | |
| 1312 if (visible) { | |
| 1313 is_or_was_visible_ = true; | |
| 1314 web_contents_->WasShown(); | |
| 1315 } | |
| 1316 return; | |
| 1317 } | |
| 1318 if (visible) { | |
| 1319 if (!web_contents_->should_normally_be_visible()) | |
| 1320 web_contents_->WasShown(); | |
| 1321 } else { | |
| 1322 if (web_contents_->should_normally_be_visible()) | |
| 1323 web_contents_->WasHidden(); | |
| 1324 } | |
| 1325 } | 1300 } |
| 1326 | 1301 |
| 1327 } // namespace content | 1302 } // namespace content |
| OLD | NEW |