Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_SAD_TAB_OBSERVER_H_ | |
| 6 #define CHROME_BROWSER_UI_SAD_TAB_OBSERVER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "content/browser/tab_contents/tab_contents_observer.h" | |
| 11 #include "content/public/browser/notification_observer.h" | |
| 12 #include "content/public/browser/notification_registrar.h" | |
| 13 #include "ui/gfx/native_widget_types.h" | |
| 14 | |
| 15 #if defined(OS_MACOSX) | |
| 16 #include "base/mac/foundation_util.h" | |
| 17 #endif | |
| 18 | |
| 19 #if defined(OS_MACOSX) | |
| 20 class SadTabController; | |
| 21 #elif defined(TOOLKIT_VIEWS) | |
| 22 namespace views { | |
| 23 class Widget; | |
| 24 } | |
| 25 #elif defined(TOOLKIT_GTK) | |
| 26 class SadTabGtk; | |
| 27 #endif | |
| 28 | |
| 29 // Per-tab class to manage sad tab views. | |
| 30 class SadTabObserver : public TabContentsObserver, | |
| 31 public content::NotificationObserver { | |
| 32 public: | |
| 33 explicit SadTabObserver(TabContents* tab_contents); | |
| 34 virtual ~SadTabObserver(); | |
| 35 | |
| 36 private: | |
| 37 // Platform specific function to get an instance of the sad tab page. | |
| 38 gfx::NativeView AcquireSadTab(base::TerminationStatus status); | |
| 39 | |
| 40 // Platform specific function to release the instance of the sad tab page. | |
| 41 void ReleaseSadTab(); | |
| 42 | |
| 43 // Platform specific function to determine if there is a current sad tab page. | |
| 44 bool HasSadTab(); | |
| 45 | |
| 46 // Overridden from TabContentsObserver: | |
| 47 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | |
| 48 | |
| 49 // Overridden from content::NotificationObserver: | |
| 50 virtual void Observe(int type, | |
| 51 const content::NotificationSource& source, | |
| 52 const content::NotificationDetails& details) OVERRIDE; | |
| 53 | |
| 54 // Used to get notifications about renderers coming and going. | |
| 55 content::NotificationRegistrar registrar_; | |
| 56 | |
| 57 // The platform views used to render the sad tab, non-NULL if visible. | |
| 58 #if defined(OS_MACOSX) | |
| 59 class ScopedPtrRelease { | |
|
jochen (gone - plz use gerrit)
2011/11/14 16:44:54
shouldn't that go into some base/ header?
Avi (use Gerrit)
2011/11/14 20:00:50
This is a hack; this is building the equivalent of
| |
| 60 public: | |
| 61 inline void operator()(void* x) const { | |
| 62 base::mac::NSObjectRelease(x); | |
| 63 } | |
| 64 }; | |
| 65 scoped_ptr_malloc<SadTabController, ScopedPtrRelease> sad_tab_; | |
| 66 #elif defined(TOOLKIT_VIEWS) | |
| 67 scoped_ptr<views::Widget> sad_tab_; | |
| 68 #elif defined(TOOLKIT_GTK) | |
| 69 scoped_ptr<SadTabGtk> sad_tab_; | |
| 70 #endif | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(SadTabObserver); | |
| 73 }; | |
| 74 | |
| 75 #endif // CHROME_BROWSER_UI_SAD_TAB_OBSERVER_H_ | |
| OLD | NEW |