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

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: With the new attach approach 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 bool auto_navigate,
Fady Samuel 2014/08/29 18:52:31 How about taking in a BrowserPluginDelegate instea
lazyboy 2014/08/29 22:08:25 Done. Only downside is I don't know the browser_pl
49 const std::string& mime_type)
48 : attached_(false), 50 : attached_(false),
49 attach_pending_(false), 51 attach_pending_(false),
50 render_view_(render_view->AsWeakPtr()), 52 render_view_(render_view->AsWeakPtr()),
51 render_view_routing_id_(render_view->GetRoutingID()), 53 render_view_routing_id_(render_view->GetRoutingID()),
52 container_(NULL), 54 container_(NULL),
53 paint_ack_received_(true), 55 paint_ack_received_(true),
54 last_device_scale_factor_(GetDeviceScaleFactor()), 56 last_device_scale_factor_(GetDeviceScaleFactor()),
55 sad_guest_(NULL), 57 sad_guest_(NULL),
56 guest_crashed_(false), 58 guest_crashed_(false),
57 content_window_routing_id_(MSG_ROUTING_NONE), 59 content_window_routing_id_(MSG_ROUTING_NONE),
58 plugin_focused_(false), 60 plugin_focused_(false),
59 visible_(true), 61 visible_(true),
60 auto_navigate_(auto_navigate), 62 auto_navigate_(auto_navigate),
Fady Samuel 2014/08/29 18:52:31 Get rid of this.
lazyboy 2014/08/29 22:08:24 Done.
63 mime_type_(mime_type),
Fady Samuel 2014/08/29 18:52:31 Get rid of this.
lazyboy 2014/08/29 22:08:24 Done.
61 mouse_locked_(false), 64 mouse_locked_(false),
62 browser_plugin_manager_(render_view->GetBrowserPluginManager()), 65 browser_plugin_manager_(render_view->GetBrowserPluginManager()),
63 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone), 66 browser_plugin_instance_id_(browser_plugin::kInstanceIDNone),
64 weak_ptr_factory_(this) { 67 weak_ptr_factory_(this) {
65 } 68 }
66 69
67 BrowserPlugin::~BrowserPlugin() { 70 BrowserPlugin::~BrowserPlugin() {
68 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_); 71 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_);
69 72
70 if (!ready()) 73 if (!ready())
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 npp_.reset(new NPP_t); 393 npp_.reset(new NPP_t);
391 container->allowScriptObjects(); 394 container->allowScriptObjects();
392 395
393 bindings_.reset(new BrowserPluginBindings(this)); 396 bindings_.reset(new BrowserPluginBindings(this));
394 container_ = container; 397 container_ = container;
395 container_->setWantsWheelEvents(true); 398 container_->setWantsWheelEvents(true);
396 399
397 // This is a way to notify observers of our attributes that this plugin is 400 // This is a way to notify observers of our attributes that this plugin is
398 // available in render tree. 401 // available in render tree.
399 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID(); 402 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID();
403
404 if (auto_navigate_) {
405 delegate_.reset(GetContentClient()->renderer()->CreateBrowserPluginDelegate(
406 render_view_routing_id_,
407 browser_plugin_instance_id_,
408 mime_type_));
409 }
410
400 UpdateDOMAttribute("internalinstanceid", 411 UpdateDOMAttribute("internalinstanceid",
401 base::IntToString(browser_plugin_instance_id_)); 412 base::IntToString(browser_plugin_instance_id_));
402 413
403 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this); 414 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this);
404 return true; 415 return true;
405 } 416 }
406 417
407 void BrowserPlugin::EnableCompositing(bool enable) { 418 void BrowserPlugin::EnableCompositing(bool enable) {
408 bool enabled = !!compositing_helper_.get(); 419 bool enabled = !!compositing_helper_.get();
409 if (enabled == enable) 420 if (enabled == enable)
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 mask, 703 mask,
693 position)); 704 position));
694 return true; 705 return true;
695 } 706 }
696 707
697 void BrowserPlugin::didReceiveResponse( 708 void BrowserPlugin::didReceiveResponse(
698 const blink::WebURLResponse& response) { 709 const blink::WebURLResponse& response) {
699 } 710 }
700 711
701 void BrowserPlugin::didReceiveData(const char* data, int data_length) { 712 void BrowserPlugin::didReceiveData(const char* data, int data_length) {
702 if (auto_navigate_) { 713 if (auto_navigate_) {
Fady Samuel 2014/08/29 18:52:31 Move this to the delegate.
lazyboy 2014/08/29 22:08:24 Done.
703 std::string value(data, data_length); 714 std::string value(data, data_length);
704 html_string_ += value; 715 html_string_ += value;
705 } 716 }
706 } 717 }
707 718
708 void BrowserPlugin::didFinishLoading() { 719 void BrowserPlugin::didFinishLoading() {
709 if (auto_navigate_) { 720 if (auto_navigate_) {
710 // TODO(lazyboy): Make |auto_navigate_| stuff work. 721 if (delegate_)
711 UpdateDOMAttribute(content::browser_plugin::kAttributeSrc, html_string_); 722 delegate_->DidFinishLoading(html_string_);
712 } 723 }
713 } 724 }
714 725
715 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) { 726 void BrowserPlugin::didFailLoading(const blink::WebURLError& error) {
716 } 727 }
717 728
718 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url, 729 void BrowserPlugin::didFinishLoadingFrameRequest(const blink::WebURL& url,
719 void* notify_data) { 730 void* notify_data) {
720 } 731 }
721 732
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 const blink::WebMouseEvent& event) { 820 const blink::WebMouseEvent& event) {
810 browser_plugin_manager()->Send( 821 browser_plugin_manager()->Send(
811 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 822 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
812 browser_plugin_instance_id_, 823 browser_plugin_instance_id_,
813 plugin_rect_, 824 plugin_rect_,
814 &event)); 825 &event));
815 return true; 826 return true;
816 } 827 }
817 828
818 } // namespace content 829 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698