OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
7 | 7 |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/sequenced_task_runner_helpers.h" | 11 #include "base/sequenced_task_runner_helpers.h" |
12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
13 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
14 #endif | 14 #endif |
15 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" | 15 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" |
16 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 16 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
17 #include "content/renderer/render_view_impl.h" | 17 #include "content/renderer/render_view_impl.h" |
18 | 18 |
19 struct BrowserPluginHostMsg_ResizeGuest_Params; | 19 struct BrowserPluginHostMsg_ResizeGuest_Params; |
| 20 struct BrowserPluginMsg_DidNavigate_Params; |
20 struct BrowserPluginMsg_UpdateRect_Params; | 21 struct BrowserPluginMsg_UpdateRect_Params; |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
24 class BrowserPluginManager; | 25 class BrowserPluginManager; |
25 class MockBrowserPlugin; | 26 class MockBrowserPlugin; |
26 | 27 |
27 class CONTENT_EXPORT BrowserPlugin : | 28 class CONTENT_EXPORT BrowserPlugin : |
28 NON_EXPORTED_BASE(public WebKit::WebPlugin) { | 29 NON_EXPORTED_BASE(public WebKit::WebPlugin) { |
29 public: | 30 public: |
30 // Called only by tests to clean up before we blow away the MockRenderProcess. | 31 // Called only by tests to clean up before we blow away the MockRenderProcess. |
31 void Cleanup(); | 32 void Cleanup(); |
32 | 33 |
33 // Get the src attribute value of the BrowserPlugin instance if the guest | 34 // Get the src attribute value of the BrowserPlugin instance if the guest |
34 // has not crashed. | 35 // has not crashed. |
35 std::string GetSrcAttribute() const; | 36 std::string GetSrcAttribute() const; |
36 // Set the src attribute value of the BrowserPlugin instance and reset | 37 // Set the src attribute value of the BrowserPlugin instance and reset |
37 // the guest_crashed_ flag. | 38 // the guest_crashed_ flag. |
38 void SetSrcAttribute(const std::string& src); | 39 void SetSrcAttribute(const std::string& src); |
39 // Returns Chrome's process ID for the current guest. | 40 // Returns Chrome's process ID for the current guest. |
40 int process_id() const { return process_id_; } | 41 int process_id() const { return process_id_; } |
41 // The partition identifier string is stored as UTF-8. | 42 // The partition identifier string is stored as UTF-8. |
42 std::string GetPartitionAttribute() const; | 43 std::string GetPartitionAttribute() const; |
| 44 // Query whether the guest can navigate back to the previous entry. |
| 45 bool CanGoBack() const; |
| 46 // Query whether the guest can navigation forward to the next entry. |
| 47 bool CanGoForward() const; |
43 // This method can be successfully called only before the first navigation for | 48 // This method can be successfully called only before the first navigation for |
44 // this instance of BrowserPlugin. If an error occurs, the |error_message| is | 49 // this instance of BrowserPlugin. If an error occurs, the |error_message| is |
45 // set appropriately to indicate the failure reason. | 50 // set appropriately to indicate the failure reason. |
46 bool SetPartitionAttribute(const std::string& partition_id, | 51 bool SetPartitionAttribute(const std::string& partition_id, |
47 std::string& error_message); | 52 std::string& error_message); |
48 | 53 |
49 // Inform the BrowserPlugin to update its backing store with the pixels in | 54 // Inform the BrowserPlugin to update its backing store with the pixels in |
50 // its damage buffer. | 55 // its damage buffer. |
51 void UpdateRect(int message_id, | 56 void UpdateRect(int message_id, |
52 const BrowserPluginMsg_UpdateRect_Params& params); | 57 const BrowserPluginMsg_UpdateRect_Params& params); |
53 // Inform the BrowserPlugin that its guest has crashed. | 58 // Inform the BrowserPlugin that its guest has crashed. |
54 void GuestCrashed(); | 59 void GuestCrashed(); |
55 // Informs the BrowserPlugin that the guest has navigated to a new URL. | 60 // Informs the BrowserPlugin that the guest has navigated to a new URL. |
56 void DidNavigate(const GURL& url, int process_id); | 61 void DidNavigate(const BrowserPluginMsg_DidNavigate_Params& params); |
57 // Inform the BrowserPlugin that the guest has started loading a new page. | 62 // Inform the BrowserPlugin that the guest has started loading a new page. |
58 void LoadStart(const GURL& url, bool is_top_level); | 63 void LoadStart(const GURL& url, bool is_top_level); |
59 // Inform the BrowserPlugin that the guest has aborted loading a new page. | 64 // Inform the BrowserPlugin that the guest has aborted loading a new page. |
60 void LoadAbort(const GURL& url, bool is_top_level, const std::string& type); | 65 void LoadAbort(const GURL& url, bool is_top_level, const std::string& type); |
61 // Inform the BrowserPlugin that the guest has redirected a navigation. | 66 // Inform the BrowserPlugin that the guest has redirected a navigation. |
62 void LoadRedirect(const GURL& old_url, | 67 void LoadRedirect(const GURL& old_url, |
63 const GURL& new_url, | 68 const GURL& new_url, |
64 bool is_top_level); | 69 bool is_top_level); |
65 // Tells the BrowserPlugin to advance the focus to the next (or previous) | 70 // Tells the BrowserPlugin to advance the focus to the next (or previous) |
66 // element. | 71 // element. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 bool persist_storage_; | 198 bool persist_storage_; |
194 // Tracks the visibility of the browser plugin regardless of the whole | 199 // Tracks the visibility of the browser plugin regardless of the whole |
195 // embedder RenderView's visibility. | 200 // embedder RenderView's visibility. |
196 bool visible_; | 201 bool visible_; |
197 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; | 202 typedef std::vector<v8::Persistent<v8::Function> > EventListeners; |
198 typedef std::map<std::string, EventListeners> EventListenerMap; | 203 typedef std::map<std::string, EventListeners> EventListenerMap; |
199 EventListenerMap event_listener_map_; | 204 EventListenerMap event_listener_map_; |
200 #if defined(OS_WIN) | 205 #if defined(OS_WIN) |
201 base::SharedMemory shared_memory_; | 206 base::SharedMemory shared_memory_; |
202 #endif | 207 #endif |
| 208 // Important: Do not add more history state here. |
| 209 // We strongly discourage storing additional history state (such as page IDs) |
| 210 // in the embedder process, at the risk of having incorrect information that |
| 211 // can lead to broken back/forward logic in apps. |
| 212 // It's also important that this state does not get modified by any logic in |
| 213 // the embedder process. It should only be updated in response to navigation |
| 214 // events in the guest. No assumptions should be made about how the index |
| 215 // will change after a navigation (e.g., for back, forward, or go), because |
| 216 // the changes are not always obvious. For example, there is a maximum |
| 217 // number of entries and earlier ones will automatically be pruned. |
| 218 int current_nav_entry_index_; |
| 219 int nav_entry_count_; |
203 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 220 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
204 }; | 221 }; |
205 | 222 |
206 } // namespace content | 223 } // namespace content |
207 | 224 |
208 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 225 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |