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 #include "content/renderer/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #if defined (OS_WIN) | 9 #if defined (OS_WIN) |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 : instance_id_(instance_id), | 65 : instance_id_(instance_id), |
66 render_view_(render_view), | 66 render_view_(render_view), |
67 container_(NULL), | 67 container_(NULL), |
68 damage_buffer_(NULL), | 68 damage_buffer_(NULL), |
69 sad_guest_(NULL), | 69 sad_guest_(NULL), |
70 guest_crashed_(false), | 70 guest_crashed_(false), |
71 resize_pending_(false), | 71 resize_pending_(false), |
72 navigate_src_sent_(false), | 72 navigate_src_sent_(false), |
73 process_id_(-1), | 73 process_id_(-1), |
74 persist_storage_(false), | 74 persist_storage_(false), |
75 visible_(true) { | 75 visible_(true), |
| 76 current_nav_entry_index_(0), |
| 77 nav_entry_count_(0) { |
76 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); | 78 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); |
77 bindings_.reset(new BrowserPluginBindings(this)); | 79 bindings_.reset(new BrowserPluginBindings(this)); |
78 | 80 |
79 ParseAttributes(params); | 81 ParseAttributes(params); |
80 } | 82 } |
81 | 83 |
82 BrowserPlugin::~BrowserPlugin() { | 84 BrowserPlugin::~BrowserPlugin() { |
83 if (damage_buffer_) | 85 if (damage_buffer_) |
84 FreeDamageBuffer(); | 86 FreeDamageBuffer(); |
85 RemoveEventListeners(); | 87 RemoveEventListeners(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 144 |
143 std::string BrowserPlugin::GetPartitionAttribute() const { | 145 std::string BrowserPlugin::GetPartitionAttribute() const { |
144 std::string value; | 146 std::string value; |
145 if (persist_storage_) | 147 if (persist_storage_) |
146 value.append(kPersistPrefix); | 148 value.append(kPersistPrefix); |
147 | 149 |
148 value.append(storage_partition_id_); | 150 value.append(storage_partition_id_); |
149 return value; | 151 return value; |
150 } | 152 } |
151 | 153 |
| 154 bool BrowserPlugin::CanGoBack() const { |
| 155 return nav_entry_count_ > 1 && current_nav_entry_index_ > 0; |
| 156 } |
| 157 |
| 158 bool BrowserPlugin::CanGoForward() const { |
| 159 return current_nav_entry_index_ >= 0 && |
| 160 current_nav_entry_index_ < (nav_entry_count_ - 1); |
| 161 } |
| 162 |
152 bool BrowserPlugin::SetPartitionAttribute(const std::string& partition_id, | 163 bool BrowserPlugin::SetPartitionAttribute(const std::string& partition_id, |
153 std::string& error_message) { | 164 std::string& error_message) { |
154 if (navigate_src_sent_) { | 165 if (navigate_src_sent_) { |
155 error_message = | 166 error_message = |
156 "The object has already navigated, so its partition cannot be changed."; | 167 "The object has already navigated, so its partition cannot be changed."; |
157 return false; | 168 return false; |
158 } | 169 } |
159 | 170 |
160 std::string input = partition_id; | 171 std::string input = partition_id; |
161 | 172 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 v8::Context::Scope context_scope(v8::Context::New()); | 341 v8::Context::Scope context_scope(v8::Context::New()); |
331 v8::HandleScope handle_scope; | 342 v8::HandleScope handle_scope; |
332 container()->element().document().frame()-> | 343 container()->element().document().frame()-> |
333 callFunctionEvenIfScriptDisabled(*it, | 344 callFunctionEvenIfScriptDisabled(*it, |
334 v8::Object::New(), | 345 v8::Object::New(), |
335 0, | 346 0, |
336 NULL); | 347 NULL); |
337 } | 348 } |
338 } | 349 } |
339 | 350 |
| 351 void BrowserPlugin::NavigationStateUpdate(int current_entry_index, |
| 352 int entry_count) { |
| 353 current_nav_entry_index_ = current_entry_index; |
| 354 nav_entry_count_ = entry_count; |
| 355 } |
| 356 |
| 357 |
340 void BrowserPlugin::DidNavigate(const GURL& url, int process_id) { | 358 void BrowserPlugin::DidNavigate(const GURL& url, int process_id) { |
341 src_ = url.spec(); | 359 src_ = url.spec(); |
342 process_id_ = process_id; | 360 process_id_ = process_id; |
343 if (!HasListeners(kNavigationEventName)) | 361 if (!HasListeners(kNavigationEventName)) |
344 return; | 362 return; |
345 | 363 |
346 EventListeners& listeners = event_listener_map_[kNavigationEventName]; | 364 EventListeners& listeners = event_listener_map_[kNavigationEventName]; |
347 EventListeners::iterator it = listeners.begin(); | 365 EventListeners::iterator it = listeners.begin(); |
348 for (; it != listeners.end(); ++it) { | 366 for (; it != listeners.end(); ++it) { |
349 v8::Context::Scope context_scope(v8::Context::New()); | 367 v8::Context::Scope context_scope(v8::Context::New()); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 void* notify_data) { | 758 void* notify_data) { |
741 } | 759 } |
742 | 760 |
743 void BrowserPlugin::didFailLoadingFrameRequest( | 761 void BrowserPlugin::didFailLoadingFrameRequest( |
744 const WebKit::WebURL& url, | 762 const WebKit::WebURL& url, |
745 void* notify_data, | 763 void* notify_data, |
746 const WebKit::WebURLError& error) { | 764 const WebKit::WebURLError& error) { |
747 } | 765 } |
748 | 766 |
749 } // namespace content | 767 } // namespace content |
OLD | NEW |