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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 } | 863 } |
855 | 864 |
856 void BrowserPlugin::didReceiveData(const char* data, int data_length) { | 865 void BrowserPlugin::didReceiveData(const char* data, int data_length) { |
857 if (auto_navigate_) { | 866 if (auto_navigate_) { |
858 std::string value(data, data_length); | 867 std::string value(data, data_length); |
859 html_string_ += value; | 868 html_string_ += value; |
860 } | 869 } |
861 } | 870 } |
862 | 871 |
863 void BrowserPlugin::didFinishLoading() { | 872 void BrowserPlugin::didFinishLoading() { |
| 873 printf("html_string_: %s\n", html_string_.c_str()); |
864 if (auto_navigate_) { | 874 if (auto_navigate_) { |
865 // TODO(lazyboy): Make |auto_navigate_| stuff work. | 875 seen_src_ = true; |
866 UpdateDOMAttribute(content::browser_plugin::kAttributeSrc, html_string_); | 876 MaybeAttach(); |
867 } | 877 } |
868 } | 878 } |
869 | 879 |
| 880 void BrowserPlugin::MaybeAttach() { |
| 881 printf("MaybeAttach: seen_src_ = %d, attach_called_: %d, pending: %d\n", |
| 882 seen_src_, attach_called_, pending_instance_id_); |
| 883 if (seen_src_ && attach_called_) { |
| 884 base::DictionaryValue* extra_params = new base::DictionaryValue(); |
| 885 extra_params->SetString("src", html_string_); |
| 886 Attach(pending_instance_id_, make_scoped_ptr(extra_params)); |
| 887 } |
| 888 } |
| 889 |
870 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) { | 890 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) { |
871 } | 891 } |
872 | 892 |
873 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url, | 893 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url, |
874 void* notify_data) { | 894 void* notify_data) { |
875 } | 895 } |
876 | 896 |
877 void BrowserPlugin::didFailLoadingFrameRequest( | 897 void BrowserPlugin::didFailLoadingFrameRequest( |
878 const blink::WebURL& url, | 898 const blink::WebURL& url, |
879 void* notify_data, | 899 void* notify_data, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 const blink::WebMouseEvent& event) { | 984 const blink::WebMouseEvent& event) { |
965 browser_plugin_manager()->Send( | 985 browser_plugin_manager()->Send( |
966 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 986 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
967 guest_instance_id_, | 987 guest_instance_id_, |
968 plugin_rect_, | 988 plugin_rect_, |
969 &event)); | 989 &event)); |
970 return true; | 990 return true; |
971 } | 991 } |
972 | 992 |
973 } // namespace content | 993 } // namespace content |
OLD | NEW |