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

Side by Side Diff: android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java

Issue 1054203002: Enable NeedsBraces check and fix some checkstyle issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added if checks Created 5 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 package com.android.webview.chromium; 5 package com.android.webview.chromium;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.BitmapFactory; 9 import android.graphics.BitmapFactory;
10 import android.graphics.Canvas; 10 import android.graphics.Canvas;
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 */ 1188 */
1189 public static class PermissionRequestAdapter extends PermissionRequest { 1189 public static class PermissionRequestAdapter extends PermissionRequest {
1190 // TODO: Move the below definitions to AwPermissionRequest. 1190 // TODO: Move the below definitions to AwPermissionRequest.
1191 private static final long BITMASK_RESOURCE_VIDEO_CAPTURE = 1 << 1; 1191 private static final long BITMASK_RESOURCE_VIDEO_CAPTURE = 1 << 1;
1192 private static final long BITMASK_RESOURCE_AUDIO_CAPTURE = 1 << 2; 1192 private static final long BITMASK_RESOURCE_AUDIO_CAPTURE = 1 << 2;
1193 private static final long BITMASK_RESOURCE_PROTECTED_MEDIA_ID = 1 << 3; 1193 private static final long BITMASK_RESOURCE_PROTECTED_MEDIA_ID = 1 << 3;
1194 1194
1195 public static long toAwPermissionResources(String[] resources) { 1195 public static long toAwPermissionResources(String[] resources) {
1196 long result = 0; 1196 long result = 0;
1197 for (String resource : resources) { 1197 for (String resource : resources) {
1198 if (resource.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) 1198 if (resource.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) {
1199 result |= BITMASK_RESOURCE_VIDEO_CAPTURE; 1199 result |= BITMASK_RESOURCE_VIDEO_CAPTURE;
1200 else if (resource.equals(PermissionRequest.RESOURCE_AUDIO_CAPTUR E)) 1200 } else if (resource.equals(PermissionRequest.RESOURCE_AUDIO_CAPT URE)) {
1201 result |= BITMASK_RESOURCE_AUDIO_CAPTURE; 1201 result |= BITMASK_RESOURCE_AUDIO_CAPTURE;
1202 else if (resource.equals(PermissionRequest.RESOURCE_PROTECTED_ME DIA_ID)) 1202 } else if (resource.equals(PermissionRequest.RESOURCE_PROTECTED_ MEDIA_ID)) {
1203 result |= BITMASK_RESOURCE_PROTECTED_MEDIA_ID; 1203 result |= BITMASK_RESOURCE_PROTECTED_MEDIA_ID;
1204 }
1204 } 1205 }
1205 return result; 1206 return result;
1206 } 1207 }
1207 1208
1208 private static String[] toPermissionResources(long resources) { 1209 private static String[] toPermissionResources(long resources) {
1209 ArrayList<String> result = new ArrayList<String>(); 1210 ArrayList<String> result = new ArrayList<String>();
1210 if ((resources & BITMASK_RESOURCE_VIDEO_CAPTURE) != 0) 1211 if ((resources & BITMASK_RESOURCE_VIDEO_CAPTURE) != 0) {
1211 result.add(PermissionRequest.RESOURCE_VIDEO_CAPTURE); 1212 result.add(PermissionRequest.RESOURCE_VIDEO_CAPTURE);
1212 if ((resources & BITMASK_RESOURCE_AUDIO_CAPTURE) != 0) 1213 }
1214 if ((resources & BITMASK_RESOURCE_AUDIO_CAPTURE) != 0) {
1213 result.add(PermissionRequest.RESOURCE_AUDIO_CAPTURE); 1215 result.add(PermissionRequest.RESOURCE_AUDIO_CAPTURE);
1214 if ((resources & BITMASK_RESOURCE_PROTECTED_MEDIA_ID) != 0) 1216 }
1217 if ((resources & BITMASK_RESOURCE_PROTECTED_MEDIA_ID) != 0) {
1215 result.add(PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID); 1218 result.add(PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID);
1219 }
1216 String[] resource_array = new String[result.size()]; 1220 String[] resource_array = new String[result.size()];
1217 return result.toArray(resource_array); 1221 return result.toArray(resource_array);
1218 } 1222 }
1219 1223
1220 private AwPermissionRequest mAwPermissionRequest; 1224 private AwPermissionRequest mAwPermissionRequest;
1221 private String[] mResources; 1225 private String[] mResources;
1222 1226
1223 public PermissionRequestAdapter(AwPermissionRequest awPermissionRequest) { 1227 public PermissionRequestAdapter(AwPermissionRequest awPermissionRequest) {
1224 assert awPermissionRequest != null; 1228 assert awPermissionRequest != null;
1225 mAwPermissionRequest = awPermissionRequest; 1229 mAwPermissionRequest = awPermissionRequest;
(...skipping 11 matching lines...) Expand all
1237 if (mResources == null) { 1241 if (mResources == null) {
1238 mResources = toPermissionResources(mAwPermissionRequest.getR esources()); 1242 mResources = toPermissionResources(mAwPermissionRequest.getR esources());
1239 } 1243 }
1240 return mResources; 1244 return mResources;
1241 } 1245 }
1242 } 1246 }
1243 1247
1244 @Override 1248 @Override
1245 public void grant(String[] resources) { 1249 public void grant(String[] resources) {
1246 long requestedResource = mAwPermissionRequest.getResources(); 1250 long requestedResource = mAwPermissionRequest.getResources();
1247 if ((requestedResource & toAwPermissionResources(resources)) == requ estedResource) 1251 if ((requestedResource & toAwPermissionResources(resources)) == requ estedResource) {
1248 mAwPermissionRequest.grant(); 1252 mAwPermissionRequest.grant();
1249 else 1253 } else {
1250 mAwPermissionRequest.deny(); 1254 mAwPermissionRequest.deny();
1255 }
1251 } 1256 }
1252 1257
1253 @Override 1258 @Override
1254 public void deny() { 1259 public void deny() {
1255 mAwPermissionRequest.deny(); 1260 mAwPermissionRequest.deny();
1256 } 1261 }
1257 } 1262 }
1258 } 1263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698