summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedchoc@chromium.org <tedchoc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 00:18:11 +0000
committertedchoc@chromium.org <tedchoc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 00:18:11 +0000
commit1e4fdc0ba8d4438bda54a986be156f3d00081f4f (patch)
tree944a13956d01fabb4fbaac27cb230df0315eb116
parent9983928d0c2d6a43ce5c40d3cb8d9eb6773b7d01 (diff)
downloadchromium_src-1e4fdc0ba8d4438bda54a986be156f3d00081f4f.zip
chromium_src-1e4fdc0ba8d4438bda54a986be156f3d00081f4f.tar.gz
chromium_src-1e4fdc0ba8d4438bda54a986be156f3d00081f4f.tar.bz2
Disable incognito if parental controls are enabled on android.
Provides a hook to the Android application to specify whether parental controls are enabled and incognito should be disabled. TEST=build/android/test_runner.py gtest -s unit_tests BUG=329276 Review URL: https://codereview.chromium.org/136693011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245390 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/apk_test.gypi1
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/ChromiumApplication.java7
-rw-r--r--chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellApplication.java5
-rw-r--r--chrome/browser/android/chromium_application.cc6
-rw-r--r--chrome/browser/android/chromium_application.h3
-rw-r--r--chrome/browser/prefs/incognito_mode_prefs.cc22
-rw-r--r--chrome/browser/prefs/incognito_mode_prefs.h4
-rw-r--r--chrome/chrome_tests_unit.gypi13
-rw-r--r--chrome/test/android/unit_tests_apk/AndroidManifest.xml34
-rw-r--r--chrome/test/android/unit_tests_apk/src/org/chromium/chrome/unit_tests_apk/ChromeNativeTestApplication.java30
-rw-r--r--testing/android/java/AndroidManifest.xml (renamed from testing/android/AndroidManifest.xml)2
11 files changed, 120 insertions, 7 deletions
diff --git a/build/apk_test.gypi b/build/apk_test.gypi
index f774831..8ec23a2 100644
--- a/build/apk_test.gypi
+++ b/build/apk_test.gypi
@@ -31,7 +31,6 @@
'intermediate_dir': '<(PRODUCT_DIR)/<(test_suite_name)_apk',
'final_apk_path': '<(intermediate_dir)/<(test_suite_name)-debug.apk',
'java_in_dir': '<(DEPTH)/testing/android/java',
- 'android_manifest_path': '<(DEPTH)/testing/android/AndroidManifest.xml',
'native_lib_target': 'lib<(test_suite_name)',
# TODO(yfriedman, cjhopman): Support managed installs for gtests.
'gyp_managed_install': 0,
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromiumApplication.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromiumApplication.java
index 2cc9b86..d8a594b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromiumApplication.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromiumApplication.java
@@ -23,4 +23,11 @@ public abstract class ChromiumApplication extends ContentApplication {
@CalledByNative
protected abstract void showTermsOfServiceDialog();
+
+ /**
+ * @return Whether parental controls are enabled. Returning true will disable
+ * incognito mode.
+ */
+ @CalledByNative
+ protected abstract boolean areParentalControlsEnabled();
}
diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellApplication.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellApplication.java
index 5a6ee56..d7c43d1 100644
--- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellApplication.java
+++ b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellApplication.java
@@ -82,4 +82,9 @@ public class ChromiumTestShellApplication extends ChromiumApplication {
@Override
protected void showTermsOfServiceDialog() {
}
+
+ @Override
+ protected boolean areParentalControlsEnabled() {
+ return false;
+ }
}
diff --git a/chrome/browser/android/chromium_application.cc b/chrome/browser/android/chromium_application.cc
index 270a3f1..ff77aa5 100644
--- a/chrome/browser/android/chromium_application.cc
+++ b/chrome/browser/android/chromium_application.cc
@@ -33,5 +33,11 @@ void ChromiumApplication::ShowTermsOfServiceDialog() {
base::android::GetApplicationContext());
}
+bool ChromiumApplication::AreParentalControlsEnabled() {
+ return Java_ChromiumApplication_areParentalControlsEnabled(
+ base::android::AttachCurrentThread(),
+ base::android::GetApplicationContext());
+}
+
} // namespace android
} // namespace chrome
diff --git a/chrome/browser/android/chromium_application.h b/chrome/browser/android/chromium_application.h
index 36d235d..c2ecef2 100644
--- a/chrome/browser/android/chromium_application.h
+++ b/chrome/browser/android/chromium_application.h
@@ -28,6 +28,9 @@ class ChromiumApplication {
// Shows a dialog with the terms of service.
static void ShowTermsOfServiceDialog();
+ // Determines whether parental controls are enabled.
+ static bool AreParentalControlsEnabled();
+
private:
ChromiumApplication() {}
~ChromiumApplication() {}
diff --git a/chrome/browser/prefs/incognito_mode_prefs.cc b/chrome/browser/prefs/incognito_mode_prefs.cc
index 7ca0e29..f68709c 100644
--- a/chrome/browser/prefs/incognito_mode_prefs.cc
+++ b/chrome/browser/prefs/incognito_mode_prefs.cc
@@ -16,6 +16,10 @@
#include "base/win/metro.h"
#endif // OS_WIN
+#if defined(OS_ANDROID)
+#include "chrome/browser/android/chromium_application.h"
+#endif // OS_ANDROID
+
// static
bool IncognitoModePrefs::IntToAvailability(int in_value,
Availability* out_value) {
@@ -35,15 +39,11 @@ IncognitoModePrefs::Availability IncognitoModePrefs::GetAvailability(
Availability result = IncognitoModePrefs::ENABLED;
bool valid = IntToAvailability(pref_value, &result);
DCHECK(valid);
-#if defined(OS_WIN)
- // Disable incognito mode windows if parental controls are on. This is only
- // for Windows Vista and above.
- if (base::win::IsParentalControlActivityLoggingOn()) {
+ if (ArePlatformParentalControlsEnabled()) {
if (result == IncognitoModePrefs::FORCED)
LOG(ERROR) << "Ignoring FORCED incognito. Parental control logging on";
return IncognitoModePrefs::DISABLED;
}
-#endif // OS_WIN
return result;
}
@@ -87,3 +87,15 @@ bool IncognitoModePrefs::CanOpenBrowser(Profile* profile) {
NOTREACHED();
return false;
}
+
+// static
+bool IncognitoModePrefs::ArePlatformParentalControlsEnabled() {
+#if defined(OS_WIN)
+ // Disable incognito mode windows if parental controls are on. This is only
+ // for Windows Vista and above.
+ return base::win::IsParentalControlActivityLoggingOn();
+#elif defined(OS_ANDROID)
+ return chrome::android::ChromiumApplication::AreParentalControlsEnabled();
+#endif
+ return false;
+}
diff --git a/chrome/browser/prefs/incognito_mode_prefs.h b/chrome/browser/prefs/incognito_mode_prefs.h
index 9f366a6..698250f 100644
--- a/chrome/browser/prefs/incognito_mode_prefs.h
+++ b/chrome/browser/prefs/incognito_mode_prefs.h
@@ -61,6 +61,10 @@ class IncognitoModePrefs {
static bool CanOpenBrowser(Profile* profile);
private:
+ // Returns whether parental controls have been enabled on the platform, which
+ // if enabled will overrule the Availability as configured in prefs.
+ static bool ArePlatformParentalControlsEnabled();
+
DISALLOW_IMPLICIT_CONSTRUCTORS(IncognitoModePrefs);
};
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 8f6633c..2e868e7 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -2801,15 +2801,28 @@
['OS == "android" and gtest_target_type == "shared_library"', {
'targets': [
{
+ 'target_name': 'unit_tests_java',
+ 'type': 'none',
+ 'variables': {
+ 'java_in_dir': 'test/android/unit_tests_apk',
+ },
+ 'dependencies': [
+ 'chrome_java',
+ ],
+ 'includes': [ '../build/java.gypi' ],
+ },
+ {
'target_name': 'unit_tests_apk',
'type': 'none',
'dependencies': [
'chrome_java',
+ 'unit_tests_java',
'unit_tests',
],
'variables': {
'test_suite_name': 'unit_tests',
'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)unit_tests<(SHARED_LIB_SUFFIX)',
+ 'android_manifest_path': 'test/android/unit_tests_apk/AndroidManifest.xml',
},
'includes': [ '../build/apk_test.gypi' ],
},
diff --git a/chrome/test/android/unit_tests_apk/AndroidManifest.xml b/chrome/test/android/unit_tests_apk/AndroidManifest.xml
new file mode 100644
index 0000000..43b015e
--- /dev/null
+++ b/chrome/test/android/unit_tests_apk/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Copyright 2014 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.chromium.native_test"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+
+ <application android:label="ChromeNativeTests"
+ android:name="org.chromium.chrome.unit_tests_apk.ChromeNativeTestApplication">
+ <activity android:name="org.chromium.native_test.ChromeNativeTestActivity"
+ android:label="ChromeNativeTest"
+ android:configChanges="orientation|keyboardHidden">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.CAMERA" />
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
+ <uses-permission android:name="android.permission.RECORD_AUDIO"/>
+ <uses-permission android:name="android.permission.WAKE_LOCK"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+
+</manifest>
diff --git a/chrome/test/android/unit_tests_apk/src/org/chromium/chrome/unit_tests_apk/ChromeNativeTestApplication.java b/chrome/test/android/unit_tests_apk/src/org/chromium/chrome/unit_tests_apk/ChromeNativeTestApplication.java
new file mode 100644
index 0000000..3d87b70
--- /dev/null
+++ b/chrome/test/android/unit_tests_apk/src/org/chromium/chrome/unit_tests_apk/ChromeNativeTestApplication.java
@@ -0,0 +1,30 @@
+// Copyright 2014 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.chrome.unit_tests_apk;
+
+import org.chromium.chrome.browser.ChromiumApplication;
+
+/**
+ * A stub implementation of the chrome application to be used in chrome unit_tests.
+ */
+public class ChromeNativeTestApplication extends ChromiumApplication {
+
+ @Override
+ protected void openProtectedContentSettings() {
+ }
+
+ @Override
+ protected void showSyncSettings() {
+ }
+
+ @Override
+ protected void showTermsOfServiceDialog() {
+ }
+
+ @Override
+ protected boolean areParentalControlsEnabled() {
+ return false;
+ }
+}
diff --git a/testing/android/AndroidManifest.xml b/testing/android/java/AndroidManifest.xml
index 1b2c8c2..da2fee5 100644
--- a/testing/android/AndroidManifest.xml
+++ b/testing/android/java/AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
-Copyright (c) 2012 The Chromium Authors. All rights reserved.
+Copyright 2014 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.
-->