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

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: add switch to control feature, remove a DCHECK from extension_message_filter 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // Tell |container| to allow this plugin to use script objects. 400 // Tell |container| to allow this plugin to use script objects.
396 npp_.reset(new NPP_t); 401 npp_.reset(new NPP_t);
397 container->allowScriptObjects(); 402 container->allowScriptObjects();
398 403
399 bindings_.reset(new BrowserPluginBindings(this)); 404 bindings_.reset(new BrowserPluginBindings(this));
400 container_ = container; 405 container_ = container;
401 container_->setWantsWheelEvents(true); 406 container_->setWantsWheelEvents(true);
402 407
403 // This is a way to notify observers of our attributes that this plugin is 408 // This is a way to notify observers of our attributes that this plugin is
404 // available in render tree. 409 // available in render tree.
405 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID(); 410 // TODO(lazyboy): This should be done through the delegate instead. Perhaps
411 // by firing an event from there.
406 UpdateDOMAttribute("internalinstanceid", 412 UpdateDOMAttribute("internalinstanceid",
407 base::IntToString(browser_plugin_instance_id_)); 413 base::IntToString(browser_plugin_instance_id_));
408 414
409 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this); 415 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this);
410 return true; 416 return true;
411 } 417 }
412 418
413 void BrowserPlugin::EnableCompositing(bool enable) { 419 void BrowserPlugin::EnableCompositing(bool enable) {
414 bool enabled = !!compositing_helper_.get(); 420 bool enabled = !!compositing_helper_.get();
415 if (enabled == enable) 421 if (enabled == enable)
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 mask, 692 mask,
687 position)); 693 position));
688 return true; 694 return true;
689 } 695 }
690 696
691 void BrowserPlugin::didReceiveResponse( 697 void BrowserPlugin::didReceiveResponse(
692 const blink::WebURLResponse& response) { 698 const blink::WebURLResponse& response) {
693 } 699 }
694 700
695 void BrowserPlugin::didReceiveData(const char* data, int data_length) { 701 void BrowserPlugin::didReceiveData(const char* data, int data_length) {
696 if (auto_navigate_) { 702 if (delegate_)
697 std::string value(data, data_length); 703 delegate_->DidReceiveData(data, data_length);
698 html_string_ += value;
699 }
700 } 704 }
701 705
702 void BrowserPlugin::didFinishLoading() { 706 void BrowserPlugin::didFinishLoading() {
703 if (auto_navigate_) { 707 if (delegate_)
704 // TODO(lazyboy): Make |auto_navigate_| stuff work. 708 delegate_->DidFinishLoading();
705 UpdateDOMAttribute(content::browser_plugin::kAttributeSrc, html_string_);
706 }
707 } 709 }
708 710
709 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) { 711 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) {
710 } 712 }
711 713
712 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url, 714 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url,
713 void* notify_data) { 715 void* notify_data) {
714 } 716 }
715 717
716 void BrowserPlugin::didFailLoadingFrameRequest( 718 void BrowserPlugin::didFailLoadingFrameRequest(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 const blink::WebMouseEvent& event) { 805 const blink::WebMouseEvent& event) {
804 browser_plugin_manager()->Send( 806 browser_plugin_manager()->Send(
805 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 807 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
806 browser_plugin_instance_id_, 808 browser_plugin_instance_id_,
807 plugin_rect_, 809 plugin_rect_,
808 &event)); 810 &event));
809 return true; 811 return true;
810 } 812 }
811 813
812 } // namespace content 814 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698