| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // Notify any observer that have a reference on this WebContents. | 337 // Notify any observer that have a reference on this WebContents. |
| 338 NotificationService::current()->Notify( | 338 NotificationService::current()->Notify( |
| 339 NOTIFICATION_WEB_CONTENTS_DESTROYED, | 339 NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 340 Source<WebContents>(this), | 340 Source<WebContents>(this), |
| 341 NotificationService::NoDetails()); | 341 NotificationService::NoDetails()); |
| 342 | 342 |
| 343 // TODO(brettw) this should be moved to the view. | 343 // TODO(brettw) this should be moved to the view. |
| 344 #if defined(OS_WIN) && !defined(USE_AURA) | 344 #if defined(OS_WIN) && !defined(USE_AURA) |
| 345 // If we still have a window handle, destroy it. GetNativeView can return | 345 // If we still have a window handle, destroy it. GetNativeView can return |
| 346 // NULL if this contents was part of a window that closed. | 346 // NULL if this contents was part of a window that closed. |
| 347 if (GetNativeView()) { | 347 if (view_->GetNativeView()) { |
| 348 RenderViewHost* host = GetRenderViewHost(); | 348 RenderViewHost* host = GetRenderViewHost(); |
| 349 if (host && host->GetView()) | 349 if (host && host->GetView()) |
| 350 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); | 350 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); |
| 351 } | 351 } |
| 352 #endif | 352 #endif |
| 353 | 353 |
| 354 // OnCloseStarted isn't called in unit tests. | 354 // OnCloseStarted isn't called in unit tests. |
| 355 if (!close_start_time_.is_null()) { | 355 if (!close_start_time_.is_null()) { |
| 356 base::TimeTicks now = base::TimeTicks::Now(); | 356 base::TimeTicks now = base::TimeTicks::Now(); |
| 357 base::TimeTicks unload_start_time = close_start_time_; | 357 base::TimeTicks unload_start_time = close_start_time_; |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 CreateParams create_params(GetBrowserContext(), GetSiteInstance()); | 1179 CreateParams create_params(GetBrowserContext(), GetSiteInstance()); |
| 1180 create_params.initial_size = view_->GetContainerSize(); | 1180 create_params.initial_size = view_->GetContainerSize(); |
| 1181 WebContentsImpl* tc = CreateWithOpener(create_params, opener_); | 1181 WebContentsImpl* tc = CreateWithOpener(create_params, opener_); |
| 1182 tc->GetController().CopyStateFrom(controller_); | 1182 tc->GetController().CopyStateFrom(controller_); |
| 1183 FOR_EACH_OBSERVER(WebContentsObserver, | 1183 FOR_EACH_OBSERVER(WebContentsObserver, |
| 1184 observers_, | 1184 observers_, |
| 1185 DidCloneToNewWebContents(this, tc)); | 1185 DidCloneToNewWebContents(this, tc)); |
| 1186 return tc; | 1186 return tc; |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 gfx::NativeView WebContentsImpl::GetContentNativeView() const { | |
| 1190 return view_->GetContentNativeView(); | |
| 1191 } | |
| 1192 | |
| 1193 gfx::NativeView WebContentsImpl::GetNativeView() const { | |
| 1194 return view_->GetNativeView(); | |
| 1195 } | |
| 1196 | |
| 1197 void WebContentsImpl::GetContainerBounds(gfx::Rect* out) const { | |
| 1198 view_->GetContainerBounds(out); | |
| 1199 } | |
| 1200 | |
| 1201 void WebContentsImpl::Focus() { | |
| 1202 view_->Focus(); | |
| 1203 } | |
| 1204 | |
| 1205 void WebContentsImpl::Observe(int type, | 1189 void WebContentsImpl::Observe(int type, |
| 1206 const NotificationSource& source, | 1190 const NotificationSource& source, |
| 1207 const NotificationDetails& details) { | 1191 const NotificationDetails& details) { |
| 1208 switch (type) { | 1192 switch (type) { |
| 1209 case NOTIFICATION_WEB_CONTENTS_DESTROYED: | 1193 case NOTIFICATION_WEB_CONTENTS_DESTROYED: |
| 1210 OnWebContentsDestroyed(Source<WebContents>(source).ptr()); | 1194 OnWebContentsDestroyed(Source<WebContents>(source).ptr()); |
| 1211 break; | 1195 break; |
| 1212 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { | 1196 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { |
| 1213 RenderWidgetHost* host = Source<RenderWidgetHost>(source).ptr(); | 1197 RenderWidgetHost* host = Source<RenderWidgetHost>(source).ptr(); |
| 1214 for (PendingWidgetViews::iterator i = pending_widget_views_.begin(); | 1198 for (PendingWidgetViews::iterator i = pending_widget_views_.begin(); |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2378 int version, | 2362 int version, |
| 2379 const std::vector<gfx::RectF>& rects, | 2363 const std::vector<gfx::RectF>& rects, |
| 2380 const gfx::RectF& active_rect) { | 2364 const gfx::RectF& active_rect) { |
| 2381 if (delegate_) | 2365 if (delegate_) |
| 2382 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | 2366 delegate_->FindMatchRectsReply(this, version, rects, active_rect); |
| 2383 } | 2367 } |
| 2384 | 2368 |
| 2385 void WebContentsImpl::OnOpenDateTimeDialog( | 2369 void WebContentsImpl::OnOpenDateTimeDialog( |
| 2386 const ViewHostMsg_DateTimeDialogValue_Params& value) { | 2370 const ViewHostMsg_DateTimeDialogValue_Params& value) { |
| 2387 date_time_chooser_->ShowDialog( | 2371 date_time_chooser_->ShowDialog( |
| 2388 GetContentNativeView(), GetRenderViewHost(), value.dialog_type, | 2372 view_->GetContentNativeView(), GetRenderViewHost(), value.dialog_type, |
| 2389 value.year, value.month, value.day, value.hour, | 2373 value.year, value.month, value.day, value.hour, |
| 2390 value.minute, value.second); | 2374 value.minute, value.second); |
| 2391 } | 2375 } |
| 2392 | 2376 |
| 2393 #endif | 2377 #endif |
| 2394 | 2378 |
| 2395 void WebContentsImpl::OnCrashedPlugin(const base::FilePath& plugin_path, | 2379 void WebContentsImpl::OnCrashedPlugin(const base::FilePath& plugin_path, |
| 2396 base::ProcessId plugin_pid) { | 2380 base::ProcessId plugin_pid) { |
| 2397 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2381 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2398 PluginCrashed(plugin_path, plugin_pid)); | 2382 PluginCrashed(plugin_path, plugin_pid)); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2780 } | 2764 } |
| 2781 | 2765 |
| 2782 NotifyConnected(); | 2766 NotifyConnected(); |
| 2783 bool was_crashed = IsCrashed(); | 2767 bool was_crashed = IsCrashed(); |
| 2784 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); | 2768 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); |
| 2785 | 2769 |
| 2786 // Restore the focus to the tab (otherwise the focus will be on the top | 2770 // Restore the focus to the tab (otherwise the focus will be on the top |
| 2787 // window). | 2771 // window). |
| 2788 if (was_crashed && !FocusLocationBarByDefault() && | 2772 if (was_crashed && !FocusLocationBarByDefault() && |
| 2789 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { | 2773 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { |
| 2790 Focus(); | 2774 view_->Focus(); |
| 2791 } | 2775 } |
| 2792 | 2776 |
| 2793 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewReady()); | 2777 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewReady()); |
| 2794 } | 2778 } |
| 2795 | 2779 |
| 2796 void WebContentsImpl::RenderViewGone(RenderViewHost* rvh, | 2780 void WebContentsImpl::RenderViewGone(RenderViewHost* rvh, |
| 2797 base::TerminationStatus status, | 2781 base::TerminationStatus status, |
| 2798 int error_code) { | 2782 int error_code) { |
| 2799 if (rvh != GetRenderViewHost()) { | 2783 if (rvh != GetRenderViewHost()) { |
| 2800 // The pending page's RenderViewHost is gone. | 2784 // The pending page's RenderViewHost is gone. |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3552 | 3536 |
| 3553 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { | 3537 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { |
| 3554 return browser_plugin_guest_.get(); | 3538 return browser_plugin_guest_.get(); |
| 3555 } | 3539 } |
| 3556 | 3540 |
| 3557 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { | 3541 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { |
| 3558 return browser_plugin_embedder_.get(); | 3542 return browser_plugin_embedder_.get(); |
| 3559 } | 3543 } |
| 3560 | 3544 |
| 3561 } // namespace content | 3545 } // namespace content |
| OLD | NEW |