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

Unified Diff: extensions/browser/guest_view/app_view/app_view_guest.cc

Issue 820583002: Adds support for media permission request handling on <appview> tag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn build Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/guest_view/app_view/app_view_guest.cc
diff --git a/extensions/browser/guest_view/app_view/app_view_guest.cc b/extensions/browser/guest_view/app_view/app_view_guest.cc
index 2309380e6ff77e0f3ff1f0a9a7c0924929d26875..1dba347ba9700e02e919afc4cf9150bb8f6b7d85 100644
--- a/extensions/browser/guest_view/app_view/app_view_guest.cc
+++ b/extensions/browser/guest_view/app_view/app_view_guest.cc
@@ -9,6 +9,7 @@
#include "content/public/common/renderer_preferences.h"
#include "extensions/browser/api/app_runtime/app_runtime_api.h"
#include "extensions/browser/api/extensions_api_client.h"
+#include "extensions/browser/app_window/app_delegate.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
@@ -104,6 +105,8 @@ AppViewGuest::AppViewGuest(content::BrowserContext* browser_context,
app_view_guest_delegate_(
ExtensionsAPIClient::Get()->CreateAppViewGuestDelegate()),
weak_ptr_factory_(this) {
+ if (app_view_guest_delegate_)
+ app_delegate_.reset(app_view_guest_delegate_->CreateAppDelegate());
}
AppViewGuest::~AppViewGuest() {
@@ -133,6 +136,41 @@ bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) {
return false;
}
+void AppViewGuest::RequestMediaAccessPermission(
+ content::WebContents* web_contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) {
+ if (!app_delegate_) {
+ WebContentsDelegate::RequestMediaAccessPermission(web_contents, request,
+ callback);
+ return;
+ }
+ const ExtensionSet& enabled_extensions =
+ ExtensionRegistry::Get(browser_context())->enabled_extensions();
+ const Extension* guest_extension =
+ enabled_extensions.GetByID(guest_extension_id_);
+
+ app_delegate_->RequestMediaAccessPermission(web_contents, request, callback,
+ guest_extension);
+}
+
+bool AppViewGuest::CheckMediaAccessPermission(
+ content::WebContents* web_contents,
+ const GURL& security_origin,
+ content::MediaStreamType type) {
+ if (!app_delegate_) {
+ return WebContentsDelegate::CheckMediaAccessPermission(
+ web_contents, security_origin, type);
+ }
+ const ExtensionSet& enabled_extensions =
+ ExtensionRegistry::Get(browser_context())->enabled_extensions();
+ const Extension* guest_extension =
+ enabled_extensions.GetByID(guest_extension_id_);
+
+ return app_delegate_->CheckMediaAccessPermission(
+ web_contents, security_origin, type, guest_extension);
+}
+
const char* AppViewGuest::GetAPINamespace() const {
return appview::kEmbedderAPINamespace;
}
@@ -258,4 +296,8 @@ void AppViewGuest::LaunchAppAndFireEvent(
browser_context(), embed_request.Pass(), extension_host->extension());
}
+void AppViewGuest::SetAppDelegateForTest(AppDelegate* delegate) {
+ app_delegate_.reset(delegate);
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698