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 #ifndef CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_ |
6 #define CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_ |
7 | 7 |
| 8 #include "base/time.h" |
8 #include "content/public/browser/web_contents_observer.h" | 9 #include "content/public/browser/web_contents_observer.h" |
9 #include "content/public/browser/web_contents_user_data.h" | 10 #include "content/public/browser/web_contents_user_data.h" |
10 | 11 |
11 class CoreTabHelperDelegate; | 12 class CoreTabHelperDelegate; |
12 | 13 |
13 // Per-tab class to handle functionality that is core to the operation of tabs. | 14 // Per-tab class to handle functionality that is core to the operation of tabs. |
14 class CoreTabHelper : public content::WebContentsObserver, | 15 class CoreTabHelper : public content::WebContentsObserver, |
15 public content::WebContentsUserData<CoreTabHelper> { | 16 public content::WebContentsUserData<CoreTabHelper> { |
16 public: | 17 public: |
17 virtual ~CoreTabHelper(); | 18 virtual ~CoreTabHelper(); |
18 | 19 |
19 CoreTabHelperDelegate* delegate() const { return delegate_; } | |
20 void set_delegate(CoreTabHelperDelegate* d) { delegate_ = d; } | |
21 | |
22 // Initial title assigned to NavigationEntries from Navigate. | 20 // Initial title assigned to NavigationEntries from Navigate. |
23 static string16 GetDefaultTitle(); | 21 static string16 GetDefaultTitle(); |
24 | 22 |
25 // Returns a human-readable description the tab's loading state. | 23 // Returns a human-readable description the tab's loading state. |
26 string16 GetStatusText() const; | 24 string16 GetStatusText() const; |
27 | 25 |
| 26 // Notification that tab closing has started. This can be called multiple |
| 27 // times, subsequent calls are ignored. |
| 28 void OnCloseStarted(); |
| 29 |
| 30 // Notification that tab closing was cancelled. This can happen when a user |
| 31 // cancels a window close via another tab's beforeunload dialog. |
| 32 void OnCloseCanceled(); |
| 33 |
| 34 CoreTabHelperDelegate* delegate() const { return delegate_; } |
| 35 void set_delegate(CoreTabHelperDelegate* d) { delegate_ = d; } |
| 36 |
| 37 void set_new_tab_start_time(const base::TimeTicks& time) { |
| 38 new_tab_start_time_ = time; |
| 39 } |
| 40 |
| 41 base::TimeTicks new_tab_start_time() const { return new_tab_start_time_; } |
| 42 |
28 private: | 43 private: |
29 explicit CoreTabHelper(content::WebContents* web_contents); | 44 explicit CoreTabHelper(content::WebContents* web_contents); |
30 friend class content::WebContentsUserData<CoreTabHelper>; | 45 friend class content::WebContentsUserData<CoreTabHelper>; |
31 | 46 |
32 // content::WebContentsObserver overrides: | 47 // content::WebContentsObserver overrides: |
33 virtual void WasShown() OVERRIDE; | 48 virtual void WasShown() OVERRIDE; |
| 49 virtual void WebContentsDestroyed( |
| 50 content::WebContents* web_contents) OVERRIDE; |
| 51 virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE; |
| 52 virtual void BeforeUnloadDialogCancelled() OVERRIDE; |
34 | 53 |
35 // Delegate for notifying our owner about stuff. Not owned by us. | 54 // Delegate for notifying our owner about stuff. Not owned by us. |
36 CoreTabHelperDelegate* delegate_; | 55 CoreTabHelperDelegate* delegate_; |
37 | 56 |
| 57 // The time when we started to create the new tab page. This time is from |
| 58 // before we created this WebContents. |
| 59 base::TimeTicks new_tab_start_time_; |
| 60 |
| 61 // The time that we started to close this WebContents. |
| 62 base::TimeTicks close_start_time_; |
| 63 |
| 64 // The time when onbeforeunload ended. |
| 65 base::TimeTicks before_unload_end_time_; |
| 66 |
38 DISALLOW_COPY_AND_ASSIGN(CoreTabHelper); | 67 DISALLOW_COPY_AND_ASSIGN(CoreTabHelper); |
39 }; | 68 }; |
40 | 69 |
41 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_ | 70 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_ |
OLD | NEW |