summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/browser_tabstrip.cc5
-rw-r--r--chrome/browser/ui/cocoa/applescript/window_applescript.mm8
-rw-r--r--chrome/browser/ui/tab_contents/core_tab_helper.cc48
-rw-r--r--chrome/browser/ui/tab_contents/core_tab_helper.h46
-rw-r--r--chrome/browser/ui/tabs/tab_strip_model.cc4
-rw-r--r--chrome/browser/ui/unload_controller.cc22
-rw-r--r--chrome/browser/ui/unload_controller.h2
-rw-r--r--chrome/browser/ui/webui/metrics_handler.cc10
8 files changed, 16 insertions, 129 deletions
diff --git a/chrome/browser/ui/browser_tabstrip.cc b/chrome/browser/ui/browser_tabstrip.cc
index 9ffa615..aa308e0 100644
--- a/chrome/browser/ui/browser_tabstrip.cc
+++ b/chrome/browser/ui/browser_tabstrip.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
@@ -29,9 +28,7 @@ void AddBlankTabAt(Browser* browser, int index, bool foreground) {
params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
params.tabstrip_index = index;
chrome::Navigate(&params);
- CoreTabHelper* core_tab_helper =
- CoreTabHelper::FromWebContents(params.target_contents);
- core_tab_helper->set_new_tab_start_time(new_tab_start_time);
+ params.target_contents->SetNewTabStartTime(new_tab_start_time);
}
content::WebContents* AddSelectedTabWithURL(
diff --git a/chrome/browser/ui/cocoa/applescript/window_applescript.mm b/chrome/browser/ui/cocoa/applescript/window_applescript.mm
index fe6677f..fe9e055 100644
--- a/chrome/browser/ui/cocoa/applescript/window_applescript.mm
+++ b/chrome/browser/ui/cocoa/applescript/window_applescript.mm
@@ -21,7 +21,6 @@
#include "chrome/browser/ui/cocoa/applescript/error_applescript.h"
#import "chrome/browser/ui/cocoa/applescript/tab_applescript.h"
#include "chrome/browser/ui/host_desktop.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_contents.h"
@@ -180,8 +179,7 @@
browser_,
GURL(chrome::kChromeUINewTabURL),
content::PAGE_TRANSITION_TYPED);
- CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
- core_tab_helper->set_new_tab_start_time(newTabStartTime);
+ contents->SetNewTabStartTime(newTabStartTime);
[aTab setWebContents:contents];
}
@@ -198,9 +196,7 @@
params.disposition = NEW_FOREGROUND_TAB;
params.tabstrip_index = index;
chrome::Navigate(&params);
- CoreTabHelper* core_tab_helper =
- CoreTabHelper::FromWebContents(params.target_contents);
- core_tab_helper->set_new_tab_start_time(newTabStartTime);
+ params.target_contents->SetNewTabStartTime(newTabStartTime);
[aTab setWebContents:params.target_contents];
}
diff --git a/chrome/browser/ui/tab_contents/core_tab_helper.cc b/chrome/browser/ui/tab_contents/core_tab_helper.cc
index f8dc42e..502a3f8 100644
--- a/chrome/browser/ui/tab_contents/core_tab_helper.cc
+++ b/chrome/browser/ui/tab_contents/core_tab_helper.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
-#include "base/metrics/histogram.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -85,26 +84,6 @@ string16 CoreTabHelper::GetStatusText() const {
return string16();
}
-void CoreTabHelper::OnCloseStarted() {
- if (close_start_time_.is_null())
- close_start_time_ = base::TimeTicks::Now();
-}
-
-void CoreTabHelper::OnCloseCanceled() {
- close_start_time_ = base::TimeTicks();
- before_unload_end_time_ = base::TimeTicks();
- unload_detached_start_time_ = base::TimeTicks();
-}
-
-void CoreTabHelper::OnUnloadStarted() {
- before_unload_end_time_ = base::TimeTicks::Now();
-}
-
-void CoreTabHelper::OnUnloadDetachedStarted() {
- if (unload_detached_start_time_.is_null())
- unload_detached_start_time_ = base::TimeTicks::Now();
-}
-
////////////////////////////////////////////////////////////////////////////////
// WebContentsObserver overrides
@@ -112,30 +91,3 @@ void CoreTabHelper::WasShown() {
WebCacheManager::GetInstance()->ObserveActivity(
web_contents()->GetRenderProcessHost()->GetID());
}
-
-void CoreTabHelper::WebContentsDestroyed(WebContents* web_contents) {
- // OnCloseStarted isn't called in unit tests.
- if (!close_start_time_.is_null()) {
- base::TimeTicks now = base::TimeTicks::Now();
- base::TimeDelta close_time = now - close_start_time_;
- UMA_HISTOGRAM_TIMES("Tab.Close", close_time);
-
- base::TimeTicks unload_start_time = close_start_time_;
- base::TimeTicks unload_end_time = now;
- if (!before_unload_end_time_.is_null())
- unload_start_time = before_unload_end_time_;
- if (!unload_detached_start_time_.is_null())
- unload_end_time = unload_detached_start_time_;
- base::TimeDelta unload_time = unload_end_time - unload_start_time;
- UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time);
-
- }
-}
-
-void CoreTabHelper::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
- before_unload_end_time_ = proceed_time;
-}
-
-void CoreTabHelper::BeforeUnloadDialogCancelled() {
- OnCloseCanceled();
-}
diff --git a/chrome/browser/ui/tab_contents/core_tab_helper.h b/chrome/browser/ui/tab_contents/core_tab_helper.h
index e5a37dd..834613e 100644
--- a/chrome/browser/ui/tab_contents/core_tab_helper.h
+++ b/chrome/browser/ui/tab_contents/core_tab_helper.h
@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_
#define CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_
-#include "base/time.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
@@ -17,64 +16,25 @@ class CoreTabHelper : public content::WebContentsObserver,
public:
virtual ~CoreTabHelper();
+ CoreTabHelperDelegate* delegate() const { return delegate_; }
+ void set_delegate(CoreTabHelperDelegate* d) { delegate_ = d; }
+
// Initial title assigned to NavigationEntries from Navigate.
static string16 GetDefaultTitle();
// Returns a human-readable description the tab's loading state.
string16 GetStatusText() const;
- // Notification that tab closing has started. This can be called multiple
- // times, subsequent calls are ignored.
- void OnCloseStarted();
-
- // Notification that tab closing was cancelled. This can happen when a user
- // cancels a window close via another tab's beforeunload dialog.
- void OnCloseCanceled();
-
- // Set the time during close when unload is started. Normally, this is set
- // after the beforeunload dialog. However, for a window close, it is set
- // after all the beforeunload dialogs have finished.
- void OnUnloadStarted();
-
- // Set the time during close when the tab is no longer visible.
- void OnUnloadDetachedStarted();
-
- CoreTabHelperDelegate* delegate() const { return delegate_; }
- void set_delegate(CoreTabHelperDelegate* d) { delegate_ = d; }
-
- void set_new_tab_start_time(const base::TimeTicks& time) {
- new_tab_start_time_ = time;
- }
-
- base::TimeTicks new_tab_start_time() const { return new_tab_start_time_; }
-
private:
explicit CoreTabHelper(content::WebContents* web_contents);
friend class content::WebContentsUserData<CoreTabHelper>;
// content::WebContentsObserver overrides:
virtual void WasShown() OVERRIDE;
- virtual void WebContentsDestroyed(
- content::WebContents* web_contents) OVERRIDE;
- virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
- virtual void BeforeUnloadDialogCancelled() OVERRIDE;
// Delegate for notifying our owner about stuff. Not owned by us.
CoreTabHelperDelegate* delegate_;
- // The time when we started to create the new tab page. This time is from
- // before we created this WebContents.
- base::TimeTicks new_tab_start_time_;
-
- // The time that we started to close this WebContents.
- base::TimeTicks close_start_time_;
-
- // The time when onbeforeunload ended.
- base::TimeTicks before_unload_end_time_;
-
- // The time when the tab was removed from view during close.
- base::TimeTicks unload_detached_start_time_;
-
DISALLOW_COPY_AND_ASSIGN(CoreTabHelper);
};
diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc
index a550ca0..78c8f0e 100644
--- a/chrome/browser/ui/tabs/tab_strip_model.cc
+++ b/chrome/browser/ui/tabs/tab_strip_model.cc
@@ -1115,9 +1115,7 @@ bool TabStripModel::InternalCloseTabs(const std::vector<int>& indices,
if (index == kNoTab)
continue;
- CoreTabHelper* core_tab_helper =
- CoreTabHelper::FromWebContents(closing_contents);
- core_tab_helper->OnCloseStarted();
+ closing_contents->OnCloseStarted();
// Update the explicitly closed state. If the unload handlers cancel the
// close the state is reset in Browser. We don't update the explicitly
diff --git a/chrome/browser/ui/unload_controller.cc b/chrome/browser/ui/unload_controller.cc
index 19d6154..b52348c 100644
--- a/chrome/browser/ui/unload_controller.cc
+++ b/chrome/browser/ui/unload_controller.cc
@@ -8,7 +8,6 @@
#include "base/message_loop.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
#include "chrome/common/chrome_notification_types.h"
@@ -223,8 +222,7 @@ bool UnloadController::DetachWebContents(content::WebContents* contents) {
tabs_needing_unload_ack_.insert(contents);
browser_->tab_strip_model()->DetachWebContentsAt(index);
contents->SetDelegate(detached_delegate_.get());
- CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
- core_tab_helper->OnUnloadDetachedStarted();
+ contents->OnUnloadDetachedStarted();
return true;
}
return false;
@@ -252,10 +250,7 @@ void UnloadController::ProcessPendingTabs() {
// the tab's render_view_host may have been nulled out.
if (contents->GetRenderViewHost()) {
tab_needing_before_unload_ack_ = contents;
-
- CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
- core_tab_helper->OnCloseStarted();
-
+ contents->OnCloseStarted();
contents->GetRenderViewHost()->FirePageBeforeUnload(false);
} else {
ProcessPendingTabs();
@@ -276,9 +271,7 @@ void UnloadController::ProcessPendingTabs() {
// Null check render_view_host here as this gets called on a PostTask
// and the tab's render_view_host may have been nulled out.
if (contents->GetRenderViewHost()) {
- CoreTabHelper* core_tab_helper =
- CoreTabHelper::FromWebContents(contents);
- core_tab_helper->OnUnloadStarted();
+ contents->OnUnloadStarted();
DetachWebContents(contents);
contents->GetRenderViewHost()->ClosePage();
}
@@ -320,18 +313,13 @@ void UnloadController::CancelWindowClose() {
DCHECK(is_attempting_to_close_browser_);
tabs_needing_before_unload_.clear();
if (tab_needing_before_unload_ack_ != NULL) {
-
- CoreTabHelper* core_tab_helper =
- CoreTabHelper::FromWebContents(tab_needing_before_unload_ack_);
- core_tab_helper->OnCloseCanceled();
+ tab_needing_before_unload_ack_->OnCloseCanceled();
tab_needing_before_unload_ack_ = NULL;
}
for (WebContentsSet::iterator it = tabs_needing_unload_.begin();
it != tabs_needing_unload_.end(); it++) {
content::WebContents* contents = *it;
-
- CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
- core_tab_helper->OnCloseCanceled();
+ contents->OnCloseCanceled();
}
tabs_needing_unload_.clear();
diff --git a/chrome/browser/ui/unload_controller.h b/chrome/browser/ui/unload_controller.h
index 47e50b0..d18ba8d 100644
--- a/chrome/browser/ui/unload_controller.h
+++ b/chrome/browser/ui/unload_controller.h
@@ -41,7 +41,7 @@ namespace chrome {
// If beforeunload/unload handlers need to run, UnloadController returns
// true and calls ProcessPendingTabs() (private method).
// 2. For each tab with a beforeunload/unload handler, ProcessPendingTabs()
-// calls |CoreTabHelper::OnCloseStarted()|
+// calls |web_contents->OnCloseStarted()|
// and |web_contents->GetRenderViewHost()->FirePageBeforeUnload()|.
// 3. If the user allowed the close to continue, we detach all the tabs with
// unload handlers, remove them from the tab strip, and finish closing
diff --git a/chrome/browser/ui/webui/metrics_handler.cc b/chrome/browser/ui/webui/metrics_handler.cc
index 9394e07..b57ce0f 100644
--- a/chrome/browser/ui/webui/metrics_handler.cc
+++ b/chrome/browser/ui/webui/metrics_handler.cc
@@ -11,7 +11,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/metrics/metric_event_duration_details.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/user_metrics.h"
@@ -83,12 +82,10 @@ void MetricsHandler::HandleLogEventTime(const ListValue* args) {
// Not all new tab pages get timed. In those cases, we don't have a
// new_tab_start_time_.
- CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(tab);
- if (core_tab_helper->new_tab_start_time().is_null())
+ if (tab->GetNewTabStartTime().is_null())
return;
- base::TimeDelta duration =
- base::TimeTicks::Now() - core_tab_helper->new_tab_start_time();
+ base::TimeDelta duration = base::TimeTicks::Now() - tab->GetNewTabStartTime();
MetricEventDurationDetails details(event_name,
static_cast<int>(duration.InMilliseconds()));
@@ -99,8 +96,7 @@ void MetricsHandler::HandleLogEventTime(const ListValue* args) {
} else if (event_name == "Tab.NewTabOnload") {
UMA_HISTOGRAM_TIMES("Tab.NewTabOnload", duration);
// The new tab page has finished loading; reset it.
- CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(tab);
- core_tab_helper->set_new_tab_start_time(base::TimeTicks());
+ tab->SetNewTabStartTime(base::TimeTicks());
} else {
NOTREACHED();
}