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

Side by Side Diff: chrome/browser/ui/android/page_info/page_info_popup_android.cc

Issue 2874073002: [subresource_filter] Always display the default setting in Android Page Info (Closed)
Patch Set: add dep PS and refactor Created 3 years, 7 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
« no previous file with comments | « chrome/browser/ui/android/page_info/page_info_popup_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/ui/android/page_info/page_info_popup_android.h" 5 #include "chrome/browser/ui/android/page_info/page_info_popup_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 NOTIMPLEMENTED(); 101 NOTIMPLEMENTED();
102 } 102 }
103 103
104 void PageInfoPopupAndroid::SetPermissionInfo( 104 void PageInfoPopupAndroid::SetPermissionInfo(
105 const PermissionInfoList& permission_info_list, 105 const PermissionInfoList& permission_info_list,
106 ChosenObjectInfoList chosen_object_info_list) { 106 ChosenObjectInfoList chosen_object_info_list) {
107 JNIEnv* env = base::android::AttachCurrentThread(); 107 JNIEnv* env = base::android::AttachCurrentThread();
108 108
109 // On Android, we only want to display a subset of the available options in a 109 // On Android, we only want to display a subset of the available options in a
110 // particular order, but only if their value is different from the default. 110 // particular order, but only if their value is different from the default.
111 // This order comes from https://crbug.com/610358.
111 std::vector<ContentSettingsType> permissions_to_display; 112 std::vector<ContentSettingsType> permissions_to_display;
112 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION); 113 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_GEOLOCATION);
113 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 114 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
114 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 115 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
115 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 116 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
116 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_IMAGES); 117 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_IMAGES);
117 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_JAVASCRIPT); 118 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_JAVASCRIPT);
118 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_POPUPS); 119 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_POPUPS);
120 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER);
119 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_AUTOPLAY); 121 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_AUTOPLAY);
120 permissions_to_display.push_back(CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER);
121 122
122 std::map<ContentSettingsType, ContentSetting> 123 std::map<ContentSettingsType, ContentSetting>
123 user_specified_settings_to_display; 124 user_specified_settings_to_display;
124 125
125 for (const auto& permission : permission_info_list) { 126 for (const auto& permission : permission_info_list) {
126 if (base::ContainsValue(permissions_to_display, permission.type)) { 127 if (base::ContainsValue(permissions_to_display, permission.type)) {
127 if (permission.setting != CONTENT_SETTING_DEFAULT) { 128 base::Optional<ContentSetting> setting_to_display =
129 GetSettingToDisplay(permission);
130 if (setting_to_display) {
128 user_specified_settings_to_display[permission.type] = 131 user_specified_settings_to_display[permission.type] =
129 permission.setting; 132 *setting_to_display;
130 } else if (permission.type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
131 if (search_geolocation_service_ &&
132 search_geolocation_service_->UseDSEGeolocationSetting(
133 url::Origin(url_))) {
134 user_specified_settings_to_display[permission.type] =
135 search_geolocation_service_->GetDSEGeolocationSetting()
136 ? CONTENT_SETTING_ALLOW
137 : CONTENT_SETTING_BLOCK;
138 }
139 } 133 }
140 } 134 }
141 } 135 }
142 136
143 for (const auto& permission : permissions_to_display) { 137 for (const auto& permission : permissions_to_display) {
144 if (base::ContainsKey(user_specified_settings_to_display, permission)) { 138 if (base::ContainsKey(user_specified_settings_to_display, permission)) {
145 base::string16 setting_title = 139 base::string16 setting_title =
146 PageInfoUI::PermissionTypeToUIString(permission); 140 PageInfoUI::PermissionTypeToUIString(permission);
147 141
148 Java_PageInfoPopup_addPermissionSection( 142 Java_PageInfoPopup_addPermissionSection(
149 env, popup_jobject_, ConvertUTF16ToJavaString(env, setting_title), 143 env, popup_jobject_, ConvertUTF16ToJavaString(env, setting_title),
150 static_cast<jint>(permission), 144 static_cast<jint>(permission),
151 static_cast<jint>(user_specified_settings_to_display[permission])); 145 static_cast<jint>(user_specified_settings_to_display[permission]));
152 } 146 }
153 } 147 }
154 148
155 for (const auto& chosen_object : chosen_object_info_list) { 149 for (const auto& chosen_object : chosen_object_info_list) {
156 base::string16 object_title = 150 base::string16 object_title =
157 PageInfoUI::ChosenObjectToUIString(*chosen_object); 151 PageInfoUI::ChosenObjectToUIString(*chosen_object);
158 152
159 Java_PageInfoPopup_addPermissionSection( 153 Java_PageInfoPopup_addPermissionSection(
160 env, popup_jobject_, ConvertUTF16ToJavaString(env, object_title), 154 env, popup_jobject_, ConvertUTF16ToJavaString(env, object_title),
161 static_cast<jint>(chosen_object->ui_info.content_settings_type), 155 static_cast<jint>(chosen_object->ui_info.content_settings_type),
162 static_cast<jint>(CONTENT_SETTING_ALLOW)); 156 static_cast<jint>(CONTENT_SETTING_ALLOW));
163 } 157 }
164 158
165 Java_PageInfoPopup_updatePermissionDisplay(env, popup_jobject_); 159 Java_PageInfoPopup_updatePermissionDisplay(env, popup_jobject_);
166 } 160 }
167 161
162 base::Optional<ContentSetting> PageInfoPopupAndroid::GetSettingToDisplay(
163 const PermissionInfo& permission) {
164 // All permissions should be displayed if they are non-default.
165 if (permission.setting != CONTENT_SETTING_DEFAULT)
166 return permission.setting;
167
168 // Handle exceptions for permissions which need to be displayed even if they
169 // are set to the default.
170 if (permission.type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
171 if (search_geolocation_service_ &&
172 search_geolocation_service_->UseDSEGeolocationSetting(
173 url::Origin(url_))) {
174 return search_geolocation_service_->GetDSEGeolocationSetting()
175 ? CONTENT_SETTING_ALLOW
176 : CONTENT_SETTING_BLOCK;
177 }
178 } else if (permission.type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) {
179 // The subresource filter permission should always display the default
180 // setting if it is showing up in Page Info. Logic for whether the
181 // setting should show up in Page Info is in ShouldShowPermission in
182 // page_info.cc.
183 return permission.default_setting;
184 }
185 return base::Optional<ContentSetting>();
186 }
187
168 // static 188 // static
169 bool PageInfoPopupAndroid::RegisterPageInfoPopupAndroid(JNIEnv* env) { 189 bool PageInfoPopupAndroid::RegisterPageInfoPopupAndroid(JNIEnv* env) {
170 return RegisterNativesImpl(env); 190 return RegisterNativesImpl(env);
171 } 191 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/page_info/page_info_popup_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698