summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.cc7
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.h5
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc39
-rw-r--r--chrome/browser/tab_contents/tab_contents.h18
4 files changed, 45 insertions, 24 deletions
diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc
index 29afb4a..3b58f2f 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.cc
+++ b/chrome/browser/tab_contents/render_view_host_manager.cc
@@ -205,13 +205,6 @@ void RenderViewHostManager::RendererAbortedProvisionalLoad(
// the response is not a download.
}
-void RenderViewHostManager::OnJavaScriptMessageBoxClosed(
- IPC::Message* reply_msg,
- bool success,
- const std::wstring& prompt) {
- render_view_host_->JavaScriptMessageBoxClosed(reply_msg, success, prompt);
-}
-
void RenderViewHostManager::ShouldClosePage(bool for_cross_site_transition,
bool proceed) {
if (for_cross_site_transition) {
diff --git a/chrome/browser/tab_contents/render_view_host_manager.h b/chrome/browser/tab_contents/render_view_host_manager.h
index 8d168cf..56da857 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.h
+++ b/chrome/browser/tab_contents/render_view_host_manager.h
@@ -134,11 +134,6 @@ class RenderViewHostManager
// Called when a provisional load on the given renderer is aborted.
void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host);
- // Forwards the message to the RenderViewHost, which is the original one.
- void OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg,
- bool success,
- const std::wstring& prompt);
-
// Sets the passed passed interstitial as the currently showing interstitial.
// |interstitial_page| should be non NULL (use the remove_interstitial_page
// method to unset the interstitial) and no interstitial page should be set
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index c4b5a7a..a526207 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -265,6 +265,7 @@ TabContents::TabContents(Profile* profile,
#endif
last_javascript_message_dismissal_(),
suppress_javascript_messages_(false),
+ is_showing_before_unload_dialog_(false),
opener_dom_ui_type_(DOMUIFactory::kNoDOMUI) {
pending_install_.page_id = 0;
pending_install_.callback_functor = NULL;
@@ -374,6 +375,12 @@ TabContents::~TabContents() {
if (GetNativeView())
::DestroyWindow(GetNativeView());
#endif
+
+ // OnCloseStarted isn't called in unit tests.
+ if (!tab_close_start_time_.is_null()) {
+ UMA_HISTOGRAM_TIMES("Tab.Close",
+ base::TimeTicks::Now() - tab_close_start_time_);
+ }
}
// static
@@ -1112,7 +1119,15 @@ void TabContents::OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg,
bool success,
const std::wstring& prompt) {
last_javascript_message_dismissal_ = base::TimeTicks::Now();
- render_manager_.OnJavaScriptMessageBoxClosed(reply_msg, success, prompt);
+ if (is_showing_before_unload_dialog_ && !success) {
+ // If a beforeunload dialog is canceled, we need to stop the throbber from
+ // spinning, since we forced it to start spinning in Navigate.
+ DidStopLoading();
+
+ tab_close_start_time_ = base::TimeTicks();
+ }
+ is_showing_before_unload_dialog_ = false;
+ render_view_host()->JavaScriptMessageBoxClosed(reply_msg, success, prompt);
}
void TabContents::OnSavePage() {
@@ -1180,12 +1195,12 @@ void TabContents::LogNewTabTime(const std::string& event_name) {
MetricEventDurationDetails details(event_name,
static_cast<int>(duration.InMilliseconds()));
- if (event_name == "NewTab.ScriptStart") {
- UMA_HISTOGRAM_TIMES("NewTab.ScriptStart", duration);
- } else if (event_name == "NewTab.DOMContentLoaded") {
- UMA_HISTOGRAM_TIMES("NewTab.DOMContentLoaded", duration);
- } else if (event_name == "NewTab.Onload") {
- UMA_HISTOGRAM_TIMES("NewTab.Onload", duration);
+ if (event_name == "Tab.NewTabScriptStart") {
+ UMA_HISTOGRAM_TIMES("Tab.NewTabScriptStart", duration);
+ } else if (event_name == "Tab.NewTabDOMContentLoaded") {
+ UMA_HISTOGRAM_TIMES("Tab.NewTabDOMContentLoaded", duration);
+ } else if (event_name == "Tab.NewTabOnload") {
+ UMA_HISTOGRAM_TIMES("Tab.NewTabOnload", duration);
// The new tab page has finished loading; reset it.
new_tab_start_time_ = base::TimeTicks();
} else {
@@ -1197,6 +1212,11 @@ void TabContents::LogNewTabTime(const std::string& event_name) {
Details<MetricEventDurationDetails>(&details));
}
+void TabContents::OnCloseStarted() {
+ if (tab_close_start_time_.is_null())
+ tab_close_start_time_ = base::TimeTicks::Now();
+}
+
// Notifies the RenderWidgetHost instance about the fact that the page is
// loading, or done loading and calls the base implementation.
void TabContents::SetIsLoading(bool is_loading,
@@ -2150,11 +2170,11 @@ void TabContents::RequestMove(const gfx::Rect& new_bounds) {
delegate()->MoveContents(this, new_bounds);
}
-void TabContents::DidStartLoading(RenderViewHost* rvh) {
+void TabContents::DidStartLoading() {
SetIsLoading(true, NULL);
}
-void TabContents::DidStopLoading(RenderViewHost* rvh) {
+void TabContents::DidStopLoading() {
scoped_ptr<LoadNotificationDetails> details;
NavigationEntry* entry = controller_.GetActiveEntry();
@@ -2293,6 +2313,7 @@ void TabContents::RunJavaScriptMessage(
void TabContents::RunBeforeUnloadConfirm(const std::wstring& message,
IPC::Message* reply_msg) {
+ is_showing_before_unload_dialog_ = true;
RunBeforeUnloadDialog(this, message, reply_msg);
}
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 6e8c8d0..99db09c 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -623,6 +623,10 @@ class TabContents : public PageNavigator,
new_tab_start_time_ = time;
}
+ // Notification that tab closing has started. This can be called multiple
+ // times, subsequent calls are ignored.
+ void OnCloseStarted();
+
private:
friend class NavigationController;
// Used to access the child_windows_ (ConstrainedWindowList) for testing
@@ -866,8 +870,8 @@ class TabContents : public PageNavigator,
virtual void UpdateInspectorSettings(const std::string& raw_settings);
virtual void Close(RenderViewHost* render_view_host);
virtual void RequestMove(const gfx::Rect& new_bounds);
- virtual void DidStartLoading(RenderViewHost* render_view_host);
- virtual void DidStopLoading(RenderViewHost* render_view_host);
+ virtual void DidStartLoading();
+ virtual void DidStopLoading();
virtual void RequestOpenURL(const GURL& url, const GURL& referrer,
WindowOpenDisposition disposition);
virtual void DomOperationResponse(const std::string& json_string,
@@ -928,7 +932,7 @@ class TabContents : public PageNavigator,
bool* proceed_to_fire_unload);
virtual void DidStartLoadingFromRenderManager(
RenderViewHost* render_view_host) {
- DidStartLoading(render_view_host);
+ DidStartLoading();
}
virtual void RenderViewGoneFromRenderManager(
RenderViewHost* render_view_host) {
@@ -1146,6 +1150,11 @@ class TabContents : public PageNavigator,
// reset on navigations to false on navigations.
bool suppress_javascript_messages_;
+ // Set to true when there is an active "before unload" dialog. When true,
+ // we've forced the throbber to start in Navigate, and we need to remember to
+ // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
+ bool is_showing_before_unload_dialog_;
+
// Shows an info-bar to users when they search from a known search engine and
// have never used the monibox for search before.
scoped_ptr<OmniboxSearchHint> omnibox_search_hint_;
@@ -1160,6 +1169,9 @@ class TabContents : public PageNavigator,
// The time that we started to create the new tab page.
base::TimeTicks new_tab_start_time_;
+ // The time that we started to close the tab.
+ base::TimeTicks tab_close_start_time_;
+
// ---------------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(TabContents);