Index: chrome/browser/extensions/api/tab_capture/offscreen_presentation.h |
diff --git a/chrome/browser/extensions/api/tab_capture/offscreen_presentation.h b/chrome/browser/extensions/api/tab_capture/offscreen_presentation.h |
index 03ca5c22810b3cbf2daf8cb9073895912bec0fe8..fcd5d0ed2c719e2dda090d13e602dda5746bb1e5 100644 |
--- a/chrome/browser/extensions/api/tab_capture/offscreen_presentation.h |
+++ b/chrome/browser/extensions/api/tab_capture/offscreen_presentation.h |
@@ -20,6 +20,9 @@ class Profile; |
namespace extensions { |
+// TODO(miu): This file and classes should be renamed, as this implementation |
+// has expanded in scope to be used for all off-screen tabs. |
+ |
class OffscreenPresentation; // Forward declaration. See below. |
// Creates, owns, and manages all OffscreenPresentation instances created by the |
@@ -31,7 +34,7 @@ class OffscreenPresentation; // Forward declaration. See below. |
// Usage: |
// |
// OffscreenPresentationsOwner::Get(extension_contents) |
-// ->FindOrStartPresentation(start_url, presentation_id, size); |
+// ->StartPresentation(start_url, size); |
// |
// This class operates exclusively on the UI thread and so is not thread-safe. |
class OffscreenPresentationsOwner |
@@ -44,14 +47,19 @@ class OffscreenPresentationsOwner |
static OffscreenPresentationsOwner* Get( |
content::WebContents* extension_web_contents); |
- // Find a presentation, keyed by |start_url| and |presentation_id|. If found, |
- // return it. Otherwise, instantiate a new one and return that. If too many |
- // presentations have already been started, this method returns nullptr. |
- OffscreenPresentation* FindOrStartPresentation( |
+ // Instantiate a new off-screen tab and navigate it to |start_url|. The new |
+ // tab's main frame will start out with the given |initial_size| in DIP |
+ // coordinates. If too many off-screen tabs have already been started, this |
+ // method returns nullptr. |
+ OffscreenPresentation* StartPresentation( |
const GURL& start_url, |
- const std::string& presentation_id, |
const gfx::Size& initial_size); |
+ // Retrieve an existing instance by its ID. If not found, this method returns |
+ // nullptr. |
+ OffscreenPresentation* FindByOffscreenTabId( |
+ const std::string& offscreen_tab_id) const; |
+ |
protected: |
friend class OffscreenPresentation; |
@@ -68,10 +76,8 @@ class OffscreenPresentationsOwner |
explicit OffscreenPresentationsOwner(content::WebContents* contents); |
- // Returns the OffscreenPresentation that matches the given |start_url| and |
- // |presentation_id|, or nullptr if not found. |
- OffscreenPresentation* FindPresentation( |
- const GURL& start_url, const std::string& presentation_id) const; |
+ // Returns a unique, random ID that no other OffscreenPresentation has. |
+ std::string CreateUniqueRandomId() const; |
content::WebContents* const extension_web_contents_; |
ScopedVector<OffscreenPresentation> presentations_; |
@@ -104,7 +110,7 @@ class OffscreenPresentation : protected content::WebContentsDelegate, |
~OffscreenPresentation() final; |
const GURL& start_url() const { return start_url_; } |
- const std::string& presentation_id() const { return presentation_id_; } |
+ const std::string& id() const { return id_; } |
// The presentation page's WebContents instance. |
content::WebContents* web_contents() const { |
@@ -184,8 +190,8 @@ class OffscreenPresentation : protected content::WebContentsDelegate, |
// current WebContents URL if navigations have occurred. |
const GURL start_url_; |
- // The presentation ID used to help uniquely identify this instance. |
- const std::string presentation_id_; |
+ // An ID used to uniquely identify this instance. |
+ const std::string id_; |
// A non-shared off-the-record profile based on the profile of the extension |
// background page. |