org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomizations Java Examples

The following examples show how to use org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomizations. 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: ChromeActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void preInflationStartup() {
    super.preInflationStartup();

    // Force a partner customizations refresh if it has yet to be initialized.  This can happen
    // if Chrome is killed and you refocus a previous activity from Android recents, which does
    // not go through ChromeLauncherActivity that would have normally triggered this.
    mPartnerBrowserRefreshNeeded = !PartnerBrowserCustomizations.isInitialized();

    ApplicationInitialization.enableFullscreenFlags(
            getResources(), this, getControlContainerHeightResource());
    getWindow().setBackgroundDrawable(getBackgroundDrawable());

    mFullscreenManager = createFullscreenManager();
    mCreatedFullscreenManager = true;
}
 
Example #2
Source File: HomepageEditor.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_edit_title);
    View v = inflater.inflate(R.layout.homepage_editor, container, false);

    FloatLabelLayout homepageUrl = (FloatLabelLayout) v.findViewById(R.id.homepage_url);
    homepageUrl.focusWithoutAnimation();

    mHomepageUrlEdit = (EditText) v.findViewById(R.id.homepage_url_edit);
    mHomepageUrlEdit.setText((mHomepageManager.getPrefHomepageUseDefaultUri()
            ? PartnerBrowserCustomizations.getHomePageUrl()
            : mHomepageManager.getPrefHomepageCustomUri()));
    mHomepageUrlEdit.addTextChangedListener(this);

    initializeSaveCancelResetButtons(v);
    return v;
}
 
Example #3
Source File: HomepageEditor.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_edit_title);
    View v = inflater.inflate(R.layout.homepage_editor, container, false);

    FloatLabelLayout homepageUrl = (FloatLabelLayout) v.findViewById(R.id.homepage_url);
    homepageUrl.focusWithoutAnimation();

    mHomepageUrlEdit = (EditText) v.findViewById(R.id.homepage_url_edit);
    mHomepageUrlEdit.setText((mHomepageManager.getPrefHomepageUseDefaultUri()
            ? PartnerBrowserCustomizations.getHomePageUrl()
            : mHomepageManager.getPrefHomepageCustomUri()));
    mHomepageUrlEdit.addTextChangedListener(this);

    initializeSaveCancelResetButtons(v);
    return v;
}
 
Example #4
Source File: ChromeActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void preInflationStartup() {
    super.preInflationStartup();

    // Force a partner customizations refresh if it has yet to be initialized.  This can happen
    // if Chrome is killed and you refocus a previous activity from Android recents, which does
    // not go through ChromeLauncherActivity that would have normally triggered this.
    mPartnerBrowserRefreshNeeded = !PartnerBrowserCustomizations.isInitialized();

    ApplicationInitialization.enableFullscreenFlags(
            getResources(), this, getControlContainerHeightResource());
    getWindow().setBackgroundDrawable(getBackgroundDrawable());
    mWindowAndroid = ((ChromeApplication) getApplicationContext())
            .createActivityWindowAndroid(this);
    mWindowAndroid.restoreInstanceState(getSavedInstanceState());
}
 
Example #5
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void preInflationStartup() {
    super.preInflationStartup();

    // Force a partner customizations refresh if it has yet to be initialized.  This can happen
    // if Chrome is killed and you refocus a previous activity from Android recents, which does
    // not go through ChromeLauncherActivity that would have normally triggered this.
    mPartnerBrowserRefreshNeeded = !PartnerBrowserCustomizations.isInitialized();

    ApplicationInitialization.enableFullscreenFlags(
            getResources(), this, getControlContainerHeightResource());
    getWindow().setBackgroundDrawable(getBackgroundDrawable());
    mWindowAndroid = new ChromeWindow(this);
    mWindowAndroid.restoreInstanceState(getSavedInstanceState());

    mFullscreenManager = createFullscreenManager();
    mCreatedFullscreenManager = true;
}
 
Example #6
Source File: HomepageEditor.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_edit_title);
    View v = inflater.inflate(R.layout.homepage_editor, container, false);

    FloatLabelLayout homepageUrl = (FloatLabelLayout) v.findViewById(R.id.homepage_url);
    homepageUrl.focusWithoutAnimation();

    mHomepageUrlEdit = (EditText) v.findViewById(R.id.homepage_url_edit);
    mHomepageUrlEdit.setText((mHomepageManager.getPrefHomepageUseDefaultUri()
            ? PartnerBrowserCustomizations.getHomePageUrl()
            : mHomepageManager.getPrefHomepageCustomUri()));
    mHomepageUrlEdit.addTextChangedListener(this);

    initializeSaveCancelResetButtons(v);
    return v;
}
 
Example #7
Source File: ChromeActivitySessionTracker.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void onForegroundActivityDestroyed() {
    if (ApplicationStatus.isEveryActivityDestroyed()) {
        // These will all be re-initialized when a new Activity starts / upon next use.
        PartnerBrowserCustomizations.destroy();
        ShareHelper.clearSharedImages();
    }
}
 
Example #8
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart() {
    if (AsyncTabParamsManager.hasParamsWithTabToReparent()) {
        mCompositorViewHolder.prepareForTabReparenting();
    }
    super.onStart();
    if (mContextReporter != null) mContextReporter.enable();

    if (mPartnerBrowserRefreshNeeded) {
        mPartnerBrowserRefreshNeeded = false;
        PartnerBrowserCustomizations.initializeAsync(getApplicationContext(),
                PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS);
        PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Runnable() {
            @Override
            public void run() {
                if (PartnerBrowserCustomizations.isIncognitoDisabled()) {
                    terminateIncognitoSession();
                }
            }
        });
    }
    if (mCompositorViewHolder != null) mCompositorViewHolder.onStart();
    mSnackbarManager.onStart();

    // Explicitly call checkAccessibility() so things are initialized correctly when Chrome has
    // been re-started after closing due to the last tab being closed when homepage is enabled.
    // See crbug.com/541546.
    checkAccessibility();

    mUiMode = getResources().getConfiguration().uiMode;
    mScreenWidthDp = getResources().getConfiguration().screenWidthDp;
}
 
Example #9
Source File: ChromeActivitySessionTracker.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void onForegroundActivityDestroyed() {
    if (ApplicationStatus.isEveryActivityDestroyed()) {
        // These will all be re-initialized when a new Activity starts / upon next use.
        PartnerBrowserCustomizations.destroy();
        ShareHelper.clearSharedImages();
    }
}
 
Example #10
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart() {
    if (AsyncTabParamsManager.hasParamsWithTabToReparent()) {
        mCompositorViewHolder.prepareForTabReparenting();
    }
    super.onStart();
    if (mContextReporter != null) mContextReporter.enable();

    if (mPartnerBrowserRefreshNeeded) {
        mPartnerBrowserRefreshNeeded = false;
        PartnerBrowserCustomizations.initializeAsync(getApplicationContext(),
                PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS);
        PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Runnable() {
            @Override
            public void run() {
                if (PartnerBrowserCustomizations.isIncognitoDisabled()) {
                    terminateIncognitoSession();
                }
            }
        });
    }
    if (mCompositorViewHolder != null) mCompositorViewHolder.onStart();
    mSnackbarManager.onStart();

    // Explicitly call checkAccessibility() so things are initialized correctly when Chrome has
    // been re-started after closing due to the last tab being closed when homepage is enabled.
    // See crbug.com/541546.
    checkAccessibility();

    mScreenWidthDp = getResources().getConfiguration().screenWidthDp;
}
 
Example #11
Source File: ChromeActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart() {
    if (AsyncTabParamsManager.hasParamsWithTabToReparent()) {
        mCompositorViewHolder.prepareForTabReparenting();
    }
    super.onStart();
    if (mContextReporter != null) mContextReporter.enable();

    if (mPartnerBrowserRefreshNeeded) {
        mPartnerBrowserRefreshNeeded = false;
        PartnerBrowserCustomizations.initializeAsync(getApplicationContext(),
                PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS);
        PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Runnable() {
            @Override
            public void run() {
                if (PartnerBrowserCustomizations.isIncognitoDisabled()) {
                    terminateIncognitoSession();
                }
            }
        });
    }
    if (mCompositorViewHolder != null) mCompositorViewHolder.onStart();
    mSnackbarManager.onStart();

    // Explicitly call checkAccessibility() so things are initialized correctly when Chrome has
    // been re-started after closing due to the last tab being closed when homepage is enabled.
    // See crbug.com/541546.
    checkAccessibility();

    mScreenWidthDp = getResources().getConfiguration().screenWidthDp;
}
 
Example #12
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 #13
Source File: ChromeTabbedActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeState() {
    // This method goes through 3 steps:
    // 1. Load the saved tab state (but don't start restoring the tabs yet).
    // 2. Process the Intent that this activity received and if that should result in any
    //    new tabs, create them.  This is done after step 1 so that the new tab gets
    //    created after previous tab state was restored.
    // 3. If no tabs were created in any of the above steps, create an NTP, otherwise
    //    start asynchronous tab restore (loading the previously active tab synchronously
    //    if no new tabs created in step 2).

    // Only look at the original intent if this is not a "restoration" and we are allowed to
    // process intents. Any subsequent intents are carried through onNewIntent.
    try {
        TraceEvent.begin("ChromeTabbedActivity.initializeState");

        super.initializeState();

        Intent intent = getIntent();

        CipherFactory.getInstance().restoreFromBundle(getSavedInstanceState());

        boolean noRestoreState =
                CommandLine.getInstance().hasSwitch(ChromeSwitches.NO_RESTORE_STATE);
        if (noRestoreState) {
            // Clear the state files because they are inconsistent and useless from now on.
            mTabModelSelectorImpl.clearState();
        } else if (!mIsOnFirstRun) {
            // State should be clear when we start first run and hence we do not need to load
            // a previous state. This may change the current Model, watch out for initialization
            // based on the model.
            mTabModelSelectorImpl.loadState();
        }

        mIntentWithEffect = false;
        if ((mIsOnFirstRun || getSavedInstanceState() == null) && intent != null
                && !mIntentHandler.shouldIgnoreIntent(ChromeTabbedActivity.this, intent)) {
            mIntentWithEffect = mIntentHandler.onNewIntent(ChromeTabbedActivity.this, intent);
        }

        mCreatedTabOnStartup = getCurrentTabModel().getCount() > 0
                || mTabModelSelectorImpl.getRestoredTabCount() > 0
                || mIntentWithEffect;

        // We always need to try to restore tabs. The set of tabs might be empty, but at least
        // it will trigger the notification that tab restore is complete which is needed by
        // other parts of Chrome such as sync.
        boolean activeTabBeingRestored = !mIntentWithEffect;
        mTabModelSelectorImpl.restoreTabs(activeTabBeingRestored);

        // Only create an initial tab if no tabs were restored and no intent was handled.
        // Also, check whether the active tab was supposed to be restored and that the total
        // tab count is now non zero.  If this is not the case, tab restore failed and we need
        // to create a new tab as well.
        if (!mCreatedTabOnStartup
                || (activeTabBeingRestored && getTabModelSelector().getTotalTabCount() == 0)) {
            // If homepage URI is not determined, due to PartnerBrowserCustomizations provider
            // async reading, then create a tab at the async reading finished. If it takes
            // too long, just create NTP.
            PartnerBrowserCustomizations.setOnInitializeAsyncFinished(
                    new Runnable() {
                        @Override
                        public void run() {
                            createInitialTab();
                        }
                    }, INITIAL_TAB_CREATION_TIMEOUT_MS);
        }

        RecordHistogram.recordBooleanHistogram(
                "MobileStartup.ColdStartupIntent", mIntentWithEffect);
    } finally {
        TraceEvent.end("ChromeTabbedActivity.initializeState");
    }
}
 
Example #14
Source File: HomepagePreferences.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void updateCurrentHomepageUrl() {
    mHomepageEdit.setSummary((mHomepageManager.getPrefHomepageUseDefaultUri()
            ? PartnerBrowserCustomizations.getHomePageUrl()
            : mHomepageManager.getPrefHomepageCustomUri()));
}
 
Example #15
Source File: ChromeApplication.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether parental controls are enabled.  Returning true will disable
 *         incognito mode.
 */
@CalledByNative
protected boolean areParentalControlsEnabled() {
    return PartnerBrowserCustomizations.isIncognitoDisabled();
}
 
Example #16
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 #17
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeState() {
    // This method goes through 3 steps:
    // 1. Load the saved tab state (but don't start restoring the tabs yet).
    // 2. Process the Intent that this activity received and if that should result in any
    //    new tabs, create them.  This is done after step 1 so that the new tab gets
    //    created after previous tab state was restored.
    // 3. If no tabs were created in any of the above steps, create an NTP, otherwise
    //    start asynchronous tab restore (loading the previously active tab synchronously
    //    if no new tabs created in step 2).

    // Only look at the original intent if this is not a "restoration" and we are allowed to
    // process intents. Any subsequent intents are carried through onNewIntent.
    try {
        TraceEvent.begin("ChromeTabbedActivity.initializeState");

        super.initializeState();

        Intent intent = getIntent();

        boolean hadCipherData =
                CipherFactory.getInstance().restoreFromBundle(getSavedInstanceState());

        boolean noRestoreState =
                CommandLine.getInstance().hasSwitch(ChromeSwitches.NO_RESTORE_STATE);
        if (noRestoreState) {
            // Clear the state files because they are inconsistent and useless from now on.
            mTabModelSelectorImpl.clearState();
        } else if (!mIsOnFirstRun) {
            // State should be clear when we start first run and hence we do not need to load
            // a previous state. This may change the current Model, watch out for initialization
            // based on the model.
            // Never attempt to restore incognito tabs when this activity was previously swiped
            // away in Recents. http://crbug.com/626629
            boolean ignoreIncognitoFiles = !hadCipherData;
            mTabModelSelectorImpl.loadState(ignoreIncognitoFiles);
        }

        mIntentWithEffect = false;
        if ((mIsOnFirstRun || getSavedInstanceState() == null) && intent != null) {
            if (mVrShellDelegate.isVrIntent(intent)) {
                // TODO(mthiesse): Improve startup when started from a VR intent. Right now
                // we launch out of VR, partially load out of VR, then switch into VR.
                mVrShellDelegate.enterVRIfNecessary();
            } else if (!mIntentHandler.shouldIgnoreIntent(ChromeTabbedActivity.this, intent)) {
                mIntentWithEffect = mIntentHandler.onNewIntent(ChromeTabbedActivity.this,
                        intent);
            }
        }

        mCreatedTabOnStartup = getCurrentTabModel().getCount() > 0
                || mTabModelSelectorImpl.getRestoredTabCount() > 0
                || mIntentWithEffect;

        // We always need to try to restore tabs. The set of tabs might be empty, but at least
        // it will trigger the notification that tab restore is complete which is needed by
        // other parts of Chrome such as sync.
        boolean activeTabBeingRestored = !mIntentWithEffect;
        mTabModelSelectorImpl.restoreTabs(activeTabBeingRestored);

        // Only create an initial tab if no tabs were restored and no intent was handled.
        // Also, check whether the active tab was supposed to be restored and that the total
        // tab count is now non zero.  If this is not the case, tab restore failed and we need
        // to create a new tab as well.
        if (!mCreatedTabOnStartup
                || (activeTabBeingRestored && getTabModelSelector().getTotalTabCount() == 0)) {
            // If homepage URI is not determined, due to PartnerBrowserCustomizations provider
            // async reading, then create a tab at the async reading finished. If it takes
            // too long, just create NTP.
            PartnerBrowserCustomizations.setOnInitializeAsyncFinished(
                    new Runnable() {
                        @Override
                        public void run() {
                            createInitialTab();
                        }
                    }, INITIAL_TAB_CREATION_TIMEOUT_MS);
        }

        RecordHistogram.recordBooleanHistogram(
                "MobileStartup.ColdStartupIntent", mIntentWithEffect);
    } finally {
        TraceEvent.end("ChromeTabbedActivity.initializeState");
    }
}
 
Example #18
Source File: HomepagePreferences.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private void updateCurrentHomepageUrl() {
    mHomepageEdit.setSummary((mHomepageManager.getPrefHomepageUseDefaultUri()
            ? PartnerBrowserCustomizations.getHomePageUrl()
            : mHomepageManager.getPrefHomepageCustomUri()));
}
 
Example #19
Source File: HomepagePreferences.java    From delion with Apache License 2.0 4 votes vote down vote up
private void updateCurrentHomepageUrl() {
    mHomepageEdit.setSummary((mHomepageManager.getPrefHomepageUseDefaultUri()
            ? PartnerBrowserCustomizations.getHomePageUrl()
            : mHomepageManager.getPrefHomepageCustomUri()));
}
 
Example #20
Source File: ChromeApplication.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether parental controls are enabled.  Returning true will disable
 *         incognito mode.
 */
@CalledByNative
protected boolean areParentalControlsEnabled() {
    return PartnerBrowserCustomizations.isIncognitoDisabled();
}