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

Unified Diff: components/web_restrictions/browser/java/src/org/chromium/components/webrestrictions/browser/WebRestrictionsClientResult.java

Issue 1890203002: Implement Web Restrictions in WebView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix final nits Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/web_restrictions/browser/java/src/org/chromium/components/webrestrictions/browser/WebRestrictionsClientResult.java
diff --git a/components/web_restrictions/browser/java/src/org/chromium/components/webrestrictions/browser/WebRestrictionsClientResult.java b/components/web_restrictions/browser/java/src/org/chromium/components/webrestrictions/browser/WebRestrictionsClientResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..548c4e36921db47f078effe651b39a32cf44ebb6
--- /dev/null
+++ b/components/web_restrictions/browser/java/src/org/chromium/components/webrestrictions/browser/WebRestrictionsClientResult.java
@@ -0,0 +1,84 @@
+// Copyright 2016 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.components.webrestrictions.browser;
+
+import android.database.Cursor;
+
+import org.chromium.base.annotations.CalledByNative;
+
+/**
+ * Result of a WebRestrictions should proceed request on the client size
+ */
+public class WebRestrictionsClientResult {
+ private final Cursor mCursor;
+
+ public WebRestrictionsClientResult(Cursor cursor) {
+ mCursor = cursor;
+ if (cursor == null) return;
+ cursor.moveToFirst();
+ }
+
+ /**
+ * @return true if it is ok to access the URL
+ */
+ @CalledByNative
+ public boolean shouldProceed() {
+ if (mCursor == null) return false;
+ return mCursor.getInt(0) > 0;
+ }
+
+ /**
+ * Get an integer element of the custom error data
+ * @param column the column number
+ * @return the value
+ */
+ @CalledByNative
+ public int getInt(int column) {
+ if (mCursor == null) return 0;
+ return mCursor.getInt(column);
+ }
+
+ /**
+ * Get a string element of the custom error data
+ * @param column column number
+ * @return the value
+ */
+ @CalledByNative
+ public String getString(int column) {
+ if (mCursor == null) return null;
+ return mCursor.getString(column);
+ }
+
+ /**
+ * Get the name of a column
+ * @param column column number
+ * @return the value
+ */
+ @CalledByNative
+ public String getColumnName(int column) {
+ if (mCursor == null) return null;
+ return mCursor.getColumnName(column);
+ }
+
+ /**
+ * @return the number of columns
+ */
+ @CalledByNative
+ public int getColumnCount() {
+ if (mCursor == null) return 0;
+ return mCursor.getColumnCount();
+ }
+
+ /**
+ * @param column column number
+ * @return whether the column is a string column
+ * @note all columns are either strings or ints.
+ */
+ @CalledByNative
+ public boolean isString(int column) {
+ if (mCursor == null) return false;
+ return mCursor.getType(column) == Cursor.FIELD_TYPE_STRING;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698