Chromium Code Reviews| 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_BACKGROUND_BACKGROUND_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_H_ |
| 6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_H_ | 6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "content/public/browser/web_contents_delegate.h" | 13 #include "content/public/browser/web_contents_delegate.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "extensions/browser/delayed_start_render_host.h" | |
| 15 #include "ui/base/window_open_disposition.h" | 16 #include "ui/base/window_open_disposition.h" |
| 17 #include "url/gurl.h" | |
| 16 | 18 |
| 17 class Profile; | 19 class Profile; |
| 18 | 20 |
| 19 namespace content { | 21 namespace content { |
| 20 class SessionStorageNamespace; | 22 class SessionStorageNamespace; |
| 21 class SiteInstance; | 23 class SiteInstance; |
| 22 }; | 24 }; |
| 23 | 25 |
| 24 // This class maintains a WebContents used in the background. It can host a | 26 // This class maintains a WebContents used in the background. It can host a |
| 25 // renderer, but does not have any visible display. | 27 // renderer, but does not have any visible display. |
| 26 // TODO(atwilson): Unify this with background pages; http://crbug.com/77790 | 28 // TODO(atwilson): Unify this with background pages; http://crbug.com/77790 |
| 27 class BackgroundContents : public content::WebContentsDelegate, | 29 class BackgroundContents : public extensions::DelayedStartRenderHost, |
| 30 public content::WebContentsDelegate, | |
| 28 public content::WebContentsObserver, | 31 public content::WebContentsObserver, |
| 29 public content::NotificationObserver { | 32 public content::NotificationObserver { |
| 30 public: | 33 public: |
| 31 class Delegate { | 34 class Delegate { |
| 32 public: | 35 public: |
| 33 // Called by AddNewContents(). Asks the delegate to attach the opened | 36 // Called by AddNewContents(). Asks the delegate to attach the opened |
| 34 // WebContents to a suitable container (e.g. browser) or to show it if it's | 37 // WebContents to a suitable container (e.g. browser) or to show it if it's |
| 35 // a popup window. If |was_blocked| is non-NULL, then |*was_blocked| will be | 38 // a popup window. If |was_blocked| is non-NULL, then |*was_blocked| will be |
| 36 // set to true if the popup gets blocked, and left unchanged otherwise. | 39 // set to true if the popup gets blocked, and left unchanged otherwise. |
| 37 virtual void AddWebContents(content::WebContents* new_contents, | 40 virtual void AddWebContents(content::WebContents* new_contents, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 49 int routing_id, | 52 int routing_id, |
| 50 int main_frame_routing_id, | 53 int main_frame_routing_id, |
| 51 Delegate* delegate, | 54 Delegate* delegate, |
| 52 const std::string& partition_id, | 55 const std::string& partition_id, |
| 53 content::SessionStorageNamespace* session_storage_namespace); | 56 content::SessionStorageNamespace* session_storage_namespace); |
| 54 ~BackgroundContents() override; | 57 ~BackgroundContents() override; |
| 55 | 58 |
| 56 content::WebContents* web_contents() const { return web_contents_.get(); } | 59 content::WebContents* web_contents() const { return web_contents_.get(); } |
| 57 virtual const GURL& GetURL() const; | 60 virtual const GURL& GetURL() const; |
| 58 | 61 |
| 62 // Adds this BackgroundContents to the queue of RenderViews to create. | |
| 63 void CreateRenderViewSoon(const GURL& url); | |
| 64 | |
| 65 // DelayedStartRenderHost implementation: | |
| 66 void CreateRenderViewNow() override; | |
|
Devlin
2015/02/18 23:22:12
We can actually make this private now (same for ex
Yoyo Zhou
2015/02/19 02:55:37
Cool, I didn't know you could do that.
Devlin
2015/02/19 16:41:43
Handy for these implementation-detail-type interfa
| |
| 67 | |
| 59 // content::WebContentsDelegate implementation: | 68 // content::WebContentsDelegate implementation: |
| 60 void CloseContents(content::WebContents* source) override; | 69 void CloseContents(content::WebContents* source) override; |
| 61 bool ShouldSuppressDialogs(content::WebContents* source) override; | 70 bool ShouldSuppressDialogs(content::WebContents* source) override; |
| 62 void DidNavigateMainFramePostCommit(content::WebContents* tab) override; | 71 void DidNavigateMainFramePostCommit(content::WebContents* tab) override; |
| 63 void AddNewContents(content::WebContents* source, | 72 void AddNewContents(content::WebContents* source, |
| 64 content::WebContents* new_contents, | 73 content::WebContents* new_contents, |
| 65 WindowOpenDisposition disposition, | 74 WindowOpenDisposition disposition, |
| 66 const gfx::Rect& initial_rect, | 75 const gfx::Rect& initial_rect, |
| 67 bool user_gesture, | 76 bool user_gesture, |
| 68 bool* was_blocked) override; | 77 bool* was_blocked) override; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 81 BackgroundContents(); | 90 BackgroundContents(); |
| 82 | 91 |
| 83 private: | 92 private: |
| 84 // The delegate for this BackgroundContents. | 93 // The delegate for this BackgroundContents. |
| 85 Delegate* delegate_; | 94 Delegate* delegate_; |
| 86 | 95 |
| 87 Profile* profile_; | 96 Profile* profile_; |
| 88 scoped_ptr<content::WebContents> web_contents_; | 97 scoped_ptr<content::WebContents> web_contents_; |
| 89 content::NotificationRegistrar registrar_; | 98 content::NotificationRegistrar registrar_; |
| 90 | 99 |
| 100 // The initial URL to load. | |
| 101 GURL initial_url_; | |
| 102 | |
| 91 DISALLOW_COPY_AND_ASSIGN(BackgroundContents); | 103 DISALLOW_COPY_AND_ASSIGN(BackgroundContents); |
| 92 }; | 104 }; |
| 93 | 105 |
| 94 // This is the data sent out as the details with BACKGROUND_CONTENTS_OPENED. | 106 // This is the data sent out as the details with BACKGROUND_CONTENTS_OPENED. |
| 95 struct BackgroundContentsOpenedDetails { | 107 struct BackgroundContentsOpenedDetails { |
| 96 // The BackgroundContents object that has just been opened. | 108 // The BackgroundContents object that has just been opened. |
| 97 BackgroundContents* contents; | 109 BackgroundContents* contents; |
| 98 | 110 |
| 99 // The name of the parent frame for these contents. | 111 // The name of the parent frame for these contents. |
| 100 const base::string16& frame_name; | 112 const base::string16& frame_name; |
| 101 | 113 |
| 102 // The ID of the parent application (if any). | 114 // The ID of the parent application (if any). |
| 103 const base::string16& application_id; | 115 const base::string16& application_id; |
| 104 }; | 116 }; |
| 105 | 117 |
| 106 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_H_ | 118 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_H_ |
| OLD | NEW |