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

Side by Side Diff: chrome/browser/background/background_contents.h

Issue 955713004: Merge 317853 - Make BackgroundContentsService start up BackgroundContents with a delay, as for Exte… (Closed) Base URL: https://chromium.googlesource.com/chromium/src@2311
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/background/background_contents.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) 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/deferred_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
26 namespace extensions {
27 class ExtensionHostDelegate;
28 }
29
24 // This class maintains a WebContents used in the background. It can host a 30 // This class maintains a WebContents used in the background. It can host a
25 // renderer, but does not have any visible display. 31 // renderer, but does not have any visible display.
26 // TODO(atwilson): Unify this with background pages; http://crbug.com/77790 32 // TODO(atwilson): Unify this with background pages; http://crbug.com/77790
27 class BackgroundContents : public content::WebContentsDelegate, 33 class BackgroundContents : public extensions::DeferredStartRenderHost,
34 public content::WebContentsDelegate,
28 public content::WebContentsObserver, 35 public content::WebContentsObserver,
29 public content::NotificationObserver { 36 public content::NotificationObserver {
30 public: 37 public:
31 class Delegate { 38 class Delegate {
32 public: 39 public:
33 // Called by AddNewContents(). Asks the delegate to attach the opened 40 // 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 41 // 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 42 // 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. 43 // set to true if the popup gets blocked, and left unchanged otherwise.
37 virtual void AddWebContents(content::WebContents* new_contents, 44 virtual void AddWebContents(content::WebContents* new_contents,
(...skipping 11 matching lines...) Expand all
49 int routing_id, 56 int routing_id,
50 int main_frame_routing_id, 57 int main_frame_routing_id,
51 Delegate* delegate, 58 Delegate* delegate,
52 const std::string& partition_id, 59 const std::string& partition_id,
53 content::SessionStorageNamespace* session_storage_namespace); 60 content::SessionStorageNamespace* session_storage_namespace);
54 ~BackgroundContents() override; 61 ~BackgroundContents() override;
55 62
56 content::WebContents* web_contents() const { return web_contents_.get(); } 63 content::WebContents* web_contents() const { return web_contents_.get(); }
57 virtual const GURL& GetURL() const; 64 virtual const GURL& GetURL() const;
58 65
66 // Adds this BackgroundContents to the queue of RenderViews to create.
67 void CreateRenderViewSoon(const GURL& url);
68
59 // content::WebContentsDelegate implementation: 69 // content::WebContentsDelegate implementation:
60 void CloseContents(content::WebContents* source) override; 70 void CloseContents(content::WebContents* source) override;
61 bool ShouldSuppressDialogs(content::WebContents* source) override; 71 bool ShouldSuppressDialogs(content::WebContents* source) override;
62 void DidNavigateMainFramePostCommit(content::WebContents* tab) override; 72 void DidNavigateMainFramePostCommit(content::WebContents* tab) override;
63 void AddNewContents(content::WebContents* source, 73 void AddNewContents(content::WebContents* source,
64 content::WebContents* new_contents, 74 content::WebContents* new_contents,
65 WindowOpenDisposition disposition, 75 WindowOpenDisposition disposition,
66 const gfx::Rect& initial_rect, 76 const gfx::Rect& initial_rect,
67 bool user_gesture, 77 bool user_gesture,
68 bool* was_blocked) override; 78 bool* was_blocked) override;
69 bool IsNeverVisible(content::WebContents* web_contents) override; 79 bool IsNeverVisible(content::WebContents* web_contents) override;
70 80
71 // content::WebContentsObserver implementation: 81 // content::WebContentsObserver implementation:
72 void RenderProcessGone(base::TerminationStatus status) override; 82 void RenderProcessGone(base::TerminationStatus status) override;
73 83
74 // content::NotificationObserver 84 // content::NotificationObserver
75 void Observe(int type, 85 void Observe(int type,
76 const content::NotificationSource& source, 86 const content::NotificationSource& source,
77 const content::NotificationDetails& details) override; 87 const content::NotificationDetails& details) override;
78 88
79 protected: 89 protected:
80 // Exposed for testing. 90 // Exposed for testing.
81 BackgroundContents(); 91 BackgroundContents();
82 92
83 private: 93 private:
94 // DeferredStartRenderHost implementation:
95 void CreateRenderViewNow() override;
96
84 // The delegate for this BackgroundContents. 97 // The delegate for this BackgroundContents.
85 Delegate* delegate_; 98 Delegate* delegate_;
86 99
100 // Delegate for choosing an ExtensionHostQueue.
101 scoped_ptr<extensions::ExtensionHostDelegate> extension_host_delegate_;
102
87 Profile* profile_; 103 Profile* profile_;
88 scoped_ptr<content::WebContents> web_contents_; 104 scoped_ptr<content::WebContents> web_contents_;
89 content::NotificationRegistrar registrar_; 105 content::NotificationRegistrar registrar_;
90 106
107 // The initial URL to load.
108 GURL initial_url_;
109
91 DISALLOW_COPY_AND_ASSIGN(BackgroundContents); 110 DISALLOW_COPY_AND_ASSIGN(BackgroundContents);
92 }; 111 };
93 112
94 // This is the data sent out as the details with BACKGROUND_CONTENTS_OPENED. 113 // This is the data sent out as the details with BACKGROUND_CONTENTS_OPENED.
95 struct BackgroundContentsOpenedDetails { 114 struct BackgroundContentsOpenedDetails {
96 // The BackgroundContents object that has just been opened. 115 // The BackgroundContents object that has just been opened.
97 BackgroundContents* contents; 116 BackgroundContents* contents;
98 117
99 // The name of the parent frame for these contents. 118 // The name of the parent frame for these contents.
100 const base::string16& frame_name; 119 const base::string16& frame_name;
101 120
102 // The ID of the parent application (if any). 121 // The ID of the parent application (if any).
103 const base::string16& application_id; 122 const base::string16& application_id;
104 }; 123 };
105 124
106 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_H_ 125 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/background/background_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698