| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "content/browser/tab_contents/tab_contents_delegate.h" | 12 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 13 #include "content/browser/tab_contents/tab_contents_observer.h" | 13 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "webkit/glue/window_open_disposition.h" | 16 #include "webkit/glue/window_open_disposition.h" |
| 17 | 17 |
| 18 class Profile; | 18 class Profile; |
| 19 | 19 |
| 20 // This class consumes TabContents. It can host a renderer, but does not | 20 // This class consumes TabContents. It can host a renderer, but does not |
| 21 // have any visible display. | 21 // have any visible display. |
| 22 class BackgroundContents : public TabContentsDelegate, | 22 class BackgroundContents : public TabContentsDelegate, |
| 23 public TabContentsObserver, | 23 public TabContentsObserver, |
| 24 public content::NotificationObserver { | 24 public content::NotificationObserver { |
| 25 public: | 25 public: |
| 26 class Delegate { | 26 class Delegate { |
| 27 public: | 27 public: |
| 28 // Called by ShowCreatedWindow. Asks the delegate to attach the opened | 28 // Called by AddNewContents(). Asks the delegate to attach the opened |
| 29 // TabContents to a suitable container (e.g. browser) or to show it if it's | 29 // TabContents to a suitable container (e.g. browser) or to show it if it's |
| 30 // a popup window. | 30 // a popup window. |
| 31 virtual void AddTabContents(TabContents* new_contents, | 31 virtual void AddTabContents(TabContents* new_contents, |
| 32 WindowOpenDisposition disposition, | 32 WindowOpenDisposition disposition, |
| 33 const gfx::Rect& initial_pos, | 33 const gfx::Rect& initial_pos, |
| 34 bool user_gesture) = 0; | 34 bool user_gesture) = 0; |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 virtual ~Delegate() {} | 37 virtual ~Delegate() {} |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 BackgroundContents(SiteInstance* site_instance, | 40 BackgroundContents(SiteInstance* site_instance, |
| 41 int routing_id, | 41 int routing_id, |
| 42 Delegate* delegate); | 42 Delegate* delegate); |
| 43 virtual ~BackgroundContents(); | 43 virtual ~BackgroundContents(); |
| 44 | 44 |
| 45 TabContents* tab_contents() { return tab_contents_.get(); } | 45 TabContents* tab_contents() { return tab_contents_.get(); } |
| 46 virtual const GURL& GetURL() const; | 46 virtual const GURL& GetURL() const; |
| 47 | 47 |
| 48 // TabContentsDelegate implementation: | 48 // TabContentsDelegate implementation: |
| 49 virtual void CloseContents(TabContents* source) OVERRIDE; | 49 virtual void CloseContents(TabContents* source) OVERRIDE; |
| 50 virtual bool ShouldSuppressDialogs() OVERRIDE; | 50 virtual bool ShouldSuppressDialogs() OVERRIDE; |
| 51 virtual void DidNavigateMainFramePostCommit(TabContents* tab) OVERRIDE; | 51 virtual void DidNavigateMainFramePostCommit(TabContents* tab) OVERRIDE; |
| 52 virtual void AddNewContents(TabContents* source, |
| 53 TabContents* new_contents, |
| 54 WindowOpenDisposition disposition, |
| 55 const gfx::Rect& initial_pos, |
| 56 bool user_gesture) OVERRIDE; |
| 52 | 57 |
| 53 // TabContentsObserver implementation: | 58 // TabContentsObserver implementation: |
| 54 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; | 59 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; |
| 55 | 60 |
| 56 // content::NotificationObserver | 61 // content::NotificationObserver |
| 57 virtual void Observe(int type, | 62 virtual void Observe(int type, |
| 58 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
| 59 const content::NotificationDetails& details) OVERRIDE; | 64 const content::NotificationDetails& details) OVERRIDE; |
| 60 | 65 |
| 61 protected: | 66 protected: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 79 BackgroundContents* contents; | 84 BackgroundContents* contents; |
| 80 | 85 |
| 81 // The name of the parent frame for these contents. | 86 // The name of the parent frame for these contents. |
| 82 const string16& frame_name; | 87 const string16& frame_name; |
| 83 | 88 |
| 84 // The ID of the parent application (if any). | 89 // The ID of the parent application (if any). |
| 85 const string16& application_id; | 90 const string16& application_id; |
| 86 }; | 91 }; |
| 87 | 92 |
| 88 #endif // CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ | 93 #endif // CHROME_BROWSER_TAB_CONTENTS_BACKGROUND_CONTENTS_H_ |
| OLD | NEW |