Commit 3088202c authored by gogerald's avatar gogerald Committed by Commit bot

Add Google Activity Controls preference

This CL adds Google Activity Controls preference in setting sign in account management screen and an icon for sync preference.

BUG=595349

Review URL: https://codereview.chromium.org/1880203002

Cr-Commit-Position: refs/heads/master@{#388608}
parent 706399be
......@@ -40,9 +40,16 @@
android:title="@string/sign_in_sync"
android:order="1005"/>
<Preference
android:key="google_activity_controls"
android:icon="@drawable/googleg"
android:title="@string/sign_in_google_activity_controls"
android:summary="@string/sign_in_google_activity_controls_message"
android:order="1006" />
<Preference
android:key="sign_out"
android:title="@string/account_management_sign_out"
android:order="1006"/>
android:order="1007"/>
</PreferenceScreen>
......@@ -77,6 +77,7 @@ import org.chromium.chrome.browser.services.AccountsChangedReceiver;
import org.chromium.chrome.browser.services.AndroidEduOwnerCheckCallback;
import org.chromium.chrome.browser.services.GoogleServicesManager;
import org.chromium.chrome.browser.share.ShareHelper;
import org.chromium.chrome.browser.signin.GoogleActivityController;
import org.chromium.chrome.browser.sync.GmsCoreSyncListener;
import org.chromium.chrome.browser.sync.SyncController;
import org.chromium.chrome.browser.tab.AuthenticatorNavigationInterceptor;
......@@ -722,6 +723,13 @@ public class ChromeApplication extends ContentApplication {
return null;
}
/**
* @return An instance of GoogleActivityController.
*/
public GoogleActivityController createGoogleActivityController() {
return new GoogleActivityController();
}
/**
* @return An instance of AppDetailsDelegate that can be queried about app information for the
* App Banner feature. Will be null if one is unavailable.
......
......@@ -32,4 +32,6 @@ public class UrlConstants {
public static final String PHYSICAL_WEB_HOST = "physical-web";
public static final String ABOUT_BLANK = "about:blank";
public static final String GOOGLE_ACCOUNT_ACTIVITY_CONTROLS_URL =
"https://myaccount.google.com/activitycontrols/search";
}
......@@ -22,6 +22,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.UserManager;
......@@ -34,7 +35,10 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Pair;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeApplication;
import org.chromium.chrome.browser.childaccounts.ChildAccountService;
import org.chromium.chrome.browser.preferences.ChromeBasePreference;
import org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate;
......@@ -106,6 +110,7 @@ public class AccountManagementFragment extends PreferenceFragment
public static final String PREF_PARENT_ACCOUNTS = "parent_accounts";
public static final String PREF_CHILD_CONTENT = "child_content";
public static final String PREF_CHILD_SAFE_SITES = "child_safe_sites";
public static final String PREF_GOOGLE_ACTIVITY_CONTROLS = "google_activity_controls";
public static final String PREF_SYNC_SETTINGS = "sync_settings";
private int mGaiaServiceType;
......@@ -196,6 +201,7 @@ public class AccountManagementFragment extends PreferenceFragment
configureAddAccountPreference();
configureChildAccountPreferences();
configureSyncSettings();
configureGoogleActivityControls();
updateAccountsList();
}
......@@ -247,6 +253,13 @@ public class AccountManagementFragment extends PreferenceFragment
private void configureSyncSettings() {
SyncPreference pref = (SyncPreference) findPreference(PREF_SYNC_SETTINGS);
// Sets preference icon and tints it to blue.
Drawable icon = ApiCompatibilityUtils.getDrawable(
getResources(), R.drawable.permission_background_sync);
icon.setColorFilter(
ApiCompatibilityUtils.getColor(getResources(), R.color.light_active_color),
PorterDuff.Mode.SRC_IN);
pref.setIcon(icon);
final Preferences preferences = (Preferences) getActivity();
final Account account = ChromeSigninController.get(getActivity()).getSignedInUser();
......@@ -270,6 +283,22 @@ public class AccountManagementFragment extends PreferenceFragment
});
}
private void configureGoogleActivityControls() {
Preference pref = (Preference) findPreference(PREF_GOOGLE_ACTIVITY_CONTROLS);
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Activity activity = getActivity();
((ChromeApplication) (activity.getApplicationContext()))
.createGoogleActivityController()
.openWebAndAppActivitySettings(activity,
ChromeSigninController.get(activity).getSignedInAccountName());
RecordUserAction.record("Signin_AccountSettings_GoogleActivityControlsClicked");
return true;
}
});
}
private void configureAddAccountPreference() {
ChromeBasePreference addAccount = (ChromeBasePreference) findPreference(PREF_ADD_ACCOUNT);
......
// 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.chrome.browser.signin;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.provider.Browser;
import org.chromium.chrome.browser.UrlConstants;
/**
* Controls how Google uses Chrome data to personalize Search and other Google services.
*/
public class GoogleActivityController {
/**
* Opens the "Web & App Activity" settings that allows the user to control how Google uses Chrome
* browsing history.
* @param activity The activity to open the settings.
* @param accountName The account for which is requested.
*/
public void openWebAndAppActivitySettings(Activity activity, String accountName) {
Intent intent = new Intent(
Intent.ACTION_VIEW, Uri.parse(UrlConstants.GOOGLE_ACCOUNT_ACTIVITY_CONTROLS_URL));
intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName());
intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
intent.setPackage(activity.getPackageName());
activity.startActivity(intent);
}
}
......@@ -213,6 +213,12 @@ CHAR-LIMIT guidelines:
<message name="IDS_SIGN_IN_TO_CHROME_SUMMARY" desc="Summary for the button to sign in to Chrome, explaining benefits of signing in.">
Sign in to get your bookmarks, history, passwords, and other settings on all your devices
</message>
<message name="IDS_SIGN_IN_GOOGLE_ACTIVITY_CONTROLS" desc="Title of Google activity controls preference in signed in accouts settings screen">
Google Activity Controls
</message>
<message name="IDS_SIGN_IN_GOOGLE_ACTIVITY_CONTROLS_MESSAGE" desc="Message of Google activity controls preference in signed in accouts settings screen">
Control how Google uses your browsing history to personalize Search and other Google services.
</message>
<!-- Search engine preferences -->
<message name="IDS_PREFS_SEARCH_ENGINE" desc="Title for Search Engine preferences. [CHAR-LIMIT=32]">
......
......@@ -729,6 +729,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/signin/AccountTrackerService.java",
"java/src/org/chromium/chrome/browser/signin/AddGoogleAccountDialogFragment.java",
"java/src/org/chromium/chrome/browser/signin/ConfirmManagedSigninFragment.java",
"java/src/org/chromium/chrome/browser/signin/GoogleActivityController.java",
"java/src/org/chromium/chrome/browser/signin/OAuth2TokenService.java",
"java/src/org/chromium/chrome/browser/signin/SignOutDialogFragment.java",
"java/src/org/chromium/chrome/browser/signin/SigninHelper.java",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment