OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_EXTENSIONS_API_TAB_CAPTURE_OFFSCREEN_PRESENTATION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_OFFSCREEN_PRESENTATION_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_OFFSCREEN_PRESENTATION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_OFFSCREEN_PRESENTATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "content/public/browser/web_contents_delegate.h" | 14 #include "content/public/browser/web_contents_delegate.h" |
15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
16 #include "content/public/browser/web_contents_user_data.h" | 16 #include "content/public/browser/web_contents_user_data.h" |
17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 | 18 |
19 class Profile; | 19 class Profile; |
20 | 20 |
21 namespace media_router { | |
22 class OneUAPresentationRouter; | |
23 } | |
24 | |
21 namespace extensions { | 25 namespace extensions { |
22 | 26 |
23 class OffscreenPresentation; // Forward declaration. See below. | 27 class OffscreenPresentation; // Forward declaration. See below. |
24 | 28 |
25 // Creates, owns, and manages all OffscreenPresentation instances created by the | 29 // Creates, owns, and manages all OffscreenPresentation instances created by the |
26 // same extension background page. When the extension background page's | 30 // same extension background page. When the extension background page's |
27 // WebContents is about to be destroyed, its associated | 31 // WebContents is about to be destroyed, its associated |
28 // OffscreenPresentationsOwner and all of its OffscreenPresentation instances | 32 // OffscreenPresentationsOwner and all of its OffscreenPresentation instances |
29 // are destroyed. | 33 // are destroyed. |
30 // | 34 // |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 175 |
172 private: | 176 private: |
173 bool in_fullscreen_mode() const { | 177 bool in_fullscreen_mode() const { |
174 return !non_fullscreen_size_.IsEmpty(); | 178 return !non_fullscreen_size_.IsEmpty(); |
175 } | 179 } |
176 | 180 |
177 // Called by |capture_poll_timer_| to automatically destroy this | 181 // Called by |capture_poll_timer_| to automatically destroy this |
178 // OffscreenPresentation when the capturer count returns to zero. | 182 // OffscreenPresentation when the capturer count returns to zero. |
179 void DieIfContentCaptureEnded(); | 183 void DieIfContentCaptureEnded(); |
180 | 184 |
185 // Unregisters this presentation from OneUAPresentationRouter and destroys it. | |
186 void Close(); | |
whywhat
2015/09/14 15:20:39
nit: the name is very out of sync from the comment
miu
2015/09/17 00:09:20
I think it would be reasonable to name this method
imcheng
2015/09/26 01:21:56
Done.
imcheng
2015/09/26 01:21:57
Done.
| |
187 | |
181 OffscreenPresentationsOwner* const owner_; | 188 OffscreenPresentationsOwner* const owner_; |
182 | 189 |
183 // The starting URL for this presentation, which may or may not match the | 190 // The starting URL for this presentation, which may or may not match the |
184 // current WebContents URL if navigations have occurred. | 191 // current WebContents URL if navigations have occurred. |
185 const GURL start_url_; | 192 const GURL start_url_; |
186 | 193 |
187 // The presentation ID used to help uniquely identify this instance. | 194 // The presentation ID used to help uniquely identify this instance. |
188 const std::string presentation_id_; | 195 const std::string presentation_id_; |
189 | 196 |
190 // A non-shared off-the-record profile based on the profile of the extension | 197 // A non-shared off-the-record profile based on the profile of the extension |
191 // background page. | 198 // background page. |
192 const scoped_ptr<Profile> profile_; | 199 const scoped_ptr<Profile> profile_; |
193 | 200 |
194 // The WebContents containing the offscreen presentation page. | 201 // The WebContents containing the offscreen presentation page. |
195 scoped_ptr<content::WebContents> presentation_web_contents_; | 202 scoped_ptr<content::WebContents> presentation_web_contents_; |
196 | 203 |
204 media_router::OneUAPresentationRouter* const one_ua_presentation_router_; | |
205 | |
197 // The time at which Start() finished creating |presentation_web_contents_|. | 206 // The time at which Start() finished creating |presentation_web_contents_|. |
198 base::TimeTicks start_time_; | 207 base::TimeTicks start_time_; |
199 | 208 |
200 // Set to the original size of the renderer just before entering fullscreen | 209 // Set to the original size of the renderer just before entering fullscreen |
201 // mode. When not in fullscreen mode, this is an empty size. | 210 // mode. When not in fullscreen mode, this is an empty size. |
202 gfx::Size non_fullscreen_size_; | 211 gfx::Size non_fullscreen_size_; |
203 | 212 |
204 // Poll timer to monitor the capturer count on |presentation_web_contents_|. | 213 // Poll timer to monitor the capturer count on |presentation_web_contents_|. |
205 // When the capturer count returns to zero, this OffscreenPresentation is | 214 // When the capturer count returns to zero, this OffscreenPresentation is |
206 // automatically destroyed. | 215 // automatically destroyed. |
207 // TODO(miu): Add a method to WebContentsObserver to report capturer count | 216 // TODO(miu): Add a method to WebContentsObserver to report capturer count |
208 // changes and get rid of this polling-based approach. | 217 // changes and get rid of this polling-based approach. |
209 base::Timer capture_poll_timer_; | 218 base::Timer capture_poll_timer_; |
210 | 219 |
211 // This is false until after the Start() method is called, and capture of the | 220 // This is false until after the Start() method is called, and capture of the |
212 // |presentation_web_contents_| is first detected. | 221 // |presentation_web_contents_| is first detected. |
213 bool content_capture_was_detected_; | 222 bool content_capture_was_detected_; |
214 | 223 |
215 DISALLOW_COPY_AND_ASSIGN(OffscreenPresentation); | 224 DISALLOW_COPY_AND_ASSIGN(OffscreenPresentation); |
216 }; | 225 }; |
217 | 226 |
218 } // namespace extensions | 227 } // namespace extensions |
219 | 228 |
220 #endif // CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_OFFSCREEN_PRESENTATION_H_ | 229 #endif // CHROME_BROWSER_EXTENSIONS_API_TAB_CAPTURE_OFFSCREEN_PRESENTATION_H_ |
OLD | NEW |