Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_GUESTVIEW_GUESTVIEW_H_ | 5 #ifndef CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_ |
| 6 #define CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_ | 6 #define CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 scoped_ptr<DictionaryValue> GetArguments(); | 36 scoped_ptr<DictionaryValue> GetArguments(); |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 const std::string event_name_; | 39 const std::string event_name_; |
| 40 scoped_ptr<DictionaryValue> args_; | 40 scoped_ptr<DictionaryValue> args_; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 static Type GetViewTypeFromString(const std::string& api_type); | 43 static Type GetViewTypeFromString(const std::string& api_type); |
| 44 | 44 |
| 45 static GuestView* Create(content::WebContents* guest_web_contents, | 45 static GuestView* Create(content::WebContents* guest_web_contents, |
| 46 const std::string& extension_id, | |
| 46 Type view_type); | 47 Type view_type); |
| 47 | 48 |
| 48 static GuestView* FromWebContents(content::WebContents* web_contents); | 49 static GuestView* FromWebContents(content::WebContents* web_contents); |
| 49 | 50 |
| 50 static GuestView* From(int embedder_process_id, int instance_id); | 51 static GuestView* From(int embedder_process_id, int instance_id); |
| 51 | 52 |
| 52 virtual void Attach(content::WebContents* embedder_web_contents, | 53 virtual void Attach(content::WebContents* embedder_web_contents, |
| 53 const std::string& extension_id, | |
| 54 const base::DictionaryValue& args); | 54 const base::DictionaryValue& args); |
| 55 | 55 |
| 56 content::WebContents* embedder_web_contents() const { | 56 content::WebContents* embedder_web_contents() const { |
| 57 return embedder_web_contents_; | 57 return embedder_web_contents_; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Returns the guest WebContents. | 60 // Returns the guest WebContents. |
| 61 content::WebContents* guest_web_contents() const { | 61 content::WebContents* guest_web_contents() const { |
| 62 return guest_web_contents_; | 62 return guest_web_contents_; |
| 63 } | 63 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 82 // Returns the extension ID of the embedder. | 82 // Returns the extension ID of the embedder. |
| 83 const std::string& extension_id() const { return extension_id_; } | 83 const std::string& extension_id() const { return extension_id_; } |
| 84 | 84 |
| 85 // Returns the user browser context of the embedder. | 85 // Returns the user browser context of the embedder. |
| 86 content::BrowserContext* browser_context() const { return browser_context_; } | 86 content::BrowserContext* browser_context() const { return browser_context_; } |
| 87 | 87 |
| 88 // Returns the embedder's process ID. | 88 // Returns the embedder's process ID. |
| 89 int embedder_render_process_id() const { return embedder_render_process_id_; } | 89 int embedder_render_process_id() const { return embedder_render_process_id_; } |
| 90 | 90 |
| 91 protected: | 91 protected: |
| 92 explicit GuestView(content::WebContents* guest_web_contents); | 92 GuestView(content::WebContents* guest_web_contents, |
| 93 const std::string& extension_id); | |
| 93 virtual ~GuestView(); | 94 virtual ~GuestView(); |
| 94 | 95 |
| 95 // Dispatches an event |event_name| to the embedder with the |event| fields. | 96 // Dispatches an event |event_name| to the embedder with the |event| fields. |
| 96 void DispatchEvent(Event* event); | 97 void DispatchEvent(Event* event); |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 void SendQueuedEvents(); | 100 void SendQueuedEvents(); |
| 100 | 101 |
| 101 content::WebContents* guest_web_contents_; | 102 content::WebContents* guest_web_contents_; |
| 102 content::WebContents* embedder_web_contents_; | 103 content::WebContents* embedder_web_contents_; |
| 103 std::string extension_id_; | 104 const std::string extension_id_; |
|
Charlie Reis
2013/10/30 20:42:20
I definitely like that we know the extension ID on
Fady Samuel
2013/10/31 17:25:17
:-)
| |
| 104 int embedder_render_process_id_; | 105 int embedder_render_process_id_; |
| 105 content::BrowserContext* browser_context_; | 106 content::BrowserContext* browser_context_; |
| 106 // |guest_instance_id_| is a profile-wide unique identifier for a guest | 107 // |guest_instance_id_| is a profile-wide unique identifier for a guest |
| 107 // WebContents. | 108 // WebContents. |
| 108 const int guest_instance_id_; | 109 const int guest_instance_id_; |
| 109 // |view_instance_id_| is an identifier that's unique within a particular | 110 // |view_instance_id_| is an identifier that's unique within a particular |
| 110 // embedder RenderViewHost for a particular <*view> instance. | 111 // embedder RenderViewHost for a particular <*view> instance. |
| 111 int view_instance_id_; | 112 int view_instance_id_; |
| 112 | 113 |
| 113 // This is a queue of Events that are destined to be sent to the embedder once | 114 // This is a queue of Events that are destined to be sent to the embedder once |
| 114 // the guest is attached to a particular embedder. | 115 // the guest is attached to a particular embedder. |
| 115 std::queue<Event*> pending_events_; | 116 std::queue<Event*> pending_events_; |
| 116 | 117 |
| 117 DISALLOW_COPY_AND_ASSIGN(GuestView); | 118 DISALLOW_COPY_AND_ASSIGN(GuestView); |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 #endif // CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_ | 121 #endif // CHROME_BROWSER_GUESTVIEW_GUESTVIEW_H_ |
| OLD | NEW |