summaryrefslogtreecommitdiffstats
path: root/chrome/browser/media/protected_media_identifier_infobar_delegate.cc
diff options
context:
space:
mode:
authorkkimlabs@chromium.org <kkimlabs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-23 04:15:45 +0000
committerkkimlabs@chromium.org <kkimlabs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-23 04:15:45 +0000
commitf961a0fedd9bfae93284d6d0d989f42da3caac7b (patch)
tree770a1f9679799f8e50decff35ecc27cad4d89f8a /chrome/browser/media/protected_media_identifier_infobar_delegate.cc
parentd34e683c837a2e48a19c576b768ea516b2dfca1f (diff)
downloadchromium_src-f961a0fedd9bfae93284d6d0d989f42da3caac7b.zip
chromium_src-f961a0fedd9bfae93284d6d0d989f42da3caac7b.tar.gz
chromium_src-f961a0fedd9bfae93284d6d0d989f42da3caac7b.tar.bz2
[Android] EME permission on/off pref and infobar UI.
For protected media identifier access permission, add global on/off preference setting and infobar permission gate UI. BUG=281576 Review URL: https://chromiumcodereview.appspot.com/23531021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/media/protected_media_identifier_infobar_delegate.cc')
-rw-r--r--chrome/browser/media/protected_media_identifier_infobar_delegate.cc108
1 files changed, 108 insertions, 0 deletions
diff --git a/chrome/browser/media/protected_media_identifier_infobar_delegate.cc b/chrome/browser/media/protected_media_identifier_infobar_delegate.cc
new file mode 100644
index 0000000..bde3fbf
--- /dev/null
+++ b/chrome/browser/media/protected_media_identifier_infobar_delegate.cc
@@ -0,0 +1,108 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/media/protected_media_identifier_infobar_delegate.h"
+
+#include "chrome/browser/content_settings/permission_queue_controller.h"
+#include "content/public/browser/navigation_details.h"
+#include "content/public/browser/navigation_entry.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+#include "net/base/net_util.h"
+#include "ui/base/l10n/l10n_util.h"
+
+// static
+InfoBarDelegate* ProtectedMediaIdentifierInfoBarDelegate::Create(
+ InfoBarService* infobar_service,
+ PermissionQueueController* controller,
+ const PermissionRequestID& id,
+ const GURL& requesting_frame,
+ const std::string& display_languages) {
+ const content::NavigationEntry* committed_entry =
+ infobar_service->web_contents()->GetController().GetLastCommittedEntry();
+ return infobar_service->AddInfoBar(
+ scoped_ptr<InfoBarDelegate>(new ProtectedMediaIdentifierInfoBarDelegate(
+ infobar_service,
+ controller,
+ id,
+ requesting_frame,
+ committed_entry ? committed_entry->GetUniqueID() : 0,
+ display_languages)));
+}
+
+
+ProtectedMediaIdentifierInfoBarDelegate::
+ ProtectedMediaIdentifierInfoBarDelegate(
+ InfoBarService* infobar_service,
+ PermissionQueueController* controller,
+ const PermissionRequestID& id,
+ const GURL& requesting_frame,
+ int contents_unique_id,
+ const std::string& display_languages)
+ : ConfirmInfoBarDelegate(infobar_service),
+ controller_(controller),
+ id_(id),
+ requesting_frame_(requesting_frame),
+ contents_unique_id_(contents_unique_id),
+ display_languages_(display_languages) {}
+
+ProtectedMediaIdentifierInfoBarDelegate::
+ ~ProtectedMediaIdentifierInfoBarDelegate() {}
+
+bool ProtectedMediaIdentifierInfoBarDelegate::Accept() {
+ SetPermission(true, true);
+ return true;
+}
+
+void ProtectedMediaIdentifierInfoBarDelegate::SetPermission(
+ bool update_content_setting,
+ bool allowed) {
+ controller_->OnPermissionSet(id_,
+ requesting_frame_,
+ web_contents()->GetLastCommittedURL(),
+ update_content_setting,
+ allowed);
+}
+
+void ProtectedMediaIdentifierInfoBarDelegate::InfoBarDismissed() {
+ SetPermission(false, false);
+}
+
+int ProtectedMediaIdentifierInfoBarDelegate::GetIconID() const {
+ return IDR_PROTECTED_MEDIA_IDENTIFIER_INFOBAR_ICON;
+}
+
+InfoBarDelegate::Type ProtectedMediaIdentifierInfoBarDelegate::GetInfoBarType()
+ const {
+ return PAGE_ACTION_TYPE;
+}
+
+bool ProtectedMediaIdentifierInfoBarDelegate::ShouldExpireInternal(
+ const content::LoadCommittedDetails& details) const {
+ // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but
+ // uses the unique ID we set in the constructor instead of that stored in the
+ // base class.
+ return (contents_unique_id_ != details.entry->GetUniqueID()) ||
+ (content::PageTransitionStripQualifier(
+ details.entry->GetTransitionType()) ==
+ content::PAGE_TRANSITION_RELOAD);
+}
+
+string16 ProtectedMediaIdentifierInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(
+ IDS_PROTECTED_MEDIA_IDENTIFIER_INFOBAR_QUESTION,
+ net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_));
+}
+
+string16 ProtectedMediaIdentifierInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ return l10n_util::GetStringUTF16(
+ (button == BUTTON_OK) ? IDS_PROTECTED_MEDIA_IDENTIFIER_ALLOW_BUTTON
+ : IDS_PROTECTED_MEDIA_IDENTIFIER_DENY_BUTTON);
+}
+
+bool ProtectedMediaIdentifierInfoBarDelegate::Cancel() {
+ SetPermission(true, false);
+ return true;
+}