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

Unified Diff: components/web_restrictions/browser/javatest/src/org/chromium/components/webrestrictions/MockWebRestrictionsClient.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/javatest/src/org/chromium/components/webrestrictions/MockWebRestrictionsClient.java
diff --git a/components/web_restrictions/browser/javatest/src/org/chromium/components/webrestrictions/MockWebRestrictionsClient.java b/components/web_restrictions/browser/javatest/src/org/chromium/components/webrestrictions/MockWebRestrictionsClient.java
deleted file mode 100644
index 0b9af2a8eb7548f03948d833ab90622b6023107c..0000000000000000000000000000000000000000
--- a/components/web_restrictions/browser/javatest/src/org/chromium/components/webrestrictions/MockWebRestrictionsClient.java
+++ /dev/null
@@ -1,125 +0,0 @@
-// 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.components.webrestrictions;
-
-import android.database.AbstractCursor;
-
-import org.chromium.base.annotations.CalledByNative;
-
-/**
- * This is a dummy version of the real WebRestrictionsClient, to allow unit testing of the C++
- * code.
- */
-public class MockWebRestrictionsClient extends WebRestrictionsClient {
- private String mAuthority;
-
- @CalledByNative
- static void registerAsMockForTesting() {
- WebRestrictionsClient.registerMockForTesting(new MockWebRestrictionsClient());
- }
-
- @CalledByNative
- static void unregisterAsMockForTesting() {
- WebRestrictionsClient.registerMockForTesting(null);
- }
- /**
- * Start the web restriction provider and setup the content resolver.
- */
- private MockWebRestrictionsClient() {}
-
- @Override
- void init(String authority, long nativeProvider) {
- mAuthority = authority;
- }
-
- /**
- * @return whether the web restriction provider supports requesting access for a blocked url.
- */
- @Override
- boolean supportsRequest() {
- return mAuthority.contains("Good");
- }
-
- /**
- * Called when the ContentResolverWebRestrictionsProvider is about to be destroyed.
- */
- @Override
- void onDestroy() {}
-
- /**
- * Whether we can proceed with loading the {@code url}.
- * In case the url is not to be loaded, the web restriction provider can return an optional
- * error page to show instead.
- */
- @Override
- ShouldProceedResult shouldProceed(final String url) {
- return new ShouldProceedResult(new AbstractCursor() {
-
- @Override
- public int getCount() {
- return 0;
- }
-
- @Override
- public String[] getColumnNames() {
- return new String[] {"Result", "Error number", "Error string"};
- }
-
- @Override
- public int getColumnCount() {
- return mAuthority.contains("Good") ? 1 : 3;
- }
-
- @Override
- public String getString(int column) {
- if (column == 2 && !mAuthority.contains("Good")) return url;
- return null;
- }
-
- @Override
- public short getShort(int column) {
- return 0;
- }
-
- @Override
- public int getInt(int column) {
- if (column == 0 && mAuthority.contains("Good")) return 1;
- if (column == 1 && !mAuthority.contains("Good")) return 42;
- return 0;
- }
-
- @Override
- public long getLong(int column) {
- return 0;
- }
-
- @Override
- public float getFloat(int column) {
- return 0;
- }
-
- @Override
- public double getDouble(int column) {
- return 0;
- }
-
- @Override
- public boolean isNull(int column) {
- return false;
- }
-
- });
- }
-
- /**
- * Request permission to load the {@code url}.
- * The web restriction provider returns a {@code boolean} variable indicating whether it was
- * able to forward the request to the appropriate authority who can approve it.
- */
- @Override
- boolean requestPermission(final String url) {
- return mAuthority.contains("Good");
- }
-}

Powered by Google App Engine
This is Rietveld 408576698