org.chromium.chrome.browser.physicalweb.PhysicalWeb Java Examples

The following examples show how to use org.chromium.chrome.browser.physicalweb.PhysicalWeb. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PhysicalWebPreferenceFragment.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[],
                                       int[] grantResults) {
    switch (requestCode) {
        case REQUEST_ID:
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                PhysicalWebUma.onPrefsLocationGranted(getActivity());
                Log.d(TAG, "Location permission granted");
                PhysicalWeb.startPhysicalWeb(
                        (ChromeApplication) getActivity().getApplicationContext());
            } else {
                PhysicalWebUma.onPrefsLocationDenied(getActivity());
                Log.d(TAG, "Location permission denied");
            }
            break;
        default:
    }
}
 
Example #2
Source File: PhysicalWebPreferenceFragment.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[],
                                       int[] grantResults) {
    switch (requestCode) {
        case REQUEST_ID:
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                PhysicalWebUma.onPrefsLocationGranted(getActivity());
                Log.d(TAG, "Location permission granted");
                PhysicalWeb.startPhysicalWeb();
            } else {
                PhysicalWebUma.onPrefsLocationDenied(getActivity());
                Log.d(TAG, "Location permission denied");
            }
            break;
        default:
    }
}
 
Example #3
Source File: PhysicalWebPreferenceFragment.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[],
                                       int[] grantResults) {
    switch (requestCode) {
        case REQUEST_ID:
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                PhysicalWebUma.onPrefsLocationGranted();
                Log.d(TAG, "Location permission granted");
            } else {
                PhysicalWebUma.onPrefsLocationDenied();
                Log.d(TAG, "Location permission denied");
            }
            break;
        default:
    }
    PhysicalWeb.updateScans();
}
 
Example #4
Source File: PrivacyPreferencesManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the Physical Web preference, which enables background scanning for bluetooth beacons
 * and displays a notification when beacons are found.
 *
 * @param enabled A boolean indicating whether to notify on nearby beacons.
 */
public void setPhysicalWebEnabled(boolean enabled) {
    int state = enabled ? PHYSICAL_WEB_ON : PHYSICAL_WEB_OFF;
    boolean isOnboarding = isPhysicalWebOnboarding();
    mSharedPreferences.edit().putInt(PREF_PHYSICAL_WEB, state).apply();
    if (enabled) {
        if (!isOnboarding) {
            PhysicalWeb.startPhysicalWeb((ChromeApplication) mContext);
        }
    } else {
        PhysicalWeb.stopPhysicalWeb((ChromeApplication) mContext);
    }
}
 
Example #5
Source File: PrivacyPreferencesManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the Physical Web preference, which enables background scanning for bluetooth beacons
 * and displays a notification when beacons are found.
 *
 * @param enabled A boolean indicating whether to notify on nearby beacons.
 */
public void setPhysicalWebEnabled(boolean enabled) {
    int state = enabled ? PHYSICAL_WEB_ON : PHYSICAL_WEB_OFF;
    boolean isOnboarding = isPhysicalWebOnboarding();
    mSharedPreferences.edit().putInt(PREF_PHYSICAL_WEB, state).apply();
    if (enabled) {
        if (!isOnboarding) {
            PhysicalWeb.startPhysicalWeb();
        }
    } else {
        PhysicalWeb.stopPhysicalWeb();
    }
}
 
Example #6
Source File: PrivacyPreferencesManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the Physical Web preference, which enables background scanning for bluetooth beacons
 * and displays a notification when beacons are found.
 *
 * @param enabled A boolean indicating whether to notify on nearby beacons.
 */
public void setPhysicalWebEnabled(boolean enabled) {
    mSharedPreferences.edit()
        .putInt(PREF_PHYSICAL_WEB, enabled ? PHYSICAL_WEB_ON : PHYSICAL_WEB_OFF)
        .apply();
    PhysicalWeb.updateScans();
}
 
Example #7
Source File: PhysicalWebPreferenceFragment.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void initLaunchButton() {
    ButtonPreference physicalWebLaunch =
            (ButtonPreference) findPreference(PREF_PHYSICAL_WEB_LAUNCH);

    physicalWebLaunch.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            PhysicalWebUma.onActivityReferral(PhysicalWebUma.PREFERENCE_REFERER);
            PhysicalWeb.showUrlList();
            return true;
        }
    });
}
 
Example #8
Source File: PrivacyPreferences.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PrivacyPreferencesManager privacyPrefManager = PrivacyPreferencesManager.getInstance();
    privacyPrefManager.migrateNetworkPredictionPreferences();
    addPreferencesFromResource(R.xml.privacy_preferences);
    getActivity().setTitle(R.string.prefs_privacy);
    setHasOptionsMenu(true);

    mManagedPreferenceDelegate = createManagedPreferenceDelegate();

    ChromeBaseCheckBoxPreference networkPredictionPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_NETWORK_PREDICTIONS);
    networkPredictionPref.setChecked(
            PrefServiceBridge.getInstance().getNetworkPredictionEnabled());
    networkPredictionPref.setOnPreferenceChangeListener(this);
    networkPredictionPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    // Display the correct settings fragment according to the user experiment group and to type
    // of the device, by removing not applicable preference fragments.
    CrashDumpUploadPreference uploadCrashDumpPref =
            (CrashDumpUploadPreference) findPreference(PREF_CRASH_DUMP_UPLOAD);
    ChromeBaseCheckBoxPreference uploadCrashDumpNoCellularPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_CRASH_DUMP_UPLOAD_NO_CELLULAR);

    PreferenceScreen preferenceScreen = getPreferenceScreen();
    if (privacyPrefManager.isCellularExperimentEnabled()) {
        preferenceScreen.removePreference(uploadCrashDumpNoCellularPref);
        preferenceScreen.removePreference(uploadCrashDumpPref);
    } else {
        preferenceScreen.removePreference(findPreference(PREF_USAGE_AND_CRASH_REPORTING));
        if (privacyPrefManager.isMobileNetworkCapable()) {
            preferenceScreen.removePreference(uploadCrashDumpNoCellularPref);
            uploadCrashDumpPref.setOnPreferenceChangeListener(this);
            uploadCrashDumpPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
        } else {
            preferenceScreen.removePreference(uploadCrashDumpPref);
            uploadCrashDumpNoCellularPref.setOnPreferenceChangeListener(this);
            uploadCrashDumpNoCellularPref.setManagedPreferenceDelegate(
                    mManagedPreferenceDelegate);
        }
    }

    ChromeBaseCheckBoxPreference navigationErrorPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_NAVIGATION_ERROR);
    navigationErrorPref.setOnPreferenceChangeListener(this);
    navigationErrorPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    ChromeBaseCheckBoxPreference searchSuggestionsPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_SEARCH_SUGGESTIONS);
    searchSuggestionsPref.setOnPreferenceChangeListener(this);
    searchSuggestionsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    if (!ContextualSearchFieldTrial.isEnabled()) {
        preferenceScreen.removePreference(findPreference(PREF_CONTEXTUAL_SEARCH));
    }

    ChromeBaseCheckBoxPreference safeBrowsingExtendedReportingPref =
            (ChromeBaseCheckBoxPreference) findPreference(
                    PREF_SAFE_BROWSING_EXTENDED_REPORTING);
    safeBrowsingExtendedReportingPref.setOnPreferenceChangeListener(this);
    safeBrowsingExtendedReportingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    ChromeBaseCheckBoxPreference safeBrowsingPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_SAFE_BROWSING);
    safeBrowsingPref.setOnPreferenceChangeListener(this);
    safeBrowsingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    if (!PhysicalWeb.featureIsEnabled()) {
        preferenceScreen.removePreference(findPreference(PREF_PHYSICAL_WEB));
    }

    updateSummaries();
}
 
Example #9
Source File: DeferredStartupHandler.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Handle application level deferred startup tasks that can be lazily done after all
 * the necessary initialization has been completed. Any calls requiring network access should
 * probably go here.
 *
 * Keep these tasks short and break up long tasks into multiple smaller tasks, as they run on
 * the UI thread and are blocking. Remember to follow RAIL guidelines, as much as possible, and
 * that most devices are quite slow, so leave enough buffer.
 */
@UiThread
public void initDeferredStartupForApp() {
    if (mDeferredStartupInitializedForApp) return;
    mDeferredStartupInitializedForApp = true;
    ThreadUtils.assertOnUiThread();

    RecordHistogram.recordLongTimesHistogram(
            "UMA.Debug.EnableCrashUpload.DeferredStartUptime2",
            SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
            TimeUnit.MILLISECONDS);

    mDeferredTasks.add(new Runnable() {
        @Override
        public void run() {
            // Punt all tasks that may block on disk off onto a background thread.
            initAsyncDiskTask();

            AfterStartupTaskUtils.setStartupComplete();

            PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Runnable() {
                @Override
                public void run() {
                    String homepageUrl = HomepageManager.getHomepageUri(mAppContext);
                    LaunchMetrics.recordHomePageLaunchMetrics(
                            HomepageManager.isHomepageEnabled(mAppContext),
                            NewTabPage.isNTPUrl(homepageUrl), homepageUrl);
                }
            });

            PartnerBookmarksShim.kickOffReading(mAppContext);

            PowerMonitor.create(mAppContext);

            ShareHelper.clearSharedImages();

            OfflinePageUtils.clearSharedOfflineFiles(mAppContext);
        }
    });

    mDeferredTasks.add(new Runnable() {
        @Override
        public void run() {
            // Clear any media notifications that existed when Chrome was last killed.
            MediaCaptureNotificationService.clearMediaNotifications(mAppContext);

            startModerateBindingManagementIfNeeded();

            recordKeyboardLocaleUma();
        }
    });

    mDeferredTasks.add(new Runnable() {
        @Override
        public void run() {
            // Start or stop Physical Web
            PhysicalWeb.onChromeStart();
        }
    });

    final ChromeApplication application = (ChromeApplication) mAppContext;

    mDeferredTasks.add(new Runnable() {
        @Override
        public void run() {
            // Starts syncing with GSA.
            application.createGsaHelper().startSync();
        }
    });

    ProcessInitializationHandler.getInstance().initializeDeferredStartupTasks();
}
 
Example #10
Source File: PrivacyPreferences.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PrivacyPreferencesManager privacyPrefManager = PrivacyPreferencesManager.getInstance();
    privacyPrefManager.migrateNetworkPredictionPreferences();
    addPreferencesFromResource(R.xml.privacy_preferences);
    getActivity().setTitle(R.string.prefs_privacy);
    setHasOptionsMenu(true);
    PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance();

    mManagedPreferenceDelegate = createManagedPreferenceDelegate();

    ChromeBaseCheckBoxPreference networkPredictionPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_NETWORK_PREDICTIONS);
    networkPredictionPref.setChecked(prefServiceBridge.getNetworkPredictionEnabled());
    networkPredictionPref.setOnPreferenceChangeListener(this);
    networkPredictionPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    ChromeBaseCheckBoxPreference navigationErrorPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_NAVIGATION_ERROR);
    navigationErrorPref.setOnPreferenceChangeListener(this);
    navigationErrorPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    ChromeBaseCheckBoxPreference searchSuggestionsPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_SEARCH_SUGGESTIONS);
    searchSuggestionsPref.setOnPreferenceChangeListener(this);
    searchSuggestionsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    PreferenceScreen preferenceScreen = getPreferenceScreen();
    if (!ContextualSearchFieldTrial.isEnabled()) {
        preferenceScreen.removePreference(findPreference(PREF_CONTEXTUAL_SEARCH));
    }

    // Listen to changes to both Extended Reporting prefs.
    ChromeBaseCheckBoxPreference legacyExtendedReportingPref =
            (ChromeBaseCheckBoxPreference) findPreference(
                PREF_SAFE_BROWSING_EXTENDED_REPORTING);
    legacyExtendedReportingPref.setOnPreferenceChangeListener(this);
    legacyExtendedReportingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    ChromeBaseCheckBoxPreference scoutReportingPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_SAFE_BROWSING_SCOUT_REPORTING);
    scoutReportingPref.setOnPreferenceChangeListener(this);
    scoutReportingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    // Remove the extended reporting preference that is NOT active.
    String extended_reporting_pref_to_remove =
            prefServiceBridge.isSafeBrowsingScoutReportingActive()
                ? PREF_SAFE_BROWSING_EXTENDED_REPORTING : PREF_SAFE_BROWSING_SCOUT_REPORTING;
    preferenceScreen.removePreference(findPreference(extended_reporting_pref_to_remove));

    ChromeBaseCheckBoxPreference safeBrowsingPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_SAFE_BROWSING);
    safeBrowsingPref.setOnPreferenceChangeListener(this);
    safeBrowsingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    if (!PhysicalWeb.featureIsEnabled()) {
        preferenceScreen.removePreference(findPreference(PREF_PHYSICAL_WEB));
    }

    updateSummaries();
}
 
Example #11
Source File: PrivacyPreferences.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PrivacyPreferencesManager privacyPrefManager = PrivacyPreferencesManager.getInstance();
    privacyPrefManager.migrateNetworkPredictionPreferences();
    PreferenceUtils.addPreferencesFromResource(this, R.xml.privacy_preferences);
    getActivity().setTitle(R.string.prefs_privacy);
    setHasOptionsMenu(true);
    PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance();

    mManagedPreferenceDelegate = createManagedPreferenceDelegate();

    ChromeBaseCheckBoxPreference networkPredictionPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_NETWORK_PREDICTIONS);
    networkPredictionPref.setChecked(prefServiceBridge.getNetworkPredictionEnabled());
    networkPredictionPref.setOnPreferenceChangeListener(this);
    networkPredictionPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    ChromeBaseCheckBoxPreference navigationErrorPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_NAVIGATION_ERROR);
    navigationErrorPref.setOnPreferenceChangeListener(this);
    navigationErrorPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    ChromeBaseCheckBoxPreference searchSuggestionsPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_SEARCH_SUGGESTIONS);
    searchSuggestionsPref.setOnPreferenceChangeListener(this);
    searchSuggestionsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONTENT_SUGGESTIONS_SETTINGS)) {
        searchSuggestionsPref.setTitle(R.string.search_site_suggestions_title);
        searchSuggestionsPref.setSummary(R.string.search_site_suggestions_summary);
    }

    PreferenceScreen preferenceScreen = getPreferenceScreen();
    if (!ContextualSearchFieldTrial.isEnabled()) {
        preferenceScreen.removePreference(findPreference(PREF_CONTEXTUAL_SEARCH));
    }

    // Listen to changes to both Extended Reporting prefs.
    ChromeBaseCheckBoxPreference legacyExtendedReportingPref =
            (ChromeBaseCheckBoxPreference) findPreference(
                PREF_SAFE_BROWSING_EXTENDED_REPORTING);
    legacyExtendedReportingPref.setOnPreferenceChangeListener(this);
    legacyExtendedReportingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    ChromeBaseCheckBoxPreference scoutReportingPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_SAFE_BROWSING_SCOUT_REPORTING);
    scoutReportingPref.setOnPreferenceChangeListener(this);
    scoutReportingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    // Remove the extended reporting preference that is NOT active.
    String extended_reporting_pref_to_remove =
            prefServiceBridge.isSafeBrowsingScoutReportingActive()
                ? PREF_SAFE_BROWSING_EXTENDED_REPORTING : PREF_SAFE_BROWSING_SCOUT_REPORTING;
    preferenceScreen.removePreference(findPreference(extended_reporting_pref_to_remove));

    ChromeBaseCheckBoxPreference safeBrowsingPref =
            (ChromeBaseCheckBoxPreference) findPreference(PREF_SAFE_BROWSING);
    safeBrowsingPref.setOnPreferenceChangeListener(this);
    safeBrowsingPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    if (!PhysicalWeb.featureIsEnabled()) {
        preferenceScreen.removePreference(findPreference(PREF_PHYSICAL_WEB));
    }

    if (ClearBrowsingDataTabsFragment.isFeatureEnabled()) {
        findPreference(PREF_CLEAR_BROWSING_DATA)
                .setFragment(ClearBrowsingDataTabsFragment.class.getName());
    }

    updateSummaries();
}