| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
| 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 std::string* partition_domain, | 69 std::string* partition_domain, |
| 70 std::string* partition_name, | 70 std::string* partition_name, |
| 71 bool* in_memory); | 71 bool* in_memory); |
| 72 | 72 |
| 73 // By default, JavaScript and images are enabled in guest content. | 73 // By default, JavaScript and images are enabled in guest content. |
| 74 static void GetDefaultContentSettingRules(RendererContentSettingRules* rules, | 74 static void GetDefaultContentSettingRules(RendererContentSettingRules* rules, |
| 75 bool incognito); | 75 bool incognito); |
| 76 | 76 |
| 77 virtual const char* GetViewType() const = 0; | 77 virtual const char* GetViewType() const = 0; |
| 78 | 78 |
| 79 // This method can be overriden by subclasses. This method is called when | 79 // This method can be overridden by subclasses. This method is called when |
| 80 // the initial set of frames within the page have completed loading. | 80 // the initial set of frames within the page have completed loading. |
| 81 virtual void DidStopLoading() {} | 81 virtual void DidStopLoading() {} |
| 82 | 82 |
| 83 // This method can be overridden by subclasses. It indicates that this guest's | 83 // This method is called when the guest WebContents is about to be destroyed. |
| 84 // embedder has been destroyed and the guest will be destroyed shortly. This | 84 // |
| 85 // method gives derived classes the opportunity to perform some cleanup. | 85 // This method can be overridden by subclasses. This gives the derived class |
| 86 // an opportunity to perform some cleanup prior to destruction. |
| 87 virtual void WillDestroy() {} |
| 88 |
| 89 // This method is called when the guest's embedder WebContents has been |
| 90 // destroyed and the guest will be destroyed shortly. |
| 91 // |
| 92 // This method can be overridden by subclasses. This gives the derived class |
| 93 // an opportunity to perform some cleanup prior to destruction. |
| 86 virtual void EmbedderDestroyed() {} | 94 virtual void EmbedderDestroyed() {} |
| 87 | 95 |
| 96 // This method is called when the guest WebContents has been destroyed. This |
| 97 // object will be destroyed after this call returns. |
| 98 // |
| 99 // This method can be overridden by subclasses. This gives the derived class |
| 100 // opportunity to perform some cleanup. |
| 101 virtual void GuestDestroyed() {} |
| 102 |
| 88 // This method queries whether drag-and-drop is enabled for this particular | 103 // This method queries whether drag-and-drop is enabled for this particular |
| 89 // view. By default, drag-and-drop is disabled. Derived classes can override | 104 // view. By default, drag-and-drop is disabled. Derived classes can override |
| 90 // this behavior to enable drag-and-drop. | 105 // this behavior to enable drag-and-drop. |
| 91 virtual bool IsDragAndDropEnabled() const; | 106 virtual bool IsDragAndDropEnabled() const; |
| 92 | 107 |
| 93 bool IsViewType(const char* const view_type) const { | 108 bool IsViewType(const char* const view_type) const { |
| 94 return !strcmp(GetViewType(), view_type); | 109 return !strcmp(GetViewType(), view_type); |
| 95 } | 110 } |
| 96 | 111 |
| 97 base::WeakPtr<GuestViewBase> AsWeakPtr(); | 112 base::WeakPtr<GuestViewBase> AsWeakPtr(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 151 |
| 137 // Returns the embedder's process ID. | 152 // Returns the embedder's process ID. |
| 138 int embedder_render_process_id() const { return embedder_render_process_id_; } | 153 int embedder_render_process_id() const { return embedder_render_process_id_; } |
| 139 | 154 |
| 140 GuestViewBase* GetOpener() const { | 155 GuestViewBase* GetOpener() const { |
| 141 return opener_.get(); | 156 return opener_.get(); |
| 142 } | 157 } |
| 143 | 158 |
| 144 void SetOpener(GuestViewBase* opener); | 159 void SetOpener(GuestViewBase* opener); |
| 145 | 160 |
| 146 // WebContentsObserver implementation. | 161 // BrowserPluginGuestDelegate implementation. |
| 147 virtual void DidStopLoading( | 162 virtual void Destroy() OVERRIDE FINAL; |
| 148 content::RenderViewHost* render_view_host) OVERRIDE FINAL; | 163 virtual void RegisterDestructionCallback( |
| 149 virtual void WebContentsDestroyed() OVERRIDE; | 164 const DestructionCallback& callback) OVERRIDE FINAL; |
| 150 | 165 |
| 151 // WebContentsDelegate implementation. | |
| 152 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; | |
| 153 virtual bool PreHandleGestureEvent( | |
| 154 content::WebContents* source, | |
| 155 const blink::WebGestureEvent& event) OVERRIDE; | |
| 156 | |
| 157 // BrowserPluginGuestDelegate implementation. | |
| 158 virtual void Destroy() OVERRIDE; | |
| 159 virtual void RegisterDestructionCallback( | |
| 160 const DestructionCallback& callback) OVERRIDE; | |
| 161 protected: | 166 protected: |
| 162 GuestViewBase(int guest_instance_id, | 167 GuestViewBase(int guest_instance_id, |
| 163 content::WebContents* guest_web_contents, | 168 content::WebContents* guest_web_contents, |
| 164 const std::string& embedder_extension_id); | 169 const std::string& embedder_extension_id); |
| 165 virtual ~GuestViewBase(); | 170 virtual ~GuestViewBase(); |
| 166 | 171 |
| 167 // Dispatches an event |event_name| to the embedder with the |event| fields. | 172 // Dispatches an event |event_name| to the embedder with the |event| fields. |
| 168 void DispatchEvent(Event* event); | 173 void DispatchEvent(Event* event); |
| 169 | 174 |
| 170 private: | 175 private: |
| 171 class EmbedderWebContentsObserver; | 176 class EmbedderWebContentsObserver; |
| 172 | 177 |
| 173 void SendQueuedEvents(); | 178 void SendQueuedEvents(); |
| 174 | 179 |
| 180 // WebContentsObserver implementation. |
| 181 virtual void DidStopLoading( |
| 182 content::RenderViewHost* render_view_host) OVERRIDE FINAL; |
| 183 virtual void WebContentsDestroyed() OVERRIDE FINAL; |
| 184 |
| 185 // WebContentsDelegate implementation. |
| 186 virtual bool ShouldFocusPageAfterCrash() OVERRIDE FINAL; |
| 187 virtual bool PreHandleGestureEvent( |
| 188 content::WebContents* source, |
| 189 const blink::WebGestureEvent& event) OVERRIDE FINAL; |
| 190 |
| 175 content::WebContents* embedder_web_contents_; | 191 content::WebContents* embedder_web_contents_; |
| 176 const std::string embedder_extension_id_; | 192 const std::string embedder_extension_id_; |
| 177 int embedder_render_process_id_; | 193 int embedder_render_process_id_; |
| 178 content::BrowserContext* const browser_context_; | 194 content::BrowserContext* const browser_context_; |
| 179 // |guest_instance_id_| is a profile-wide unique identifier for a guest | 195 // |guest_instance_id_| is a profile-wide unique identifier for a guest |
| 180 // WebContents. | 196 // WebContents. |
| 181 const int guest_instance_id_; | 197 const int guest_instance_id_; |
| 182 // |view_instance_id_| is an identifier that's unique within a particular | 198 // |view_instance_id_| is an identifier that's unique within a particular |
| 183 // embedder RenderViewHost for a particular <*view> instance. | 199 // embedder RenderViewHost for a particular <*view> instance. |
| 184 int view_instance_id_; | 200 int view_instance_id_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 201 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 217 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
| 202 | 218 |
| 203 // This is used to ensure pending tasks will not fire after this object is | 219 // This is used to ensure pending tasks will not fire after this object is |
| 204 // destroyed. | 220 // destroyed. |
| 205 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; | 221 base::WeakPtrFactory<GuestViewBase> weak_ptr_factory_; |
| 206 | 222 |
| 207 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); | 223 DISALLOW_COPY_AND_ASSIGN(GuestViewBase); |
| 208 }; | 224 }; |
| 209 | 225 |
| 210 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ | 226 #endif // CHROME_BROWSER_GUEST_VIEW_GUEST_VIEW_BASE_H_ |
| OLD | NEW |