summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxhwang <xhwang@chromium.org>2015-02-03 08:39:14 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-03 16:40:29 +0000
commit6be45c8c1662ef91fa22bbae645d4acfaa541fe5 (patch)
tree385f75bc9552dd50216b31295d6e30edd34dacd7
parentf2d4cd89181eea9a913487b5fe5c9f0a432955cf (diff)
downloadchromium_src-6be45c8c1662ef91fa22bbae645d4acfaa541fe5.zip
chromium_src-6be45c8c1662ef91fa22bbae645d4acfaa541fe5.tar.gz
chromium_src-6be45c8c1662ef91fa22bbae645d4acfaa541fe5.tar.bz2
media: Use PlatformVerificationDialog in PermissionContextBase on ChromeOS.
The current infobar/bubble doesn't work well with the text message and help link for protected media identifier permission request. With this CL, we'll show the existing platform verification modal UI when using ProtectedMediaIdentifierPermissionContext on ChromeOS. When we have an agreement on how to use the current infobar/bubble for protected media identifier permission request on ChromeOS, we can revert this CL. BUG=446263 Review URL: https://codereview.chromium.org/864753007 Cr-Commit-Position: refs/heads/master@{#314351}
-rw-r--r--chrome/browser/content_settings/permission_context_base.cc41
-rw-r--r--chrome/browser/content_settings/permission_context_base.h14
2 files changed, 55 insertions, 0 deletions
diff --git a/chrome/browser/content_settings/permission_context_base.cc b/chrome/browser/content_settings/permission_context_base.cc
index c188377..045ac48 100644
--- a/chrome/browser/content_settings/permission_context_base.cc
+++ b/chrome/browser/content_settings/permission_context_base.cc
@@ -18,6 +18,12 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/attestation/platform_verification_dialog.h"
+using chromeos::attestation::PlatformVerificationDialog;
+using chromeos::attestation::PlatformVerificationFlow;
+#endif
+
PermissionContextBase::PermissionContextBase(
Profile* profile,
const ContentSettingsType permission_type)
@@ -126,6 +132,19 @@ void PermissionContextBase::DecidePermission(
PermissionContextUmaUtil::PermissionRequested(
permission_type_, requesting_origin);
+#if defined(OS_CHROMEOS)
+ // TODO(xhwang): This is to use the existing platform verification UI. Remove
+ // it when the infobar/bubble UI can satisfy our requirements.
+ if (permission_type_ == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) {
+ PlatformVerificationDialog::ShowDialog(
+ web_contents,
+ base::Bind(&PermissionContextBase::OnPlatformVerificationResult,
+ weak_factory_.GetWeakPtr(), id, requesting_origin,
+ embedding_origin, callback));
+ return;
+ }
+#endif
+
if (PermissionBubbleManager::Enabled()) {
if (pending_bubbles_.get(id.ToString()) != NULL)
return;
@@ -229,3 +248,25 @@ void PermissionContextBase::UpdateContentSetting(const GURL& requesting_origin,
ContentSettingsPattern::FromURLNoWildcard(embedding_origin),
permission_type_, std::string(), content_setting);
}
+
+#if defined(OS_CHROMEOS)
+void PermissionContextBase::OnPlatformVerificationResult(
+ const PermissionRequestID& id,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin,
+ const BrowserPermissionCallback& callback,
+ chromeos::attestation::PlatformVerificationFlow::ConsentResponse response) {
+ if (response == PlatformVerificationFlow::CONSENT_RESPONSE_NONE) {
+ // Deny request and do not save to content settings.
+ PermissionDecided(id, requesting_origin, embedding_origin, callback,
+ false, // Do not save to content settings.
+ false); // Do not allow the permission.
+ return;
+ }
+
+ PermissionDecided(
+ id, requesting_origin, embedding_origin, callback,
+ true, // Save to content settings.
+ response == PlatformVerificationFlow::CONSENT_RESPONSE_ALLOW);
+}
+#endif
diff --git a/chrome/browser/content_settings/permission_context_base.h b/chrome/browser/content_settings/permission_context_base.h
index 740aa8f..fe711ec 100644
--- a/chrome/browser/content_settings/permission_context_base.h
+++ b/chrome/browser/content_settings/permission_context_base.h
@@ -15,6 +15,10 @@
#include "components/keyed_service/core/keyed_service.h"
#include "url/gurl.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
+#endif
+
class PermissionQueueController;
class PermissionRequestID;
class Profile;
@@ -127,6 +131,16 @@ class PermissionContextBase : public KeyedService {
// Called when a bubble is no longer used so it can be cleaned up.
void CleanUpBubble(const PermissionRequestID& id);
+#if defined(OS_CHROMEOS)
+ void OnPlatformVerificationResult(
+ const PermissionRequestID& id,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin,
+ const BrowserPermissionCallback& callback,
+ chromeos::attestation::PlatformVerificationFlow::ConsentResponse
+ response);
+#endif
+
Profile* profile_;
const ContentSettingsType permission_type_;
scoped_ptr<PermissionQueueController> permission_queue_controller_;