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

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: Sync and reup patch for review. 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;
41 using WebKit::WebRect; 41 using WebKit::WebRect;
42 using WebKit::WebURL; 42 using WebKit::WebURL;
43 using WebKit::WebVector; 43 using WebKit::WebVector;
44 44
45 namespace content { 45 namespace content {
46 46
47 namespace { 47 namespace {
48 48
49 // Events. 49 // Events.
50 const char kEventExit[] = "exit"; 50 const char kEventExit[] = "exit";
51 const char kEventLoadAbort[] = "loadabort"; 51 const char kEventLoadAbort[] = "loadabort";
52 const char kEventLoadCommit[] = "loadcommit"; 52 const char kEventLoadCommit[] = "loadcommit";
53 const char kEventLoadRedirect[] = "loadredirect"; 53 const char kEventLoadRedirect[] = "loadredirect";
54 const char kEventLoadStart[] = "loadstart"; 54 const char kEventLoadStart[] = "loadstart";
55 const char kEventLoadStop[] = "loadstop"; 55 const char kEventLoadStop[] = "loadstop";
56 const char kEventSizeChanged[] = "sizechanged"; 56 const char kEventSizeChanged[] = "sizechanged";
57 const char kEventRequestPermission[] = "permissionrequest";
Charlie Reis 2012/11/20 01:54:00 nit: Alphabetize
lazyboy 2012/11/20 02:55:20 Ah bad merge, Done.
57 58
58 // Parameters/properties on events. 59 // Parameters/properties on events.
60 const char kInstanceIdKey[] = "instance_id";
59 const char kIsTopLevel[] = "isTopLevel"; 61 const char kIsTopLevel[] = "isTopLevel";
60 const char kNewURL[] = "newUrl"; 62 const char kNewURL[] = "newUrl";
61 const char kNewHeight[] = "newHeight"; 63 const char kNewHeight[] = "newHeight";
62 const char kNewWidth[] = "newWidth"; 64 const char kNewWidth[] = "newWidth";
63 const char kOldURL[] = "oldUrl"; 65 const char kOldURL[] = "oldUrl";
64 const char kOldHeight[] = "oldHeight"; 66 const char kOldHeight[] = "oldHeight";
65 const char kOldWidth[] = "oldWidth"; 67 const char kOldWidth[] = "oldWidth";
66 const char kPartition[] = "partition"; 68 const char kPartition[] = "partition";
69 const char kPermissionTypeMedia[] = "media";
67 const char kPersistPrefix[] = "persist:"; 70 const char kPersistPrefix[] = "persist:";
68 const char kProcessId[] = "processId"; 71 const char kProcessId[] = "processId";
72 const char kReason[] = "reason";
73 const char kRequestIdKey[] = "request_id";
Charlie Reis 2012/11/20 01:54:00 What's the difference between having a "Key" suffi
lazyboy 2012/11/20 02:55:20 yes that's confusing, all string in this section a
69 const char kSrc[] = "src"; 74 const char kSrc[] = "src";
70 const char kReason[] = "reason";
71 const char kURL[] = "url"; 75 const char kURL[] = "url";
72 76
73 // Error messages. 77 // Error messages.
74 const char kErrorAlreadyNavigated[] = 78 const char kErrorAlreadyNavigated[] =
75 "The object has already navigated, so its partition cannot be changed."; 79 "The object has already navigated, so its partition cannot be changed.";
76 const char kErrorInvalidPartition[] = 80 const char kErrorInvalidPartition[] =
77 "Invalid partition attribute."; 81 "Invalid partition attribute.";
78 82
79 static std::string TerminationStatusToString(base::TerminationStatus status) { 83 static std::string TerminationStatusToString(base::TerminationStatus status) {
80 switch (status) { 84 switch (status) {
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 void BrowserPlugin::LoadAbort(const GURL& url, 604 void BrowserPlugin::LoadAbort(const GURL& url,
601 bool is_top_level, 605 bool is_top_level,
602 const std::string& type) { 606 const std::string& type) {
603 std::map<std::string, base::Value*> props; 607 std::map<std::string, base::Value*> props;
604 props[kURL] = base::Value::CreateStringValue(url.spec()); 608 props[kURL] = base::Value::CreateStringValue(url.spec());
605 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); 609 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level);
606 props[kReason] = base::Value::CreateStringValue(type); 610 props[kReason] = base::Value::CreateStringValue(type);
607 TriggerEvent(kEventLoadAbort, &props); 611 TriggerEvent(kEventLoadAbort, &props);
608 } 612 }
609 613
614 void BrowserPlugin::RequestMediaAccess(int request_id) {
615 std::map<std::string, base::Value*> props;
616 props[kReason] = base::Value::CreateStringValue(kPermissionTypeMedia);
617 props[kRequestIdKey] = base::Value::CreateIntegerValue(request_id);
618 TriggerEvent(kEventRequestPermission, &props);
619 }
620
610 void BrowserPlugin::LoadRedirect(const GURL& old_url, 621 void BrowserPlugin::LoadRedirect(const GURL& old_url,
611 const GURL& new_url, 622 const GURL& new_url,
612 bool is_top_level) { 623 bool is_top_level) {
613 std::map<std::string, base::Value*> props; 624 std::map<std::string, base::Value*> props;
614 props[kOldURL] = base::Value::CreateStringValue(old_url.spec()); 625 props[kOldURL] = base::Value::CreateStringValue(old_url.spec());
615 props[kNewURL] = base::Value::CreateStringValue(new_url.spec()); 626 props[kNewURL] = base::Value::CreateStringValue(new_url.spec());
616 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level); 627 props[kIsTopLevel] = base::Value::CreateBooleanValue(is_top_level);
617 TriggerEvent(kEventLoadRedirect, &props); 628 TriggerEvent(kEventLoadRedirect, &props);
618 } 629 }
619 630
(...skipping 30 matching lines...) Expand all
650 void BrowserPlugin::GuestContentWindowReady(int content_window_routing_id) { 661 void BrowserPlugin::GuestContentWindowReady(int content_window_routing_id) {
651 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); 662 DCHECK(content_window_routing_id != MSG_ROUTING_NONE);
652 content_window_routing_id_ = content_window_routing_id; 663 content_window_routing_id_ = content_window_routing_id;
653 } 664 }
654 665
655 void BrowserPlugin::SetAcceptTouchEvents(bool accept) { 666 void BrowserPlugin::SetAcceptTouchEvents(bool accept) {
656 if (container()) 667 if (container())
657 container()->setIsAcceptingTouchEvents(accept); 668 container()->setIsAcceptingTouchEvents(accept);
658 } 669 }
659 670
671 void BrowserPlugin::RespondMediaAccess(int request_id, bool allow) {
672 BrowserPluginManager::Get()->Send(
673 new BrowserPluginHostMsg_AllowMediaAccess(render_view_->GetRoutingID(),
674 instance_id_,
675 request_id,
676 allow));
677 }
678
660 WebKit::WebPluginContainer* BrowserPlugin::container() const { 679 WebKit::WebPluginContainer* BrowserPlugin::container() const {
661 return container_; 680 return container_;
662 } 681 }
663 682
664 bool BrowserPlugin::initialize(WebPluginContainer* container) { 683 bool BrowserPlugin::initialize(WebPluginContainer* container) {
665 container_ = container; 684 container_ = container;
666 return true; 685 return true;
667 } 686 }
668 687
669 void BrowserPlugin::destroy() { 688 void BrowserPlugin::destroy() {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 void* notify_data) { 970 void* notify_data) {
952 } 971 }
953 972
954 void BrowserPlugin::didFailLoadingFrameRequest( 973 void BrowserPlugin::didFailLoadingFrameRequest(
955 const WebKit::WebURL& url, 974 const WebKit::WebURL& url,
956 void* notify_data, 975 void* notify_data,
957 const WebKit::WebURLError& error) { 976 const WebKit::WebURLError& error) {
958 } 977 }
959 978
960 } // namespace content 979 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698