Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/ui/sad_tab_helper.h

Issue 10949011: Switch SadTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, win fix Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/sad_tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SAD_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_UI_SAD_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_SAD_TAB_HELPER_H_ 6 #define CHROME_BROWSER_UI_SAD_TAB_HELPER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/tab_contents/web_contents_user_data.h"
11 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
14 15
15 #if defined(OS_MACOSX) 16 #if defined(OS_MACOSX)
16 #include "base/mac/foundation_util.h" 17 #include "base/mac/foundation_util.h"
17 #endif 18 #endif
18 19
19 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
20 class SadTabController; 21 class SadTabController;
21 #elif defined(TOOLKIT_VIEWS) 22 #elif defined(TOOLKIT_VIEWS)
22 namespace views { 23 namespace views {
23 class Widget; 24 class Widget;
24 } 25 }
25 #elif defined(TOOLKIT_GTK) 26 #elif defined(TOOLKIT_GTK)
26 class SadTabGtk; 27 class SadTabGtk;
27 #endif 28 #endif
28 29
29 // Per-tab class to manage sad tab views. 30 // Per-tab class to manage sad tab views.
30 class SadTabHelper : public content::WebContentsObserver, 31 class SadTabHelper : public content::WebContentsObserver,
31 public content::NotificationObserver { 32 public content::NotificationObserver,
33 public WebContentsUserData<SadTabHelper> {
32 public: 34 public:
33 explicit SadTabHelper(content::WebContents* web_contents);
34 virtual ~SadTabHelper(); 35 virtual ~SadTabHelper();
35 36
36 // Platform specific function to determine if there is a current sad tab page. 37 // Platform specific function to determine if there is a current sad tab page.
37 bool HasSadTab() const; 38 bool HasSadTab() const;
38 39
39 #if defined(TOOLKIT_VIEWS) 40 #if defined(TOOLKIT_VIEWS)
40 views::Widget* sad_tab() { return sad_tab_.get(); } 41 views::Widget* sad_tab() { return sad_tab_.get(); }
41 #endif 42 #endif
42 43
43 private: 44 private:
45 explicit SadTabHelper(content::WebContents* web_contents);
46 static int kUserDataKey;
47 friend class WebContentsUserData<SadTabHelper>;
48
44 // Platform specific function to get an instance of the sad tab page. 49 // Platform specific function to get an instance of the sad tab page.
45 void InstallSadTab(base::TerminationStatus status); 50 void InstallSadTab(base::TerminationStatus status);
46 51
47 // Overridden from content::WebContentsObserver: 52 // Overridden from content::WebContentsObserver:
48 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 53 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
49 54
50 // Overridden from content::NotificationObserver: 55 // Overridden from content::NotificationObserver:
51 virtual void Observe(int type, 56 virtual void Observe(int type,
52 const content::NotificationSource& source, 57 const content::NotificationSource& source,
53 const content::NotificationDetails& details) OVERRIDE; 58 const content::NotificationDetails& details) OVERRIDE;
(...skipping 13 matching lines...) Expand all
67 #elif defined(TOOLKIT_VIEWS) 72 #elif defined(TOOLKIT_VIEWS)
68 scoped_ptr<views::Widget> sad_tab_; 73 scoped_ptr<views::Widget> sad_tab_;
69 #elif defined(TOOLKIT_GTK) 74 #elif defined(TOOLKIT_GTK)
70 scoped_ptr<SadTabGtk> sad_tab_; 75 scoped_ptr<SadTabGtk> sad_tab_;
71 #endif 76 #endif
72 77
73 DISALLOW_COPY_AND_ASSIGN(SadTabHelper); 78 DISALLOW_COPY_AND_ASSIGN(SadTabHelper);
74 }; 79 };
75 80
76 #endif // CHROME_BROWSER_UI_SAD_TAB_HELPER_H_ 81 #endif // CHROME_BROWSER_UI_SAD_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/sad_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698