Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 376033002: Adding MimeHandlerView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pending-zork-patch2
Patch Set: address comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "content/common/browser_plugin/browser_plugin_constants.h" 11 #include "content/common/browser_plugin/browser_plugin_constants.h"
12 #include "content/common/browser_plugin/browser_plugin_messages.h" 12 #include "content/common/browser_plugin/browser_plugin_messages.h"
13 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
14 #include "content/public/common/content_client.h" 14 #include "content/public/common/content_client.h"
15 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
16 #include "content/public/renderer/browser_plugin_delegate.h"
16 #include "content/public/renderer/content_renderer_client.h" 17 #include "content/public/renderer/content_renderer_client.h"
17 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" 18 #include "content/renderer/browser_plugin/browser_plugin_bindings.h"
18 #include "content/renderer/browser_plugin/browser_plugin_manager.h" 19 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
19 #include "content/renderer/child_frame_compositing_helper.h" 20 #include "content/renderer/child_frame_compositing_helper.h"
20 #include "content/renderer/cursor_utils.h" 21 #include "content/renderer/cursor_utils.h"
21 #include "content/renderer/drop_data_builder.h" 22 #include "content/renderer/drop_data_builder.h"
22 #include "content/renderer/render_thread_impl.h" 23 #include "content/renderer/render_thread_impl.h"
23 #include "content/renderer/sad_plugin.h" 24 #include "content/renderer/sad_plugin.h"
24 #include "third_party/WebKit/public/platform/WebRect.h" 25 #include "third_party/WebKit/public/platform/WebRect.h"
25 #include "third_party/WebKit/public/web/WebBindings.h" 26 #include "third_party/WebKit/public/web/WebBindings.h"
(...skipping 11 matching lines...) Expand all
37 using blink::WebPluginParams; 38 using blink::WebPluginParams;
38 using blink::WebPoint; 39 using blink::WebPoint;
39 using blink::WebRect; 40 using blink::WebRect;
40 using blink::WebURL; 41 using blink::WebURL;
41 using blink::WebVector; 42 using blink::WebVector;
42 43
43 namespace content { 44 namespace content {
44 45
45 BrowserPlugin::BrowserPlugin(RenderViewImpl* render_view, 46 BrowserPlugin::BrowserPlugin(RenderViewImpl* render_view,
46 blink::WebFrame* frame, 47 blink::WebFrame* frame,
47 bool auto_navigate) 48 BrowserPluginDelegate* delegate)
48 : attached_(false), 49 : attached_(false),
49 attach_pending_(false), 50 attach_pending_(false),
50 render_view_(render_view->AsWeakPtr()), 51 render_view_(render_view->AsWeakPtr()),
51 render_view_routing_id_(render_view->GetRoutingID()), 52 render_view_routing_id_(render_view->GetRoutingID()),
52 container_(NULL), 53 container_(NULL),
53 paint_ack_received_(true), 54 paint_ack_received_(true),
54 last_device_scale_factor_(GetDeviceScaleFactor()), 55 last_device_scale_factor_(GetDeviceScaleFactor()),
55 sad_guest_(NULL), 56 sad_guest_(NULL),
56 guest_crashed_(false), 57 guest_crashed_(false),
57 content_window_routing_id_(MSG_ROUTING_NONE), 58 content_window_routing_id_(MSG_ROUTING_NONE),
58 plugin_focused_(false), 59 plugin_focused_(false),
59 visible_(true), 60 visible_(true),
60 auto_navigate_(auto_navigate),
61 mouse_locked_(false), 61 mouse_locked_(false),
62 browser_plugin_manager_(render_view->GetBrowserPluginManager()), 62 browser_plugin_manager_(render_view->GetBrowserPluginManager()),
63 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone), 63 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone),
64 delegate_(delegate),
64 weak_ptr_factory_(this) { 65 weak_ptr_factory_(this) {
66 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID();
67
68 if (delegate)
69 delegate->SetElementInstanceID(browser_plugin_instance_id_);
65 } 70 }
66 71
67 BrowserPlugin::~BrowserPlugin() { 72 BrowserPlugin::~BrowserPlugin() {
68 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_); 73 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_);
69 74
70 if (!ready()) 75 if (!ready())
71 return; 76 return;
72 77
73 browser_plugin_manager()->Send( 78 browser_plugin_manager()->Send(
74 new BrowserPluginHostMsg_PluginDestroyed(render_view_routing_id_, 79 new BrowserPluginHostMsg_PluginDestroyed(render_view_routing_id_,
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // Tell |container| to allow this plugin to use script objects. 394 // Tell |container| to allow this plugin to use script objects.
390 npp_.reset(new NPP_t); 395 npp_.reset(new NPP_t);
391 container->allowScriptObjects(); 396 container->allowScriptObjects();
392 397
393 bindings_.reset(new BrowserPluginBindings(this)); 398 bindings_.reset(new BrowserPluginBindings(this));
394 container_ = container; 399 container_ = container;
395 container_->setWantsWheelEvents(true); 400 container_->setWantsWheelEvents(true);
396 401
397 // This is a way to notify observers of our attributes that this plugin is 402 // This is a way to notify observers of our attributes that this plugin is
398 // available in render tree. 403 // available in render tree.
399 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID(); 404 // TODO(lazyboy): This should be done through the delegate instead. Perhaps
405 // by firing an event from there.
400 UpdateDOMAttribute("internalinstanceid", 406 UpdateDOMAttribute("internalinstanceid",
401 base::IntToString(browser_plugin_instance_id_)); 407 base::IntToString(browser_plugin_instance_id_));
402 408
403 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this); 409 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this);
404 return true; 410 return true;
405 } 411 }
406 412
407 void BrowserPlugin::EnableCompositing(bool enable) { 413 void BrowserPlugin::EnableCompositing(bool enable) {
408 bool enabled = !!compositing_helper_.get(); 414 bool enabled = !!compositing_helper_.get();
409 if (enabled == enable) 415 if (enabled == enable)
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 mask, 698 mask,
693 position)); 699 position));
694 return true; 700 return true;
695 } 701 }
696 702
697 void BrowserPlugin::didReceiveResponse( 703 void BrowserPlugin::didReceiveResponse(
698 const blink::WebURLResponse& response) { 704 const blink::WebURLResponse& response) {
699 } 705 }
700 706
701 void BrowserPlugin::didReceiveData(const char* data, int data_length) { 707 void BrowserPlugin::didReceiveData(const char* data, int data_length) {
702 if (auto_navigate_) { 708 if (delegate_)
703 std::string value(data, data_length); 709 delegate_->DidReceiveData(data, data_length);
704 html_string_ += value;
705 }
706 } 710 }
707 711
708 void BrowserPlugin::didFinishLoading() { 712 void BrowserPlugin::didFinishLoading() {
709 if (auto_navigate_) { 713 if (delegate_)
710 // TODO(lazyboy): Make |auto_navigate_| stuff work. 714 delegate_->DidFinishLoading();
711 UpdateDOMAttribute(content::browser_plugin::kAttributeSrc, html_string_);
712 }
713 } 715 }
714 716
715 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) { 717 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) {
716 } 718 }
717 719
718 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url, 720 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url,
719 void* notify_data) { 721 void* notify_data) {
720 } 722 }
721 723
722 void BrowserPlugin::didFailLoadingFrameRequest( 724 void BrowserPlugin::didFailLoadingFrameRequest(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 const blink::WebMouseEvent& event) { 811 const blink::WebMouseEvent& event) {
810 browser_plugin_manager()->Send( 812 browser_plugin_manager()->Send(
811 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 813 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
812 browser_plugin_instance_id_, 814 browser_plugin_instance_id_,
813 plugin_rect_, 815 plugin_rect_,
814 &event)); 816 &event));
815 return true; 817 return true;
816 } 818 }
817 819
818 } // namespace content 820 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698