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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 #if defined(OS_WIN) && !defined(USE_AURA) | 391 #if defined(OS_WIN) && !defined(USE_AURA) |
392 // If we still have a window handle, destroy it. GetNativeView can return | 392 // If we still have a window handle, destroy it. GetNativeView can return |
393 // NULL if this contents was part of a window that closed. | 393 // NULL if this contents was part of a window that closed. |
394 if (view_->GetNativeView()) { | 394 if (view_->GetNativeView()) { |
395 RenderViewHost* host = GetRenderViewHost(); | 395 RenderViewHost* host = GetRenderViewHost(); |
396 if (host && host->GetView()) | 396 if (host && host->GetView()) |
397 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); | 397 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); |
398 } | 398 } |
399 #endif | 399 #endif |
400 | 400 |
401 // OnCloseStarted isn't called in unit tests. | |
402 if (!close_start_time_.is_null()) { | |
403 base::TimeTicks now = base::TimeTicks::Now(); | |
404 base::TimeTicks unload_start_time = close_start_time_; | |
405 if (!before_unload_end_time_.is_null()) | |
406 unload_start_time = before_unload_end_time_; | |
407 UMA_HISTOGRAM_TIMES("Tab.Close", now - close_start_time_); | |
408 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", now - unload_start_time); | |
409 } | |
410 | |
411 FOR_EACH_OBSERVER(WebContentsObserver, | 401 FOR_EACH_OBSERVER(WebContentsObserver, |
412 observers_, | 402 observers_, |
413 WebContentsImplDestroyed()); | 403 WebContentsImplDestroyed()); |
414 | 404 |
415 SetDelegate(NULL); | 405 SetDelegate(NULL); |
416 | 406 |
417 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), | 407 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), |
418 destruction_observers_.end()); | 408 destruction_observers_.end()); |
419 } | 409 } |
420 | 410 |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 | 1931 |
1942 void WebContentsImpl::ResetOverrideEncoding() { | 1932 void WebContentsImpl::ResetOverrideEncoding() { |
1943 encoding_.clear(); | 1933 encoding_.clear(); |
1944 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID())); | 1934 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID())); |
1945 } | 1935 } |
1946 | 1936 |
1947 RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() { | 1937 RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() { |
1948 return &renderer_preferences_; | 1938 return &renderer_preferences_; |
1949 } | 1939 } |
1950 | 1940 |
1951 void WebContentsImpl::SetNewTabStartTime(const base::TimeTicks& time) { | |
1952 new_tab_start_time_ = time; | |
1953 } | |
1954 | |
1955 base::TimeTicks WebContentsImpl::GetNewTabStartTime() const { | |
1956 return new_tab_start_time_; | |
1957 } | |
1958 | |
1959 void WebContentsImpl::Close() { | 1941 void WebContentsImpl::Close() { |
1960 Close(GetRenderViewHost()); | 1942 Close(GetRenderViewHost()); |
1961 } | 1943 } |
1962 | 1944 |
1963 void WebContentsImpl::OnCloseStarted() { | |
1964 if (close_start_time_.is_null()) | |
1965 close_start_time_ = base::TimeTicks::Now(); | |
1966 } | |
1967 | |
1968 void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y, | 1945 void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y, |
1969 int screen_x, int screen_y, WebKit::WebDragOperation operation) { | 1946 int screen_x, int screen_y, WebKit::WebDragOperation operation) { |
1970 if (browser_plugin_embedder_.get()) | 1947 if (browser_plugin_embedder_.get()) |
1971 browser_plugin_embedder_->DragSourceEndedAt(client_x, client_y, | 1948 browser_plugin_embedder_->DragSourceEndedAt(client_x, client_y, |
1972 screen_x, screen_y, operation); | 1949 screen_x, screen_y, operation); |
1973 if (GetRenderViewHost()) | 1950 if (GetRenderViewHost()) |
1974 GetRenderViewHostImpl()->DragSourceEndedAt(client_x, client_y, | 1951 GetRenderViewHostImpl()->DragSourceEndedAt(client_x, client_y, |
1975 screen_x, screen_y, operation); | 1952 screen_x, screen_y, operation); |
1976 } | 1953 } |
1977 | 1954 |
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3482 } | 3459 } |
3483 | 3460 |
3484 void WebContentsImpl::WorkerCrashed() { | 3461 void WebContentsImpl::WorkerCrashed() { |
3485 if (delegate_) | 3462 if (delegate_) |
3486 delegate_->WorkerCrashed(this); | 3463 delegate_->WorkerCrashed(this); |
3487 } | 3464 } |
3488 | 3465 |
3489 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( | 3466 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( |
3490 bool proceed, const base::TimeTicks& proceed_time, | 3467 bool proceed, const base::TimeTicks& proceed_time, |
3491 bool* proceed_to_fire_unload) { | 3468 bool* proceed_to_fire_unload) { |
3492 before_unload_end_time_ = proceed_time; | 3469 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3470 BeforeUnloadFired(proceed_time)); |
3493 if (delegate_) | 3471 if (delegate_) |
3494 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); | 3472 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); |
3495 } | 3473 } |
3496 | 3474 |
3497 void WebContentsImpl::RenderViewGoneFromRenderManager( | 3475 void WebContentsImpl::RenderViewGoneFromRenderManager( |
3498 RenderViewHost* render_view_host) { | 3476 RenderViewHost* render_view_host) { |
3499 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); | 3477 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); |
3500 RenderViewTerminated(render_view_host, crashed_status_, crashed_error_code_); | 3478 RenderViewTerminated(render_view_host, crashed_status_, crashed_error_code_); |
3501 } | 3479 } |
3502 | 3480 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3625 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, | 3603 void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, |
3626 IPC::Message* reply_msg, | 3604 IPC::Message* reply_msg, |
3627 bool success, | 3605 bool success, |
3628 const string16& user_input) { | 3606 const string16& user_input) { |
3629 if (is_showing_before_unload_dialog_ && !success) { | 3607 if (is_showing_before_unload_dialog_ && !success) { |
3630 // If a beforeunload dialog is canceled, we need to stop the throbber from | 3608 // If a beforeunload dialog is canceled, we need to stop the throbber from |
3631 // spinning, since we forced it to start spinning in Navigate. | 3609 // spinning, since we forced it to start spinning in Navigate. |
3632 DidStopLoading(rvh); | 3610 DidStopLoading(rvh); |
3633 controller_.DiscardNonCommittedEntries(); | 3611 controller_.DiscardNonCommittedEntries(); |
3634 | 3612 |
3635 close_start_time_ = base::TimeTicks(); | 3613 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3636 before_unload_end_time_ = base::TimeTicks(); | 3614 BeforeUnloadDialogCancelled()); |
3637 } | 3615 } |
3638 is_showing_before_unload_dialog_ = false; | 3616 is_showing_before_unload_dialog_ = false; |
3639 static_cast<RenderViewHostImpl*>( | 3617 static_cast<RenderViewHostImpl*>( |
3640 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); | 3618 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); |
3641 } | 3619 } |
3642 | 3620 |
3643 void WebContentsImpl::SetEncoding(const std::string& encoding) { | 3621 void WebContentsImpl::SetEncoding(const std::string& encoding) { |
3644 encoding_ = GetContentClient()->browser()-> | 3622 encoding_ = GetContentClient()->browser()-> |
3645 GetCanonicalEncodingNameByAliasName(encoding); | 3623 GetCanonicalEncodingNameByAliasName(encoding); |
3646 } | 3624 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3689 } | 3667 } |
3690 | 3668 |
3691 BrowserPluginGuestManager* | 3669 BrowserPluginGuestManager* |
3692 WebContentsImpl::GetBrowserPluginGuestManager() const { | 3670 WebContentsImpl::GetBrowserPluginGuestManager() const { |
3693 return static_cast<BrowserPluginGuestManager*>( | 3671 return static_cast<BrowserPluginGuestManager*>( |
3694 GetBrowserContext()->GetUserData( | 3672 GetBrowserContext()->GetUserData( |
3695 browser_plugin::kBrowserPluginGuestManagerKeyName)); | 3673 browser_plugin::kBrowserPluginGuestManagerKeyName)); |
3696 } | 3674 } |
3697 | 3675 |
3698 } // namespace content | 3676 } // namespace content |
OLD | NEW |