org.chromium.policy.CombinedPolicyProvider Java Examples

The following examples show how to use org.chromium.policy.CombinedPolicyProvider. 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: ChromeBrowserInitializer.java    From delion with Apache License 2.0 6 votes vote down vote up
private void startChromeBrowserProcessesSync() throws ProcessInitException {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
        ThreadUtils.assertOnUiThread();
        mApplication.initCommandLine();
        LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER);
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
        libraryLoader.ensureInitialized(mApplication);
        StrictMode.setThreadPolicy(oldPolicy);
        libraryLoader.asyncPrefetchLibrariesToMemory();
        // The policies are used by browser startup, so we need to register the policy providers
        // before starting the browser process.
        mApplication.registerPolicyProviders(CombinedPolicyProvider.get());
        BrowserStartupController.get(mApplication, LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesSync(false);
        GoogleServicesManager.get(mApplication);
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
    }
}
 
Example #2
Source File: ChromeBrowserInitializer.java    From delion with Apache License 2.0 5 votes vote down vote up
private void startChromeBrowserProcessesAsync(
        boolean startGpuProcess,
        BrowserStartupController.StartupCallback callback) throws ProcessInitException {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcessesAsync");
        mApplication.registerPolicyProviders(CombinedPolicyProvider.get());
        BrowserStartupController.get(mApplication, LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesAsync(startGpuProcess, callback);
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcessesAsync");
    }
}
 
Example #3
Source File: ChromeApplication.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called after onForegroundSessionEnd() indicating that the activity whose onStop() ended the
 * last foreground session was destroyed.
 */
private void onForegroundActivityDestroyed() {
    if (ApplicationStatus.isEveryActivityDestroyed()) {
        mBackgroundProcessing.onDestroy();
        if (mDevToolsServer != null) {
            mDevToolsServer.destroy();
            mDevToolsServer = null;
        }
        stopApplicationActivityTracker();
        PartnerBrowserCustomizations.destroy();
        ShareHelper.clearSharedImages(this);
        CombinedPolicyProvider.get().destroy();
    }
}
 
Example #4
Source File: ChromeBrowserInitializer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void onStartNativeInitialization() {
    ThreadUtils.assertOnUiThread();
    if (mNativeInitializationComplete) return;
    // The policies are used by browser startup, so we need to register the policy providers
    // before starting the browser process.
    mApplication.registerPolicyProviders(CombinedPolicyProvider.get());

    SpeechRecognition.initialize(mApplication);
}
 
Example #5
Source File: ChromeBrowserInitializer.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void onStartNativeInitialization() {
    ThreadUtils.assertOnUiThread();
    if (mNativeInitializationComplete) return;
    // The policies are used by browser startup, so we need to register the policy providers
    // before starting the browser process.
    AppHooks.get().registerPolicyProviders(CombinedPolicyProvider.get());

    SpeechRecognition.initialize(mApplication);
}
 
Example #6
Source File: ChromeApplication.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Add a listener to be notified upon policy changes.
 */
public void addPolicyChangeListener(PolicyChangeListener listener) {
    CombinedPolicyProvider.get().addPolicyChangeListener(listener);
}
 
Example #7
Source File: ChromeApplication.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Remove a listener to be notified upon policy changes.
 */
public void removePolicyChangeListener(PolicyChangeListener listener) {
    CombinedPolicyProvider.get().removePolicyChangeListener(listener);
}
 
Example #8
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void postInflationStartup() {
    super.postInflationStartup();

    mSnackbarManager = new SnackbarManager(this);
    mDataUseSnackbarController = new DataUseSnackbarController(this, getSnackbarManager());

    mAssistStatusHandler = createAssistStatusHandler();
    if (mAssistStatusHandler != null) {
        if (mTabModelSelector != null) {
            mAssistStatusHandler.setTabModelSelector(mTabModelSelector);
        }
        mAssistStatusHandler.updateAssistState();
    }

    // If a user had ALLOW_LOW_END_DEVICE_UI explicitly set to false then we manually override
    // SysUtils.isLowEndDevice() with a switch so that they continue to see the normal UI. This
    // is only the case for grandfathered-in svelte users. We no longer do so for newer users.
    if (!ChromePreferenceManager.getInstance(this).getAllowLowEndDeviceUi()) {
        CommandLine.getInstance().appendSwitch(
                BaseSwitches.DISABLE_LOW_END_DEVICE_MODE);
    }

    AccessibilityManager manager = (AccessibilityManager)
            getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    manager.addAccessibilityStateChangeListener(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        mTouchExplorationStateChangeListener = new TouchExplorationStateChangeListener() {
            @Override
            public void onTouchExplorationStateChanged(boolean enabled) {
                checkAccessibility();
            }
        };
        manager.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
    }

    // Make the activity listen to policy change events
    CombinedPolicyProvider.get().addPolicyChangeListener(this);

    // Set up the animation placeholder to be the SurfaceView. This disables the
    // SurfaceView's 'hole' clipping during animations that are notified to the window.
    mWindowAndroid.setAnimationPlaceholderView(mCompositorViewHolder.getSurfaceView());

    // Inform the WindowAndroid of the keyboard accessory view.
    mWindowAndroid.setKeyboardAccessoryView((ViewGroup) findViewById(R.id.keyboard_accessory));
    initializeToolbar();
    initializeTabModels();
    if (!isFinishing() && getFullscreenManager() != null) {
        getFullscreenManager().initialize(
                (ControlContainer) findViewById(R.id.control_container),
                getTabModelSelector(),
                getControlContainerHeightResource());
    }
}
 
Example #9
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * This cannot be overridden in order to preserve destruction order.  Override
 * {@link #onDestroyInternal()} instead to perform clean up tasks.
 */
@SuppressLint("NewApi")
@Override
protected final void onDestroy() {
    if (mReaderModeManager != null) {
        mReaderModeManager.destroy();
        mReaderModeManager = null;
    }

    if (mContextualSearchManager != null) {
        mContextualSearchManager.destroy();
        mContextualSearchManager = null;
    }

    if (mTabModelSelectorTabObserver != null) {
        mTabModelSelectorTabObserver.destroy();
        mTabModelSelectorTabObserver = null;
    }

    if (mCompositorViewHolder != null) {
        if (mCompositorViewHolder.getLayoutManager() != null) {
            mCompositorViewHolder.getLayoutManager().removeSceneChangeObserver(this);
        }
        mCompositorViewHolder.shutDown();
        mCompositorViewHolder = null;
    }

    onDestroyInternal();

    if (mToolbarManager != null) {
        mToolbarManager.destroy();
        mToolbarManager = null;
    }

    if (mTabModelsInitialized) {
        TabModelSelector selector = getTabModelSelector();
        if (selector != null) selector.destroy();
    }

    if (mWindowAndroid != null) {
        mWindowAndroid.destroy();
        mWindowAndroid = null;
    }

    CombinedPolicyProvider.get().removePolicyChangeListener(this);

    if (mTabContentManager != null) {
        mTabContentManager.destroy();
        mTabContentManager = null;
    }

    AccessibilityManager manager = (AccessibilityManager)
            getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    manager.removeAccessibilityStateChangeListener(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        manager.removeTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
    }

    if (mBlimpClientContextDelegate != null) {
        mBlimpClientContextDelegate.destroy();
        mBlimpClientContextDelegate = null;
    }

    super.onDestroy();
}
 
Example #10
Source File: AppHooks.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public void registerPolicyProviders(CombinedPolicyProvider combinedProvider) {
    combinedProvider.registerProvider(
            new AppRestrictionsProvider(ContextUtils.getApplicationContext()));
}
 
Example #11
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void postInflationStartup() {
    super.postInflationStartup();

    mSnackbarManager = new SnackbarManager(this, null);
    mDataUseSnackbarController = new DataUseSnackbarController(this, getSnackbarManager());

    mAssistStatusHandler = createAssistStatusHandler();
    if (mAssistStatusHandler != null) {
        if (mTabModelSelector != null) {
            mAssistStatusHandler.setTabModelSelector(mTabModelSelector);
        }
        mAssistStatusHandler.updateAssistState();
    }

    // If a user had ALLOW_LOW_END_DEVICE_UI explicitly set to false then we manually override
    // SysUtils.isLowEndDevice() with a switch so that they continue to see the normal UI. This
    // is only the case for grandfathered-in svelte users. We no longer do so for newer users.
    if (!ChromePreferenceManager.getInstance().getAllowLowEndDeviceUi()) {
        CommandLine.getInstance().appendSwitch(
                BaseSwitches.DISABLE_LOW_END_DEVICE_MODE);
    }

    AccessibilityManager manager = (AccessibilityManager)
            getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    manager.addAccessibilityStateChangeListener(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        mTouchExplorationStateChangeListener = new TouchExplorationStateChangeListener() {
            @Override
            public void onTouchExplorationStateChanged(boolean enabled) {
                checkAccessibility();
            }
        };
        manager.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
    }

    // Make the activity listen to policy change events
    CombinedPolicyProvider.get().addPolicyChangeListener(this);
    mDidAddPolicyChangeListener = true;

    // Set up the animation placeholder to be the SurfaceView. This disables the
    // SurfaceView's 'hole' clipping during animations that are notified to the window.
    getWindowAndroid().setAnimationPlaceholderView(mCompositorViewHolder.getCompositorView());

    // Inform the WindowAndroid of the keyboard accessory view.
    getWindowAndroid().setKeyboardAccessoryView(
            (ViewGroup) findViewById(R.id.keyboard_accessory));
    initializeToolbar();
    initializeTabModels();
    if (!isFinishing() && getFullscreenManager() != null) {
        getFullscreenManager().initialize(
                (ControlContainer) findViewById(R.id.control_container),
                getTabModelSelector(),
                getControlContainerHeightResource());
    }

    if (mBottomSheet != null) {
        mBottomSheet.setTabModelSelector(mTabModelSelector);
        mBottomSheet.setFullscreenManager(mFullscreenManager);

        mFadingBackgroundView = (FadingBackgroundView) findViewById(R.id.fading_focus_target);
        mBottomSheet.addObserver(new EmptyBottomSheetObserver() {
            @Override
            public void onTransitionPeekToHalf(float transitionFraction) {
                mFadingBackgroundView.setViewAlpha(transitionFraction);
            }
        });
        mFadingBackgroundView.addObserver(mBottomSheet);

        mBottomSheetContentController =
                (BottomSheetContentController) ((ViewStub) findViewById(R.id.bottom_nav_stub))
                        .inflate();
        int controlContainerHeight =
                ((ControlContainer) findViewById(R.id.control_container)).getView().getHeight();
        mBottomSheetContentController.init(
                mBottomSheet, controlContainerHeight, mTabModelSelector, this);
    }
    ((BottomContainer) findViewById(R.id.bottom_container)).initialize(mFullscreenManager);
}
 
Example #12
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * This cannot be overridden in order to preserve destruction order.  Override
 * {@link #onDestroyInternal()} instead to perform clean up tasks.
 */
@SuppressLint("NewApi")
@Override
protected final void onDestroy() {
    if (mReaderModeManager != null) {
        mReaderModeManager.destroy();
        mReaderModeManager = null;
    }

    if (mContextualSearchManager != null) {
        mContextualSearchManager.destroy();
        mContextualSearchManager = null;
    }

    if (mTabModelSelectorTabObserver != null) {
        mTabModelSelectorTabObserver.destroy();
        mTabModelSelectorTabObserver = null;
    }

    if (mCompositorViewHolder != null) {
        if (mCompositorViewHolder.getLayoutManager() != null) {
            mCompositorViewHolder.getLayoutManager().removeSceneChangeObserver(this);
        }
        mCompositorViewHolder.shutDown();
        mCompositorViewHolder = null;
    }

    onDestroyInternal();

    if (mToolbarManager != null) {
        mToolbarManager.destroy();
        mToolbarManager = null;
    }

    if (mTabModelsInitialized) {
        TabModelSelector selector = getTabModelSelector();
        if (selector != null) selector.destroy();
    }

    if (mDidAddPolicyChangeListener) {
        CombinedPolicyProvider.get().removePolicyChangeListener(this);
        mDidAddPolicyChangeListener = false;
    }

    if (mTabContentManager != null) {
        mTabContentManager.destroy();
        mTabContentManager = null;
    }

    AccessibilityManager manager = (AccessibilityManager)
            getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    manager.removeAccessibilityStateChangeListener(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        manager.removeTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
    }

    super.onDestroy();
}
 
Example #13
Source File: ChromeApplication.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Registers various policy providers with the policy manager.
 * Providers are registered in increasing order of precedence so overrides should call this
 * method in the end for this method to maintain the highest precedence.
 * @param combinedProvider The {@link CombinedPolicyProvider} to register the providers with.
 */
public void registerPolicyProviders(CombinedPolicyProvider combinedProvider) {
    combinedProvider.registerProvider(new AppRestrictionsProvider(getApplicationContext()));
}
 
Example #14
Source File: ChromeApplication.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Registers various policy providers with the policy manager.
 * Providers are registered in increasing order of precedence so overrides should call this
 * method in the end for this method to maintain the highest precedence.
 * @param combinedProvider The {@link CombinedPolicyProvider} to register the providers with.
 */
public void registerPolicyProviders(CombinedPolicyProvider combinedProvider) {
    combinedProvider.registerProvider(new AppRestrictionsProvider(getApplicationContext()));
}