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

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

Issue 11093080: <webview>: First stab at implementing media permission request for guests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reup patch, with new style event handling + fix tests. Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "content/common/browser_plugin_messages.h" 11 #include "content/common/browser_plugin_messages.h"
12 #include "content/common/view_messages.h" 12 #include "content/common/view_messages.h"
13 #include "content/public/common/content_client.h" 13 #include "content/public/common/content_client.h"
14 #include "content/public/renderer/content_renderer_client.h" 14 #include "content/public/renderer/content_renderer_client.h"
15 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" 15 #include "content/renderer/browser_plugin/browser_plugin_bindings.h"
16 #include "content/renderer/browser_plugin/browser_plugin_manager.h" 16 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
17 #include "content/renderer/render_process_impl.h" 17 #include "content/renderer/render_process_impl.h"
18 #include "content/renderer/render_thread_impl.h" 18 #include "content/renderer/render_thread_impl.h"
19 #include "content/renderer/v8_value_converter_impl.h" 19 #include "content/renderer/v8_value_converter_impl.h"
20 #include "skia/ext/platform_canvas.h" 20 #include "skia/ext/platform_canvas.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMCustomEvent.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
31 #include "webkit/plugins/sad_plugin.h" 31 #include "webkit/plugins/sad_plugin.h"
32 32
33 #if defined (OS_WIN) 33 #if defined (OS_WIN)
34 #include "base/sys_info.h" 34 #include "base/sys_info.h"
35 #endif 35 #endif
36 36
37 using WebKit::WebCanvas; 37 using WebKit::WebCanvas;
38 using WebKit::WebPluginContainer; 38 using WebKit::WebPluginContainer;
39 using WebKit::WebPluginParams; 39 using WebKit::WebPluginParams;
40 using WebKit::WebPoint; 40 using WebKit::WebPoint;
(...skipping 11 matching lines...) Expand all
52 const char kLoadRedirectEventName[] = "loadredirect"; 52 const char kLoadRedirectEventName[] = "loadredirect";
53 const char kLoadStartEventName[] = "loadstart"; 53 const char kLoadStartEventName[] = "loadstart";
54 const char kLoadStopEventName[] = "loadstop"; 54 const char kLoadStopEventName[] = "loadstop";
55 const char kNewURL[] = "newUrl"; 55 const char kNewURL[] = "newUrl";
56 const char kNewHeight[] = "newHeight"; 56 const char kNewHeight[] = "newHeight";
57 const char kNewWidth[] = "newWidth"; 57 const char kNewWidth[] = "newWidth";
58 const char kOldURL[] = "oldUrl"; 58 const char kOldURL[] = "oldUrl";
59 const char kOldHeight[] = "oldHeight"; 59 const char kOldHeight[] = "oldHeight";
60 const char kOldWidth[] = "oldWidth"; 60 const char kOldWidth[] = "oldWidth";
61 const char kPartitionAttribute[] = "partition"; 61 const char kPartitionAttribute[] = "partition";
62 const char kPermissionRequestEventName[] = "permissionrequest";
sadrul 2012/11/16 03:59:53 General comment (definitely not scope for this CL)
lazyboy 2012/11/16 06:27:09 Agreed, I'll fix that separately so I don't have t
63 const char kPermissionTypeMedia[] = "media";
62 const char kPersistPrefix[] = "persist:"; 64 const char kPersistPrefix[] = "persist:";
63 const char kProcessId[] = "processId"; 65 const char kProcessId[] = "processId";
66 const char kRequestIdKey[] = "request_id";
64 const char kSizeChangedEventName[] = "sizechanged"; 67 const char kSizeChangedEventName[] = "sizechanged";
65 const char kSrcAttribute[] = "src"; 68 const char kSrcAttribute[] = "src";
66 const char kReason[] = "reason"; 69 const char kReason[] = "reason";
67 const char kURL[] = "url"; 70 const char kURL[] = "url";
68 71
69 static std::string TerminationStatusToString(base::TerminationStatus status) { 72 static std::string TerminationStatusToString(base::TerminationStatus status) {
70 switch (status) { 73 switch (status) {
71 case base::TERMINATION_STATUS_NORMAL_TERMINATION: 74 case base::TERMINATION_STATUS_NORMAL_TERMINATION:
72 return "normal"; 75 return "normal";
73 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: 76 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION:
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 void BrowserPlugin::LoadAbort(const GURL& url, 583 void BrowserPlugin::LoadAbort(const GURL& url,
581 bool is_top_level, 584 bool is_top_level,
582 const std::string& type) { 585 const std::string& type) {
583 std::map<std::string, base::Value*> props; 586 std::map<std::string, base::Value*> props;
584 props[kURL] = base::Value::CreateStringValue(url.spec()); 587 props[kURL] = base::Value::CreateStringValue(url.spec());
585 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); 588 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level);
586 props[kReason] = base::Value::CreateStringValue(type); 589 props[kReason] = base::Value::CreateStringValue(type);
587 TriggerEvent(kLoadAbortEventName, &props); 590 TriggerEvent(kLoadAbortEventName, &props);
588 } 591 }
589 592
593 void BrowserPlugin::RequestMediaAccess(int request_id) {
594 std::map<std::string, base::Value*> props;
595 props[kReason] = base::Value::CreateStringValue(kPermissionTypeMedia);
596 props[kRequestIdKey] = base::Value::CreateIntegerValue(request_id);
597 TriggerEvent(kPermissionRequestEventName, &props);
598 }
599
590 void BrowserPlugin::LoadRedirect(const GURL& old_url, 600 void BrowserPlugin::LoadRedirect(const GURL& old_url,
591 const GURL& new_url, 601 const GURL& new_url,
592 bool is_top_level) { 602 bool is_top_level) {
593 std::map<std::string, base::Value*> props; 603 std::map<std::string, base::Value*> props;
594 props[kOldURL] = base::Value::CreateStringValue(old_url.spec()); 604 props[kOldURL] = base::Value::CreateStringValue(old_url.spec());
595 props[kNewURL] = base::Value::CreateStringValue(new_url.spec()); 605 props[kNewURL] = base::Value::CreateStringValue(new_url.spec());
596 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); 606 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level);
597 TriggerEvent(kLoadRedirectEventName, &props); 607 TriggerEvent(kLoadRedirectEventName, &props);
598 } 608 }
599 609
(...skipping 30 matching lines...) Expand all
630 void BrowserPlugin::GuestContentWindowReady(int content_window_routing_id) { 640 void BrowserPlugin::GuestContentWindowReady(int content_window_routing_id) {
631 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); 641 DCHECK(content_window_routing_id != MSG_ROUTING_NONE);
632 content_window_routing_id_ = content_window_routing_id; 642 content_window_routing_id_ = content_window_routing_id;
633 } 643 }
634 644
635 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { 645 void BrowserPlugin::SetAcceptTouchEvents(bool accept) {
636 if (container()) 646 if (container())
637 container()->setIsAcceptingTouchEvents(accept); 647 container()->setIsAcceptingTouchEvents(accept);
638 } 648 }
639 649
650 void BrowserPlugin::AllowMediaAccess(int request_id, bool allow) {
651 BrowserPluginManager::Get()->Send(
652 new BrowserPluginHostMsg_AllowMediaAccess(render_view_->GetRoutingID(),
653 instance_id_,
654 request_id,
655 allow));
656 }
657
640 WebKit::WebPluginContainer* BrowserPlugin::container() const { 658 WebKit::WebPluginContainer* BrowserPlugin::container() const {
641 return container_; 659 return container_;
642 } 660 }
643 661
644 bool BrowserPlugin::initialize(WebPluginContainer* container) { 662 bool BrowserPlugin::initialize(WebPluginContainer* container) {
645 container_ = container; 663 container_ = container;
646 return true; 664 return true;
647 } 665 }
648 666
649 void BrowserPlugin::destroy() { 667 void BrowserPlugin::destroy() {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 void* notify_data) { 951 void* notify_data) {
934 } 952 }
935 953
936 void BrowserPlugin::didFailLoadingFrameRequest( 954 void BrowserPlugin::didFailLoadingFrameRequest(
937 const WebKit::WebURL& url, 955 const WebKit::WebURL& url,
938 void* notify_data, 956 void* notify_data,
939 const WebKit::WebURLError& error) { 957 const WebKit::WebURLError& error) {
940 } 958 }
941 959
942 } // namespace content 960 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698