OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 paint_ack_received_(true), | 53 paint_ack_received_(true), |
54 last_device_scale_factor_(GetDeviceScaleFactor()), | 54 last_device_scale_factor_(GetDeviceScaleFactor()), |
55 sad_guest_(NULL), | 55 sad_guest_(NULL), |
56 guest_crashed_(false), | 56 guest_crashed_(false), |
57 is_auto_size_state_dirty_(false), | 57 is_auto_size_state_dirty_(false), |
58 content_window_routing_id_(MSG_ROUTING_NONE), | 58 content_window_routing_id_(MSG_ROUTING_NONE), |
59 plugin_focused_(false), | 59 plugin_focused_(false), |
60 visible_(true), | 60 visible_(true), |
61 auto_navigate_(auto_navigate), | 61 auto_navigate_(auto_navigate), |
62 mouse_locked_(false), | 62 mouse_locked_(false), |
| 63 attach_called_(false), |
| 64 seen_src_(false), |
63 browser_plugin_manager_(render_view->GetBrowserPluginManager()), | 65 browser_plugin_manager_(render_view->GetBrowserPluginManager()), |
64 embedder_frame_url_(frame->document().url()), | 66 embedder_frame_url_(frame->document().url()), |
65 weak_ptr_factory_(this) { | 67 weak_ptr_factory_(this) { |
66 } | 68 } |
67 | 69 |
68 BrowserPlugin::~BrowserPlugin() { | 70 BrowserPlugin::~BrowserPlugin() { |
69 // If the BrowserPlugin has never navigated then the browser process and | 71 // If the BrowserPlugin has never navigated then the browser process and |
70 // BrowserPluginManager don't know about it and so there is nothing to do | 72 // BrowserPluginManager don't know about it and so there is nothing to do |
71 // here. | 73 // here. |
72 if (!HasGuestInstanceID()) | 74 if (!HasGuestInstanceID()) |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 GetSizeParams(NULL, &resize_guest_params, true); | 260 GetSizeParams(NULL, &resize_guest_params, true); |
259 } | 261 } |
260 paint_ack_received_ = false; | 262 paint_ack_received_ = false; |
261 browser_plugin_manager()->Send( | 263 browser_plugin_manager()->Send( |
262 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_, | 264 new BrowserPluginHostMsg_SetAutoSize(render_view_routing_id_, |
263 guest_instance_id_, | 265 guest_instance_id_, |
264 auto_size_params, | 266 auto_size_params, |
265 resize_guest_params)); | 267 resize_guest_params)); |
266 } | 268 } |
267 | 269 |
| 270 void BrowserPlugin::AttachToPlugin( |
| 271 int instance_id) { |
| 272 attach_called_ = true; |
| 273 pending_instance_id_ = instance_id; |
| 274 MaybeAttach(); |
| 275 } |
| 276 |
268 void BrowserPlugin::Attach(int guest_instance_id, | 277 void BrowserPlugin::Attach(int guest_instance_id, |
269 scoped_ptr<base::DictionaryValue> extra_params) { | 278 scoped_ptr<base::DictionaryValue> extra_params) { |
270 CHECK(guest_instance_id != browser_plugin::kInstanceIDNone); | 279 CHECK(guest_instance_id != browser_plugin::kInstanceIDNone); |
271 | 280 |
272 // If this BrowserPlugin is already attached to a guest, then kill the guest. | 281 // If this BrowserPlugin is already attached to a guest, then kill the guest. |
273 if (HasGuestInstanceID()) { | 282 if (HasGuestInstanceID()) { |
274 if (guest_instance_id == guest_instance_id_) | 283 if (guest_instance_id == guest_instance_id_) |
275 return; | 284 return; |
276 guest_crashed_ = false; | 285 guest_crashed_ = false; |
277 EnableCompositing(false); | 286 EnableCompositing(false); |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 } | 862 } |
854 | 863 |
855 void BrowserPlugin::didReceiveData(const char* data, int data_length) { | 864 void BrowserPlugin::didReceiveData(const char* data, int data_length) { |
856 if (auto_navigate_) { | 865 if (auto_navigate_) { |
857 std::string value(data, data_length); | 866 std::string value(data, data_length); |
858 html_string_ += value; | 867 html_string_ += value; |
859 } | 868 } |
860 } | 869 } |
861 | 870 |
862 void BrowserPlugin::didFinishLoading() { | 871 void BrowserPlugin::didFinishLoading() { |
| 872 printf("html_string_: %s\n", html_string_.c_str()); |
863 if (auto_navigate_) { | 873 if (auto_navigate_) { |
864 // TODO(lazyboy): Make |auto_navigate_| stuff work. | 874 seen_src_ = true; |
865 UpdateDOMAttribute(content::browser_plugin::kAttributeSrc, html_string_); | 875 MaybeAttach(); |
866 } | 876 } |
867 } | 877 } |
868 | 878 |
| 879 void BrowserPlugin::MaybeAttach() { |
| 880 printf("MaybeAttach: seen_src_ = %d, attach_called_: %d, pending: %d\n", |
| 881 seen_src_, attach_called_, pending_instance_id_); |
| 882 if (seen_src_ && attach_called_) { |
| 883 base::DictionaryValue* extra_params = new base::DictionaryValue(); |
| 884 extra_params->SetString("src", html_string_); |
| 885 Attach(pending_instance_id_, make_scoped_ptr(extra_params)); |
| 886 } |
| 887 } |
| 888 |
869 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) { | 889 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) { |
870 } | 890 } |
871 | 891 |
872 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url, | 892 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url, |
873 void* notify_data) { | 893 void* notify_data) { |
874 } | 894 } |
875 | 895 |
876 void BrowserPlugin::didFailLoadingFrameRequest( | 896 void BrowserPlugin::didFailLoadingFrameRequest( |
877 const blink::WebURL& url, | 897 const blink::WebURL& url, |
878 void* notify_data, | 898 void* notify_data, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 const blink::WebMouseEvent& event) { | 983 const blink::WebMouseEvent& event) { |
964 browser_plugin_manager()->Send( | 984 browser_plugin_manager()->Send( |
965 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 985 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
966 guest_instance_id_, | 986 guest_instance_id_, |
967 plugin_rect_, | 987 plugin_rect_, |
968 &event)); | 988 &event)); |
969 return true; | 989 return true; |
970 } | 990 } |
971 | 991 |
972 } // namespace content | 992 } // namespace content |
OLD | NEW |