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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 #if defined(OS_WIN) && !defined(USE_AURA) | 390 #if defined(OS_WIN) && !defined(USE_AURA) |
391 // If we still have a window handle, destroy it. GetNativeView can return | 391 // If we still have a window handle, destroy it. GetNativeView can return |
392 // NULL if this contents was part of a window that closed. | 392 // NULL if this contents was part of a window that closed. |
393 if (view_->GetNativeView()) { | 393 if (view_->GetNativeView()) { |
394 RenderViewHost* host = GetRenderViewHost(); | 394 RenderViewHost* host = GetRenderViewHost(); |
395 if (host && host->GetView()) | 395 if (host && host->GetView()) |
396 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); | 396 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); |
397 } | 397 } |
398 #endif | 398 #endif |
399 | 399 |
400 // OnCloseStarted isn't called in unit tests. | |
401 if (!close_start_time_.is_null()) { | |
402 base::TimeTicks now = base::TimeTicks::Now(); | |
403 base::TimeDelta close_time = now - close_start_time_; | |
404 UMA_HISTOGRAM_TIMES("Tab.Close", close_time); | |
405 | |
406 base::TimeTicks unload_start_time = close_start_time_; | |
407 base::TimeTicks unload_end_time = now; | |
408 if (!before_unload_end_time_.is_null()) | |
409 unload_start_time = before_unload_end_time_; | |
410 if (!unload_detached_start_time_.is_null()) | |
411 unload_end_time = unload_detached_start_time_; | |
412 base::TimeDelta unload_time = unload_end_time - unload_start_time; | |
413 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time); | |
414 | |
415 } | |
416 | |
417 FOR_EACH_OBSERVER(WebContentsObserver, | 400 FOR_EACH_OBSERVER(WebContentsObserver, |
418 observers_, | 401 observers_, |
419 WebContentsImplDestroyed()); | 402 WebContentsImplDestroyed()); |
420 | 403 |
421 SetDelegate(NULL); | 404 SetDelegate(NULL); |
422 | 405 |
423 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), | 406 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), |
424 destruction_observers_.end()); | 407 destruction_observers_.end()); |
425 } | 408 } |
426 | 409 |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1944 | 1927 |
1945 void WebContentsImpl::ResetOverrideEncoding() { | 1928 void WebContentsImpl::ResetOverrideEncoding() { |
1946 encoding_.clear(); | 1929 encoding_.clear(); |
1947 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID())); | 1930 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID())); |
1948 } | 1931 } |
1949 | 1932 |
1950 RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() { | 1933 RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() { |
1951 return &renderer_preferences_; | 1934 return &renderer_preferences_; |
1952 } | 1935 } |
1953 | 1936 |
1954 void WebContentsImpl::SetNewTabStartTime(const base::TimeTicks& time) { | |
1955 new_tab_start_time_ = time; | |
1956 } | |
1957 | |
1958 base::TimeTicks WebContentsImpl::GetNewTabStartTime() const { | |
1959 return new_tab_start_time_; | |
1960 } | |
1961 | |
1962 void WebContentsImpl::Close() { | 1937 void WebContentsImpl::Close() { |
1963 Close(GetRenderViewHost()); | 1938 Close(GetRenderViewHost()); |
1964 } | 1939 } |
1965 | 1940 |
1966 void WebContentsImpl::OnCloseStarted() { | |
1967 if (close_start_time_.is_null()) | |
1968 close_start_time_ = base::TimeTicks::Now(); | |
1969 } | |
1970 | |
1971 void WebContentsImpl::OnCloseCanceled() { | |
1972 close_start_time_ = base::TimeTicks(); | |
1973 before_unload_end_time_ = base::TimeTicks(); | |
1974 unload_detached_start_time_ = base::TimeTicks(); | |
1975 } | |
1976 | |
1977 void WebContentsImpl::OnUnloadStarted() { | |
1978 before_unload_end_time_ = base::TimeTicks::Now(); | |
1979 } | |
1980 | |
1981 void WebContentsImpl::OnUnloadDetachedStarted() { | |
1982 if (unload_detached_start_time_.is_null()) | |
1983 unload_detached_start_time_ = base::TimeTicks::Now(); | |
1984 } | |
1985 | |
1986 void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y, | 1941 void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y, |
1987 int screen_x, int screen_y, WebKit::WebDragOperation operation) { | 1942 int screen_x, int screen_y, WebKit::WebDragOperation operation) { |
1988 if (browser_plugin_embedder_.get()) | 1943 if (browser_plugin_embedder_.get()) |
1989 browser_plugin_embedder_->DragSourceEndedAt(client_x, client_y, | 1944 browser_plugin_embedder_->DragSourceEndedAt(client_x, client_y, |
1990 screen_x, screen_y, operation); | 1945 screen_x, screen_y, operation); |
1991 if (GetRenderViewHost()) | 1946 if (GetRenderViewHost()) |
1992 GetRenderViewHostImpl()->DragSourceEndedAt(client_x, client_y, | 1947 GetRenderViewHostImpl()->DragSourceEndedAt(client_x, client_y, |
1993 screen_x, screen_y, operation); | 1948 screen_x, screen_y, operation); |
1994 } | 1949 } |
1995 | 1950 |
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3498 } | 3453 } |
3499 | 3454 |
3500 void WebContentsImpl::WorkerCrashed() { | 3455 void WebContentsImpl::WorkerCrashed() { |
3501 if (delegate_) | 3456 if (delegate_) |
3502 delegate_->WorkerCrashed(this); | 3457 delegate_->WorkerCrashed(this); |
3503 } | 3458 } |
3504 | 3459 |
3505 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( | 3460 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( |
3506 bool proceed, const base::TimeTicks& proceed_time, | 3461 bool proceed, const base::TimeTicks& proceed_time, |
3507 bool* proceed_to_fire_unload) { | 3462 bool* proceed_to_fire_unload) { |
3508 before_unload_end_time_ = proceed_time; | 3463 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3464 BeforeUnloadFired(proceed_time)); | |
3509 if (delegate_) | 3465 if (delegate_) |
3510 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); | 3466 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); |
3467 // Note: |this| can be deleted at this point. | |
Avi (use Gerrit)
2013/06/19 05:00:01
"can be deleted" sounds like permission. Perhaps "
| |
3511 } | 3468 } |
3512 | 3469 |
3513 void WebContentsImpl::RenderViewGoneFromRenderManager( | 3470 void WebContentsImpl::RenderViewGoneFromRenderManager( |
3514 RenderViewHost* render_view_host) { | 3471 RenderViewHost* render_view_host) { |
3515 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); | 3472 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); |
3516 RenderViewTerminated(render_view_host, crashed_status_, crashed_error_code_); | 3473 RenderViewTerminated(render_view_host, crashed_status_, crashed_error_code_); |
3517 } | 3474 } |
3518 | 3475 |
3519 void WebContentsImpl::UpdateRenderViewSizeForRenderManager() { | 3476 void WebContentsImpl::UpdateRenderViewSizeForRenderManager() { |
3520 // TODO(brettw) this is a hack. See WebContentsView::SizeContents. | 3477 // TODO(brettw) this is a hack. See WebContentsView::SizeContents. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3640 | 3597 |
3641 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, | 3598 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, |
3642 IPC::Message* reply_msg, | 3599 IPC::Message* reply_msg, |
3643 bool success, | 3600 bool success, |
3644 const string16& user_input) { | 3601 const string16& user_input) { |
3645 if (is_showing_before_unload_dialog_ && !success) { | 3602 if (is_showing_before_unload_dialog_ && !success) { |
3646 // If a beforeunload dialog is canceled, we need to stop the throbber from | 3603 // If a beforeunload dialog is canceled, we need to stop the throbber from |
3647 // spinning, since we forced it to start spinning in Navigate. | 3604 // spinning, since we forced it to start spinning in Navigate. |
3648 DidStopLoading(rvh); | 3605 DidStopLoading(rvh); |
3649 controller_.DiscardNonCommittedEntries(); | 3606 controller_.DiscardNonCommittedEntries(); |
3650 OnCloseCanceled(); | 3607 |
3608 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | |
3609 BeforeUnloadDialogCancelled()); | |
3651 } | 3610 } |
3652 is_showing_before_unload_dialog_ = false; | 3611 is_showing_before_unload_dialog_ = false; |
3653 static_cast<RenderViewHostImpl*>( | 3612 static_cast<RenderViewHostImpl*>( |
3654 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); | 3613 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); |
3655 } | 3614 } |
3656 | 3615 |
3657 void WebContentsImpl::SetEncoding(const std::string& encoding) { | 3616 void WebContentsImpl::SetEncoding(const std::string& encoding) { |
3658 encoding_ = GetContentClient()->browser()-> | 3617 encoding_ = GetContentClient()->browser()-> |
3659 GetCanonicalEncodingNameByAliasName(encoding); | 3618 GetCanonicalEncodingNameByAliasName(encoding); |
3660 } | 3619 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3703 } | 3662 } |
3704 | 3663 |
3705 BrowserPluginGuestManager* | 3664 BrowserPluginGuestManager* |
3706 WebContentsImpl::GetBrowserPluginGuestManager() const { | 3665 WebContentsImpl::GetBrowserPluginGuestManager() const { |
3707 return static_cast<BrowserPluginGuestManager*>( | 3666 return static_cast<BrowserPluginGuestManager*>( |
3708 GetBrowserContext()->GetUserData( | 3667 GetBrowserContext()->GetUserData( |
3709 browser_plugin::kBrowserPluginGuestManagerKeyName)); | 3668 browser_plugin::kBrowserPluginGuestManagerKeyName)); |
3710 } | 3669 } |
3711 | 3670 |
3712 } // namespace content | 3671 } // namespace content |
OLD | NEW |