| 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 content_window_routing_id_(MSG_ROUTING_NONE), |
| 75 visible_(true), | 76 visible_(true), |
| 76 current_nav_entry_index_(0), | 77 current_nav_entry_index_(0), |
| 77 nav_entry_count_(0) { | 78 nav_entry_count_(0) { |
| 78 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); | 79 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); |
| 79 bindings_.reset(new BrowserPluginBindings(this)); | 80 bindings_.reset(new BrowserPluginBindings(this)); |
| 80 | 81 |
| 81 ParseAttributes(params); | 82 ParseAttributes(params); |
| 82 } | 83 } |
| 83 | 84 |
| 84 BrowserPlugin::~BrowserPlugin() { | 85 BrowserPlugin::~BrowserPlugin() { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 instance_id_, | 128 instance_id_, |
| 128 src, | 129 src, |
| 129 *params)); | 130 *params)); |
| 130 // Record that we sent a NavigateGuest message to embedder. | 131 // Record that we sent a NavigateGuest message to embedder. |
| 131 // Once this instance has navigated, the storage partition cannot be changed, | 132 // Once this instance has navigated, the storage partition cannot be changed, |
| 132 // so this value is used for enforcing this. | 133 // so this value is used for enforcing this. |
| 133 navigate_src_sent_ = true; | 134 navigate_src_sent_ = true; |
| 134 src_ = src; | 135 src_ = src; |
| 135 } | 136 } |
| 136 | 137 |
| 138 NPObject* BrowserPlugin::GetContentWindow() const { |
| 139 if (content_window_routing_id_ == MSG_ROUTING_NONE) |
| 140 return NULL; |
| 141 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( |
| 142 ChildThread::current()->ResolveRoute(content_window_routing_id_)); |
| 143 if (!guest_render_view) |
| 144 return NULL; |
| 145 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); |
| 146 return guest_frame->windowObject(); |
| 147 } |
| 148 |
| 137 std::string BrowserPlugin::GetPartitionAttribute() const { | 149 std::string BrowserPlugin::GetPartitionAttribute() const { |
| 138 std::string value; | 150 std::string value; |
| 139 if (persist_storage_) | 151 if (persist_storage_) |
| 140 value.append(kPersistPrefix); | 152 value.append(kPersistPrefix); |
| 141 | 153 |
| 142 value.append(storage_partition_id_); | 154 value.append(storage_partition_id_); |
| 143 return value; | 155 return value; |
| 144 } | 156 } |
| 145 | 157 |
| 146 bool BrowserPlugin::CanGoBack() const { | 158 bool BrowserPlugin::CanGoBack() const { |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 frame->callFunctionEvenIfScriptDisabled(*it, v8::Object::New(), 1, &val); | 491 frame->callFunctionEvenIfScriptDisabled(*it, v8::Object::New(), 1, &val); |
| 480 } | 492 } |
| 481 } | 493 } |
| 482 | 494 |
| 483 void BrowserPlugin::AdvanceFocus(bool reverse) { | 495 void BrowserPlugin::AdvanceFocus(bool reverse) { |
| 484 // We do not have a RenderView when we are testing. | 496 // We do not have a RenderView when we are testing. |
| 485 if (render_view_) | 497 if (render_view_) |
| 486 render_view_->GetWebView()->advanceFocus(reverse); | 498 render_view_->GetWebView()->advanceFocus(reverse); |
| 487 } | 499 } |
| 488 | 500 |
| 501 void BrowserPlugin::GuestContentWindowReady(int content_window_routing_id) { |
| 502 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); |
| 503 content_window_routing_id_ = content_window_routing_id; |
| 504 } |
| 505 |
| 489 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { | 506 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { |
| 490 if (container()) | 507 if (container()) |
| 491 container()->setIsAcceptingTouchEvents(accept); | 508 container()->setIsAcceptingTouchEvents(accept); |
| 492 } | 509 } |
| 493 | 510 |
| 494 bool BrowserPlugin::HasListeners(const std::string& event_name) { | 511 bool BrowserPlugin::HasListeners(const std::string& event_name) { |
| 495 return event_listener_map_.find(event_name) != event_listener_map_.end(); | 512 return event_listener_map_.find(event_name) != event_listener_map_.end(); |
| 496 } | 513 } |
| 497 | 514 |
| 498 bool BrowserPlugin::AddEventListener(const std::string& event_name, | 515 bool BrowserPlugin::AddEventListener(const std::string& event_name, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 void* notify_data) { | 806 void* notify_data) { |
| 790 } | 807 } |
| 791 | 808 |
| 792 void BrowserPlugin::didFailLoadingFrameRequest( | 809 void BrowserPlugin::didFailLoadingFrameRequest( |
| 793 const WebKit::WebURL& url, | 810 const WebKit::WebURL& url, |
| 794 void* notify_data, | 811 void* notify_data, |
| 795 const WebKit::WebURLError& error) { | 812 const WebKit::WebURLError& error) { |
| 796 } | 813 } |
| 797 | 814 |
| 798 } // namespace content | 815 } // namespace content |
| OLD | NEW |