| 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_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 last_active_time_(base::TimeTicks::Now()), | 331 last_active_time_(base::TimeTicks::Now()), |
| 332 closed_by_user_gesture_(false), | 332 closed_by_user_gesture_(false), |
| 333 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 333 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
| 334 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 334 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
| 335 temporary_zoom_settings_(false), | 335 temporary_zoom_settings_(false), |
| 336 totalPinchGestureAmount_(0), | 336 totalPinchGestureAmount_(0), |
| 337 currentPinchZoomStepDelta_(0), | 337 currentPinchZoomStepDelta_(0), |
| 338 color_chooser_identifier_(0), | 338 color_chooser_identifier_(0), |
| 339 render_view_message_source_(NULL), | 339 render_view_message_source_(NULL), |
| 340 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), | 340 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), |
| 341 current_popup_host_view_(NULL), |
| 341 is_subframe_(false) { | 342 is_subframe_(false) { |
| 342 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 343 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
| 343 g_created_callbacks.Get().at(i).Run(this); | 344 g_created_callbacks.Get().at(i).Run(this); |
| 344 frame_tree_.SetFrameRemoveListener( | 345 frame_tree_.SetFrameRemoveListener( |
| 345 base::Bind(&WebContentsImpl::OnFrameRemoved, | 346 base::Bind(&WebContentsImpl::OnFrameRemoved, |
| 346 base::Unretained(this))); | 347 base::Unretained(this))); |
| 347 } | 348 } |
| 348 | 349 |
| 349 WebContentsImpl::~WebContentsImpl() { | 350 WebContentsImpl::~WebContentsImpl() { |
| 350 is_being_destroyed_ = true; | 351 is_being_destroyed_ = true; |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 // window, OnWindowPosChanged() notices and calls WasHidden() (which | 981 // window, OnWindowPosChanged() notices and calls WasHidden() (which |
| 981 // calls us). | 982 // calls us). |
| 982 RenderWidgetHostViewPort* rwhv = | 983 RenderWidgetHostViewPort* rwhv = |
| 983 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); | 984 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); |
| 984 if (rwhv) | 985 if (rwhv) |
| 985 rwhv->Hide(); | 986 rwhv->Hide(); |
| 986 } | 987 } |
| 987 | 988 |
| 988 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); | 989 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); |
| 989 | 990 |
| 991 if (current_popup_host_view_) { |
| 992 current_popup_host_view_->Destroy(); |
| 993 current_popup_host_view_ = NULL; |
| 994 } |
| 995 |
| 990 should_normally_be_visible_ = false; | 996 should_normally_be_visible_ = false; |
| 991 } | 997 } |
| 992 | 998 |
| 993 bool WebContentsImpl::NeedToFireBeforeUnload() { | 999 bool WebContentsImpl::NeedToFireBeforeUnload() { |
| 994 // TODO(creis): Should we fire even for interstitial pages? | 1000 // TODO(creis): Should we fire even for interstitial pages? |
| 995 return WillNotifyDisconnection() && | 1001 return WillNotifyDisconnection() && |
| 996 !ShowingInterstitialPage() && | 1002 !ShowingInterstitialPage() && |
| 997 !static_cast<RenderViewHostImpl*>( | 1003 !static_cast<RenderViewHostImpl*>( |
| 998 GetRenderViewHost())->SuddenTerminationAllowed(); | 1004 GetRenderViewHost())->SuddenTerminationAllowed(); |
| 999 } | 1005 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1023 switch (type) { | 1029 switch (type) { |
| 1024 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { | 1030 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { |
| 1025 RenderWidgetHost* host = Source<RenderWidgetHost>(source).ptr(); | 1031 RenderWidgetHost* host = Source<RenderWidgetHost>(source).ptr(); |
| 1026 for (PendingWidgetViews::iterator i = pending_widget_views_.begin(); | 1032 for (PendingWidgetViews::iterator i = pending_widget_views_.begin(); |
| 1027 i != pending_widget_views_.end(); ++i) { | 1033 i != pending_widget_views_.end(); ++i) { |
| 1028 if (host->GetView() == i->second) { | 1034 if (host->GetView() == i->second) { |
| 1029 pending_widget_views_.erase(i); | 1035 pending_widget_views_.erase(i); |
| 1030 break; | 1036 break; |
| 1031 } | 1037 } |
| 1032 } | 1038 } |
| 1039 if (host->GetView() == current_popup_host_view_) { |
| 1040 current_popup_host_view_ = NULL; |
| 1041 } |
| 1033 break; | 1042 break; |
| 1034 } | 1043 } |
| 1035 default: | 1044 default: |
| 1036 NOTREACHED(); | 1045 NOTREACHED(); |
| 1037 } | 1046 } |
| 1038 } | 1047 } |
| 1039 | 1048 |
| 1040 WebContents* WebContentsImpl::GetWebContents() { | 1049 WebContents* WebContentsImpl::GetWebContents() { |
| 1041 return this; | 1050 return this; |
| 1042 } | 1051 } |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 } else { | 1567 } else { |
| 1559 widget_host_view->InitAsFullscreen(GetRenderWidgetHostViewPort()); | 1568 widget_host_view->InitAsFullscreen(GetRenderWidgetHostViewPort()); |
| 1560 } | 1569 } |
| 1561 FOR_EACH_OBSERVER(WebContentsObserver, | 1570 FOR_EACH_OBSERVER(WebContentsObserver, |
| 1562 observers_, | 1571 observers_, |
| 1563 DidShowFullscreenWidget(route_id)); | 1572 DidShowFullscreenWidget(route_id)); |
| 1564 if (!widget_host_view->HasFocus()) | 1573 if (!widget_host_view->HasFocus()) |
| 1565 widget_host_view->Focus(); | 1574 widget_host_view->Focus(); |
| 1566 } else { | 1575 } else { |
| 1567 widget_host_view->InitAsPopup(GetRenderWidgetHostViewPort(), initial_pos); | 1576 widget_host_view->InitAsPopup(GetRenderWidgetHostViewPort(), initial_pos); |
| 1577 DCHECK(!current_popup_host_view_); |
| 1578 current_popup_host_view_ = widget_host_view; |
| 1568 } | 1579 } |
| 1569 | 1580 |
| 1570 RenderWidgetHostImpl* render_widget_host_impl = | 1581 RenderWidgetHostImpl* render_widget_host_impl = |
| 1571 RenderWidgetHostImpl::From(widget_host_view->GetRenderWidgetHost()); | 1582 RenderWidgetHostImpl::From(widget_host_view->GetRenderWidgetHost()); |
| 1572 render_widget_host_impl->Init(); | 1583 render_widget_host_impl->Init(); |
| 1573 // Only allow privileged mouse lock for fullscreen render widget, which is | 1584 // Only allow privileged mouse lock for fullscreen render widget, which is |
| 1574 // used to implement Pepper Flash fullscreen. | 1585 // used to implement Pepper Flash fullscreen. |
| 1575 render_widget_host_impl->set_allow_privileged_mouse_lock(is_fullscreen); | 1586 render_widget_host_impl->set_allow_privileged_mouse_lock(is_fullscreen); |
| 1576 | 1587 |
| 1577 #if defined(OS_MACOSX) | 1588 #if defined(OS_MACOSX) |
| (...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3693 | 3704 |
| 3694 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 3705 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
| 3695 if (!delegate_) | 3706 if (!delegate_) |
| 3696 return; | 3707 return; |
| 3697 const gfx::Size new_size = GetPreferredSize(); | 3708 const gfx::Size new_size = GetPreferredSize(); |
| 3698 if (new_size != old_size) | 3709 if (new_size != old_size) |
| 3699 delegate_->UpdatePreferredSize(this, new_size); | 3710 delegate_->UpdatePreferredSize(this, new_size); |
| 3700 } | 3711 } |
| 3701 | 3712 |
| 3702 } // namespace content | 3713 } // namespace content |
| OLD | NEW |