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

Side by Side Diff: chrome/browser/permissions/permission_update_infobar_delegate_android.cc

Issue 1362803002: Add logic to resolve permission mismatches in Android M for webrtc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment in media_stream_devices_controller Created 5 years, 3 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/permissions/permission_update_infobar_delegate_android. h" 5 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/android/jni_array.h" 9 #include "base/android/jni_array.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 // static 71 // static
72 bool PermissionUpdateInfoBarDelegate::RegisterPermissionUpdateInfoBarDelegate( 72 bool PermissionUpdateInfoBarDelegate::RegisterPermissionUpdateInfoBarDelegate(
73 JNIEnv* env) { 73 JNIEnv* env) {
74 return RegisterNativesImpl(env); 74 return RegisterNativesImpl(env);
75 } 75 }
76 76
77 void PermissionUpdateInfoBarDelegate::OnPermissionResult( 77 void PermissionUpdateInfoBarDelegate::OnPermissionResult(
78 JNIEnv* env, jobject obj, jboolean all_permissions_granted) { 78 JNIEnv* env, jobject obj, jboolean all_permissions_granted) {
79 callback_.Run(all_permissions_granted); 79 PermissionUpdatedCallback cb = callback_;
Guido Urdaneta 2015/09/23 13:32:14 Can you use base::ResetAndReturn() here?
Ted C 2015/09/23 19:45:34 Neat! Done
Peter Kasting 2016/09/21 21:33:44 This change got referenced in another review I was
Peter Kasting 2016/09/21 21:37:08 To be clear: I understand why you want to reset th
80 callback_.Reset();
81 cb.Run(all_permissions_granted);
82
80 infobar()->RemoveSelf(); 83 infobar()->RemoveSelf();
81 } 84 }
82 85
83 PermissionUpdateInfoBarDelegate::PermissionUpdateInfoBarDelegate( 86 PermissionUpdateInfoBarDelegate::PermissionUpdateInfoBarDelegate(
84 content::WebContents* web_contents, 87 content::WebContents* web_contents,
85 const std::vector<ContentSettingsType>& content_settings_types, 88 const std::vector<ContentSettingsType>& content_settings_types,
86 const PermissionUpdatedCallback& callback) 89 const PermissionUpdatedCallback& callback)
87 : ConfirmInfoBarDelegate(), 90 : ConfirmInfoBarDelegate(),
88 content_settings_types_(content_settings_types), 91 content_settings_types_(content_settings_types),
89 callback_(callback) { 92 callback_(callback) {
90 std::vector<int> content_settings_type_values; 93 std::vector<int> content_settings_type_values;
91 for (ContentSettingsType type : content_settings_types) 94 for (ContentSettingsType type : content_settings_types)
92 content_settings_type_values.push_back(type); 95 content_settings_type_values.push_back(type);
93 96
94 JNIEnv* env = base::android::AttachCurrentThread(); 97 JNIEnv* env = base::android::AttachCurrentThread();
95 java_delegate_.Reset(Java_PermissionUpdateInfoBarDelegate_create( 98 java_delegate_.Reset(Java_PermissionUpdateInfoBarDelegate_create(
96 env, 99 env,
97 reinterpret_cast<intptr_t>(this), 100 reinterpret_cast<intptr_t>(this),
98 web_contents->GetJavaWebContents().obj(), 101 web_contents->GetJavaWebContents().obj(),
99 base::android::ToJavaIntArray(env, content_settings_type_values).obj())); 102 base::android::ToJavaIntArray(env, content_settings_type_values).obj()));
100 103
101 content::ContentViewCore* cvc = 104 content::ContentViewCore* cvc =
102 content::ContentViewCore::FromWebContents(web_contents); 105 content::ContentViewCore::FromWebContents(web_contents);
103 window_android_ = cvc->GetWindowAndroid(); 106 window_android_ = cvc->GetWindowAndroid();
104 } 107 }
105 108
106 PermissionUpdateInfoBarDelegate::~PermissionUpdateInfoBarDelegate() { 109 PermissionUpdateInfoBarDelegate::~PermissionUpdateInfoBarDelegate() {
107 Java_PermissionUpdateInfoBarDelegate_onNativeDestroyed( 110 Java_PermissionUpdateInfoBarDelegate_onNativeDestroyed(
108 base::android::AttachCurrentThread(), java_delegate_.obj()); 111 base::android::AttachCurrentThread(), java_delegate_.obj());
112
113 if (!callback_.is_null())
114 callback_.Run(false);
109 } 115 }
110 116
111 int PermissionUpdateInfoBarDelegate::GetIconId() const { 117 int PermissionUpdateInfoBarDelegate::GetIconId() const {
112 return IDR_INFOBAR_WARNING; 118 return IDR_INFOBAR_WARNING;
113 } 119 }
114 120
115 base::string16 PermissionUpdateInfoBarDelegate::GetMessageText() const { 121 base::string16 PermissionUpdateInfoBarDelegate::GetMessageText() const {
116 int missing_permission_count = 0; 122 int missing_permission_count = 0;
117 int message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT; 123 int message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT;
118 124
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return l10n_util::GetStringUTF16(IDS_INFOBAR_UPDATE_PERMISSIONS_BUTTON_TEXT); 166 return l10n_util::GetStringUTF16(IDS_INFOBAR_UPDATE_PERMISSIONS_BUTTON_TEXT);
161 } 167 }
162 168
163 bool PermissionUpdateInfoBarDelegate::Accept() { 169 bool PermissionUpdateInfoBarDelegate::Accept() {
164 Java_PermissionUpdateInfoBarDelegate_requestPermissions( 170 Java_PermissionUpdateInfoBarDelegate_requestPermissions(
165 base::android::AttachCurrentThread(), java_delegate_.obj()); 171 base::android::AttachCurrentThread(), java_delegate_.obj());
166 return false; 172 return false;
167 } 173 }
168 174
169 bool PermissionUpdateInfoBarDelegate::Cancel() { 175 bool PermissionUpdateInfoBarDelegate::Cancel() {
170 callback_.Run(false); 176 PermissionUpdatedCallback cb = callback_;
Guido Urdaneta 2015/09/23 13:32:14 base::ResetAndReturn()
177 callback_.Reset();
178 cb.Run(false);
179
171 return true; 180 return true;
172 } 181 }
182
183 void PermissionUpdateInfoBarDelegate::InfoBarDismissed() {
184 PermissionUpdatedCallback cb = callback_;
185 callback_.Reset();
186 cb.Run(false);
187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698