diff options
author | tedchoc <tedchoc@chromium.org> | 2015-07-22 12:52:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-22 19:52:35 +0000 |
commit | 76bf8120ce6c788584212096886036d023d5c178 (patch) | |
tree | 5c31fc233839a1204455617b724878ca9cb47634 | |
parent | 0508456c6daa0785b5f9a65d4b91b931953d4a65 (diff) | |
download | chromium_src-76bf8120ce6c788584212096886036d023d5c178.zip chromium_src-76bf8120ce6c788584212096886036d023d5c178.tar.gz chromium_src-76bf8120ce6c788584212096886036d023d5c178.tar.bz2 |
Add an infobar to resolve android runtime permission mismatches.
With runtime permissions on android M, Chrome can get into a
mismatched state where a user had previously granted a site
a particular content setting (i.e. location), but then the user
goes into the app info and disable the required permission.
When a user is in this state, we want to prompt an infobar that
notifies the user of this mismatch and allows them to rectify it.
This patch only adds this infobar to geolocation, but it should
also be added to the media permission requests.
BUG=499393
Review URL: https://codereview.chromium.org/1240923002
Cr-Commit-Position: refs/heads/master@{#339939}
10 files changed, 471 insertions, 5 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/PermissionUpdateInfoBarDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/PermissionUpdateInfoBarDelegate.java new file mode 100644 index 0000000..6f7913c --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/PermissionUpdateInfoBarDelegate.java @@ -0,0 +1,123 @@ +// Copyright 2015 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. + +package org.chromium.chrome.browser.infobar; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.provider.Settings; + +import org.chromium.base.ActivityState; +import org.chromium.base.ApplicationStatus; +import org.chromium.base.ApplicationStatus.ActivityStateListener; +import org.chromium.base.CalledByNative; +import org.chromium.chrome.browser.preferences.PrefServiceBridge; +import org.chromium.content.browser.ContentViewCore; +import org.chromium.content_public.browser.WebContents; +import org.chromium.ui.base.WindowAndroid; + +import java.util.ArrayList; +import java.util.List; + +/** + * Handles requesting the android runtime permissions for the permission update infobar. + */ +class PermissionUpdateInfoBarDelegate implements WindowAndroid.PermissionCallback { + + private final WindowAndroid mWindowAndroid; + private final String[] mAndroidPermisisons; + private long mNativePtr; + private ActivityStateListener mActivityStateListener; + + @CalledByNative + private static PermissionUpdateInfoBarDelegate create( + long nativePtr, WebContents webContents, int[] contentSettings) { + return new PermissionUpdateInfoBarDelegate(nativePtr, webContents, contentSettings); + } + + private PermissionUpdateInfoBarDelegate( + long nativePtr, WebContents webContents, int[] contentSettings) { + mNativePtr = nativePtr; + + List<String> permissions = new ArrayList<String>(); + for (int i = 0; i < contentSettings.length; i++) { + String androidPermission = + PrefServiceBridge.getAndroidPermissionForContentSetting(contentSettings[i]); + if (androidPermission != null) permissions.add(androidPermission); + } + mAndroidPermisisons = permissions.toArray(new String[permissions.size()]); + mWindowAndroid = ContentViewCore.fromWebContents(webContents).getWindowAndroid(); + } + + @CalledByNative + private void onNativeDestroyed() { + mNativePtr = 0; + if (mActivityStateListener != null) { + ApplicationStatus.unregisterActivityStateListener(mActivityStateListener); + mActivityStateListener = null; + } + } + + @CalledByNative + private void requestPermissions() { + boolean canRequestAllPermissions = true; + for (int i = 0; i < mAndroidPermisisons.length; i++) { + canRequestAllPermissions &= + (mWindowAndroid.hasPermission(mAndroidPermisisons[i]) + || mWindowAndroid.canRequestPermission(mAndroidPermisisons[i])); + } + + if (canRequestAllPermissions) { + mWindowAndroid.requestPermissions(mAndroidPermisisons, this); + } else { + Activity activity = mWindowAndroid.getActivity().get(); + if (activity == null) { + nativeOnPermissionResult(mNativePtr, false); + return; + } + + mActivityStateListener = new ActivityStateListener() { + @Override + public void onActivityStateChange(Activity activity, int newState) { + if (newState == ActivityState.DESTROYED) { + ApplicationStatus.unregisterActivityStateListener(this); + mActivityStateListener = null; + + nativeOnPermissionResult(mNativePtr, false); + } else if (newState == ActivityState.RESUMED) { + ApplicationStatus.unregisterActivityStateListener(this); + mActivityStateListener = null; + + notifyPermissionResult(); + } + } + }; + ApplicationStatus.registerStateListenerForActivity(mActivityStateListener, activity); + + Intent settingsIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + settingsIntent.setData(Uri.parse( + "package:" + mWindowAndroid.getApplicationContext().getPackageName())); + settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + activity.startActivity(settingsIntent); + } + } + + @Override + public void onRequestPermissionsResult(String[] permissions, int[] grantResults) { + notifyPermissionResult(); + } + + private void notifyPermissionResult() { + boolean hasAllPermissions = true; + for (int i = 0; i < mAndroidPermisisons.length; i++) { + hasAllPermissions &= + mWindowAndroid.hasPermission(mAndroidPermisisons[i]); + } + if (mNativePtr != 0) nativeOnPermissionResult(mNativePtr, hasAllPermissions); + } + + private native void nativeOnPermissionResult( + long nativePermissionUpdateInfoBarDelegate, boolean allPermissionsGranted); +} diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index 164bf9a1..d72b5ea 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd @@ -1336,6 +1336,22 @@ and incorrect credentials. Either an attacker is trying to pretend to be <ph nam </message> </if> + <!-- Runtime permission infobar strings --> + <if expr="is_android"> + <message name="IDS_INFOBAR_MISSING_CAMERA_PERMISSION_TEXT" desc="Text shown in an infobar when a website has requested access to the camera capabilities, but Chrome is missing the Android camera permission."> + Chromium needs camera access to share it with this site. + </message> + <message name="IDS_INFOBAR_MISSING_MICROPHONE_PERMISSION_TEXT" desc="Text shown in an infobar when a website has requested access to the microphone capabilities, but Chrome is missing the Android microphone permission."> + Chromium needs microphone access to share it with this site. + </message> + <message name="IDS_INFOBAR_MISSING_LOCATION_PERMISSION_TEXT" desc="Text shown in an infobar when a website has requested access to the location capabilities, but Chrome is missing the Android location permission."> + Chromium needs location access to share it with this site. + </message> + <message name="IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT" desc="Text shown in an infobar when a website has requested access to the multiple restricted capabilities (e.g. location, camera, microphone), but Chrome is missing the corresponding Android permissions."> + Chromium needs permissions access to share them with this site. + </message> + </if> + <!-- OOBE --> <if expr="chromeos"> <message name="IDS_INSTALLING_UPDATE" desc="Label shown on the updates installation screen during OOBE"> diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 89b58b6..d592fbc 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -499,6 +499,13 @@ are declared in build/common.gypi. Customize </message> + <!-- Runtime permission infobar strings --> + <if expr="is_android"> + <message name="IDS_INFOBAR_UPDATE_PERMISSIONS_BUTTON_TEXT" desc="Button text shown when Chrome does not have the necessary permission required to complete the requested tasks (e.g. a website has request location information, but Chrome is missing that Android permission)." formatter_data="android_java"> + Update permissions + </message> + </if> + <message name="IDS_SHOWFULLHISTORY_LINK" desc="The label of the Show Full History link at the bottom of the back/forward menu."> Show Full History </message> diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index e7864a2..114624d 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd @@ -1259,6 +1259,22 @@ Signing in anyway will merge Chrome information like bookmarks, history, and oth </message> </if> + <!-- Runtime permission infobar strings --> + <if expr="is_android"> + <message name="IDS_INFOBAR_MISSING_CAMERA_PERMISSION_TEXT" desc="Text shown in an infobar when a website has requested access to the camera capabilities, but Chrome is missing the Android camera permission."> + Chrome needs camera access to share it with this site. + </message> + <message name="IDS_INFOBAR_MISSING_MICROPHONE_PERMISSION_TEXT" desc="Text shown in an infobar when a website has requested access to the microphone capabilities, but Chrome is missing the Android microphone permission."> + Chrome needs microphone access to share it with this site. + </message> + <message name="IDS_INFOBAR_MISSING_LOCATION_PERMISSION_TEXT" desc="Text shown in an infobar when a website has requested access to the location capabilities, but Chrome is missing the Android location permission."> + Chrome needs location access to share it with this site. + </message> + <message name="IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT" desc="Text shown in an infobar when a website has requested access to the multiple restricted capabilities (e.g. location, camera, microphone), but Chrome is missing the corresponding Android permissions."> + Chrome needs permissions access to share them with this site. + </message> + </if> + <!-- OOBE --> <if expr="chromeos"> <message name="IDS_INSTALLING_UPDATE" desc="Label shown on the updates installation screen during OOBE"> diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc index 600106d..e9fe76e 100644 --- a/chrome/browser/android/chrome_jni_registrar.cc +++ b/chrome/browser/android/chrome_jni_registrar.cc @@ -87,6 +87,7 @@ #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.h" #include "chrome/browser/notifications/notification_ui_manager_android.h" #include "chrome/browser/password_manager/credential_android.h" +#include "chrome/browser/permissions/permission_update_infobar_delegate_android.h" #include "chrome/browser/prerender/external_prerender_handler_android.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/search_engines/template_url_service_android.h" @@ -267,6 +268,8 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = { autofill::PasswordGenerationPopupViewAndroid::Register}, {"PasswordUIViewAndroid", PasswordUIViewAndroid::RegisterPasswordUIViewAndroid}, + {"PermissionUpdateInfoBarDelegate", + PermissionUpdateInfoBarDelegate::RegisterPermissionUpdateInfoBarDelegate}, {"PersonalDataManagerAndroid", autofill::PersonalDataManagerAndroid::Register}, {"PolicyManager", RegisterPolicyManager}, diff --git a/chrome/browser/geolocation/geolocation_permission_context_android.cc b/chrome/browser/geolocation/geolocation_permission_context_android.cc index 2441e59..3fd4ad1 100644 --- a/chrome/browser/geolocation/geolocation_permission_context_android.cc +++ b/chrome/browser/geolocation/geolocation_permission_context_android.cc @@ -4,16 +4,22 @@ #include "chrome/browser/geolocation/geolocation_permission_context_android.h" +#include <vector> + +#include "base/bind.h" #include "chrome/browser/android/location_settings.h" #include "chrome/browser/android/location_settings_impl.h" #include "chrome/browser/permissions/permission_request_id.h" +#include "chrome/browser/permissions/permission_update_infobar_delegate_android.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "url/gurl.h" GeolocationPermissionContextAndroid:: GeolocationPermissionContextAndroid(Profile* profile) : GeolocationPermissionContext(profile), - location_settings_(new LocationSettingsImpl()) { + location_settings_(new LocationSettingsImpl()), + weak_factory_(this) { } GeolocationPermissionContextAndroid::~GeolocationPermissionContextAndroid() { @@ -32,10 +38,43 @@ void GeolocationPermissionContextAndroid::RequestPermission( return; } + GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); + ContentSetting content_setting = + GeolocationPermissionContext::GetPermissionStatus(requesting_frame_origin, + embedding_origin); + std::vector<ContentSettingsType> content_settings_types; + content_settings_types.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION); + if (content_setting == CONTENT_SETTING_ALLOW && + PermissionUpdateInfoBarDelegate::ShouldShowPermissionInfobar( + web_contents, content_settings_types)) { + PermissionUpdateInfoBarDelegate::Create( + web_contents, content_settings_types, + base::Bind( + &GeolocationPermissionContextAndroid + ::HandleUpdateAndroidPermissions, + weak_factory_.GetWeakPtr(), id, requesting_frame_origin, + embedding_origin, callback)); + return; + } + GeolocationPermissionContext::RequestPermission( web_contents, id, requesting_frame_origin, user_gesture, callback); } +void GeolocationPermissionContextAndroid::HandleUpdateAndroidPermissions( + const PermissionRequestID& id, + const GURL& requesting_frame_origin, + const GURL& embedding_origin, + const BrowserPermissionCallback& callback, + bool permissions_updated) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + ContentSetting new_setting = permissions_updated + ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; + + NotifyPermissionSet(id, requesting_frame_origin, embedding_origin, callback, + false /* persist */, new_setting); +} + void GeolocationPermissionContextAndroid::SetLocationSettingsForTesting( scoped_ptr<LocationSettings> settings) { location_settings_ = settings.Pass(); diff --git a/chrome/browser/geolocation/geolocation_permission_context_android.h b/chrome/browser/geolocation/geolocation_permission_context_android.h index db24bfb..2391831 100644 --- a/chrome/browser/geolocation/geolocation_permission_context_android.h +++ b/chrome/browser/geolocation/geolocation_permission_context_android.h @@ -21,6 +21,7 @@ // // Otherwise the permission is already decided. #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "chrome/browser/geolocation/geolocation_permission_context.h" namespace content { @@ -43,10 +44,16 @@ class GeolocationPermissionContextAndroid // GeolocationPermissionContext: void RequestPermission( content::WebContents* web_contents, - const PermissionRequestID& id, - const GURL& requesting_frame_origin, - bool user_gesture, - const BrowserPermissionCallback& callback) override; + const PermissionRequestID& id, + const GURL& requesting_frame_origin, + bool user_gesture, + const BrowserPermissionCallback& callback) override; + + void HandleUpdateAndroidPermissions(const PermissionRequestID& id, + const GURL& requesting_frame_origin, + const GURL& embedding_origin, + const BrowserPermissionCallback& callback, + bool permissions_updated); // Overrides the LocationSettings object used to determine whether // system and Chrome-wide location permissions are enabled. @@ -54,6 +61,10 @@ class GeolocationPermissionContextAndroid scoped_ptr<LocationSettings> location_settings_; + // Must be the last member, to ensure that it will be destroyed first, which + // will invalidate weak pointers. + base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_; + DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); }; diff --git a/chrome/browser/permissions/permission_update_infobar_delegate_android.cc b/chrome/browser/permissions/permission_update_infobar_delegate_android.cc new file mode 100644 index 0000000..c1ca52a --- /dev/null +++ b/chrome/browser/permissions/permission_update_infobar_delegate_android.cc @@ -0,0 +1,172 @@ +// Copyright 2015 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/permissions/permission_update_infobar_delegate_android.h" + +#include <string> + +#include "base/android/jni_array.h" +#include "base/memory/scoped_ptr.h" +#include "chrome/browser/android/preferences/pref_service_bridge.h" +#include "chrome/browser/infobars/infobar_service.h" +#include "chrome/grit/chromium_strings.h" +#include "chrome/grit/generated_resources.h" +#include "chrome/grit/theme_resources.h" +#include "components/infobars/core/infobar.h" +#include "content/public/browser/android/content_view_core.h" +#include "content/public/browser/web_contents.h" +#include "jni/PermissionUpdateInfoBarDelegate_jni.h" +#include "ui/android/window_android.h" +#include "ui/base/l10n/l10n_util.h" + +// static +infobars::InfoBar* PermissionUpdateInfoBarDelegate::Create( + content::WebContents* web_contents, + const std::vector<ContentSettingsType>& content_settings_types, + const PermissionUpdatedCallback& callback) { + DCHECK(ShouldShowPermissionInfobar(web_contents, content_settings_types)) + << "Caller should check ShouldShowPermissionInfobar before creating the " + << "infobar."; + + InfoBarService* infobar_service = + InfoBarService::FromWebContents(web_contents); + if (!infobar_service) { + callback.Run(false); + return nullptr; + } + + return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( + scoped_ptr<ConfirmInfoBarDelegate>(new PermissionUpdateInfoBarDelegate( + web_contents, content_settings_types, callback)))); +} + +// static +bool PermissionUpdateInfoBarDelegate::ShouldShowPermissionInfobar( + content::WebContents* web_contents, + const std::vector<ContentSettingsType>& content_settings_types) { + if (!web_contents) + return false; + + content::ContentViewCore* cvc = + content::ContentViewCore::FromWebContents(web_contents); + if (!cvc || !cvc->GetWindowAndroid()) + return false; + ui::WindowAndroid* window_android = cvc->GetWindowAndroid(); + + for (ContentSettingsType content_settings_type : content_settings_types) { + std::string android_permission = + PrefServiceBridge::GetAndroidPermissionForContentSetting( + content_settings_type); + + if (!android_permission.empty() && + !window_android->HasPermission(android_permission)) { + return true; + } + } + + return false; +} + +// static +bool PermissionUpdateInfoBarDelegate::RegisterPermissionUpdateInfoBarDelegate( + JNIEnv* env) { + return RegisterNativesImpl(env); +} + +void PermissionUpdateInfoBarDelegate::OnPermissionResult( + JNIEnv* env, jobject obj, jboolean all_permissions_granted) { + callback_.Run(all_permissions_granted); + infobar()->RemoveSelf(); +} + +PermissionUpdateInfoBarDelegate::PermissionUpdateInfoBarDelegate( + content::WebContents* web_contents, + const std::vector<ContentSettingsType>& content_settings_types, + const PermissionUpdatedCallback& callback) + : ConfirmInfoBarDelegate(), + content_settings_types_(content_settings_types), + callback_(callback) { + std::vector<int> content_settings_type_values; + for (ContentSettingsType type : content_settings_types) + content_settings_type_values.push_back(type); + + JNIEnv* env = base::android::AttachCurrentThread(); + java_delegate_.Reset(Java_PermissionUpdateInfoBarDelegate_create( + env, + reinterpret_cast<intptr_t>(this), + web_contents->GetJavaWebContents().obj(), + base::android::ToJavaIntArray(env, content_settings_type_values).obj())); + + content::ContentViewCore* cvc = + content::ContentViewCore::FromWebContents(web_contents); + window_android_ = cvc->GetWindowAndroid(); +} + +PermissionUpdateInfoBarDelegate::~PermissionUpdateInfoBarDelegate() { + Java_PermissionUpdateInfoBarDelegate_onNativeDestroyed( + base::android::AttachCurrentThread(), java_delegate_.obj()); +} + +int PermissionUpdateInfoBarDelegate::GetIconID() const { + return IDR_INFOBAR_WARNING; +} + +base::string16 PermissionUpdateInfoBarDelegate::GetMessageText() const { + int missing_permission_count = 0; + int message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT; + + for (ContentSettingsType content_settings_type : content_settings_types_) { + std::string android_permission = + PrefServiceBridge::GetAndroidPermissionForContentSetting( + content_settings_type); + + if (!android_permission.empty() && + !window_android_->HasPermission(android_permission)) { + missing_permission_count++; + + switch (content_settings_type) { + case CONTENT_SETTINGS_TYPE_GEOLOCATION: + message_id = IDS_INFOBAR_MISSING_LOCATION_PERMISSION_TEXT; + break; + case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: + message_id = IDS_INFOBAR_MISSING_MICROPHONE_PERMISSION_TEXT; + break; + case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: + message_id = IDS_INFOBAR_MISSING_CAMERA_PERMISSION_TEXT; + break; + default: + NOTREACHED(); + message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT; + } + } + + if (missing_permission_count > 1) { + return l10n_util::GetStringUTF16( + IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT); + } + } + + return l10n_util::GetStringUTF16(message_id); +} + +int PermissionUpdateInfoBarDelegate::GetButtons() const { + return BUTTON_OK; +} + +base::string16 PermissionUpdateInfoBarDelegate::GetButtonLabel( + InfoBarButton button) const { + DCHECK_EQ(button, BUTTON_OK); + return l10n_util::GetStringUTF16(IDS_INFOBAR_UPDATE_PERMISSIONS_BUTTON_TEXT); +} + +bool PermissionUpdateInfoBarDelegate::Accept() { + Java_PermissionUpdateInfoBarDelegate_requestPermissions( + base::android::AttachCurrentThread(), java_delegate_.obj()); + return false; +} + +bool PermissionUpdateInfoBarDelegate::Cancel() { + callback_.Run(false); + return true; +} diff --git a/chrome/browser/permissions/permission_update_infobar_delegate_android.h b/chrome/browser/permissions/permission_update_infobar_delegate_android.h new file mode 100644 index 0000000..bdf83fd --- /dev/null +++ b/chrome/browser/permissions/permission_update_infobar_delegate_android.h @@ -0,0 +1,76 @@ +// Copyright 2015 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. + +#ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_UPDATE_INFOBAR_DELEGATE_ANDROID_H_ +#define CHROME_BROWSER_PERMISSIONS_PERMISSION_UPDATE_INFOBAR_DELEGATE_ANDROID_H_ + +#include <jni.h> +#include <vector> + +#include "base/android/scoped_java_ref.h" +#include "base/callback.h" +#include "base/strings/string16.h" +#include "components/content_settings/core/common/content_settings_types.h" +#include "components/infobars/core/confirm_infobar_delegate.h" + +namespace content { +class WebContents; +} + +namespace ui { +class WindowAndroid; +} + +// An infobar delegate to be used for requesting missing Android runtime +// permissions for previously allowed ContentSettingsTypes. +class PermissionUpdateInfoBarDelegate : public ConfirmInfoBarDelegate { + public: + using PermissionUpdatedCallback = base::Callback<void(bool)>; + + // Creates an infobar to resolve conflicts in Android runtime permissions + // and adds the infobar to |infobar_service|. Returns the infobar if it was + // successfully added. + static infobars::InfoBar* Create( + content::WebContents* web_contents, + const std::vector<ContentSettingsType>& content_settings_types, + const PermissionUpdatedCallback& callback); + + // Return whether the runtime permissions currently granted to Chrome by + // Android are compatible with ContentSettingTypes previously granted to a + // site by the user. + static bool ShouldShowPermissionInfobar( + content::WebContents* web_contents, + const std::vector<ContentSettingsType>& content_settings_types); + + static bool RegisterPermissionUpdateInfoBarDelegate(JNIEnv* env); + + void OnPermissionResult( + JNIEnv* env, jobject obj, jboolean all_permissions_granted); + + private: + PermissionUpdateInfoBarDelegate( + content::WebContents* web_contents, + const std::vector<ContentSettingsType>& content_settings_types, + const PermissionUpdatedCallback& callback); + ~PermissionUpdateInfoBarDelegate() override; + + // PermissionInfoBarDelegate: + int GetIconID() const override; + base::string16 GetMessageText() const override; + + // ConfirmInfoBarDelegate: + int GetButtons() const override; + base::string16 GetButtonLabel(InfoBarButton button) const override; + bool Accept() override; + bool Cancel() override; + + base::android::ScopedJavaGlobalRef<jobject> java_delegate_; + std::vector<ContentSettingsType> content_settings_types_; + const PermissionUpdatedCallback callback_; + ui::WindowAndroid* window_android_; + + DISALLOW_COPY_AND_ASSIGN(PermissionUpdateInfoBarDelegate); +}; + +#endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_UPDATE_INFOBAR_DELEGATE_ANDROID_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index cdd46e4..1984fa9 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1796,6 +1796,7 @@ 'android/java/src/org/chromium/chrome/browser/infobar/GeneratedPasswordSavedInfoBarDelegate.java', 'android/java/src/org/chromium/chrome/browser/infobar/InfoBar.java', 'android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java', + 'android/java/src/org/chromium/chrome/browser/infobar/PermissionUpdateInfoBarDelegate.java', 'android/java/src/org/chromium/chrome/browser/infobar/SavePasswordInfoBar.java', 'android/java/src/org/chromium/chrome/browser/invalidation/InvalidationServiceFactory.java', 'android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java', @@ -2077,6 +2078,8 @@ 'browser/permissions/permission_queue_controller.h', 'browser/permissions/permission_request_id.cc', 'browser/permissions/permission_request_id.h', + 'browser/permissions/permission_update_infobar_delegate_android.cc', + 'browser/permissions/permission_update_infobar_delegate_android.h', ], # See also the plugin_installation_sources list below. 'chrome_browser_plugins_sources': [ |