Java Code Examples for org.chromium.chrome.browser.partnercustomizations.HomepageManager

The following examples show how to use org.chromium.chrome.browser.partnercustomizations.HomepageManager. These examples are extracted from open source projects. 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 Project: delion   Source File: HomepagePreferences.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_title);
    addPreferencesFromResource(R.xml.homepage_preferences);

    mHomepageSwitch = (ChromeSwitchPreference) findPreference(PREF_HOMEPAGE_SWITCH);
    boolean isHomepageEnabled = mHomepageManager.getPrefHomepageEnabled();
    mHomepageSwitch.setChecked(isHomepageEnabled);
    mHomepageSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            mHomepageManager.setPrefHomepageEnabled((boolean) newValue);
            return true;
        }
    });

    mHomepageEdit = findPreference(PREF_HOMEPAGE_EDIT);
    updateCurrentHomepageUrl();
}
 
Example 2
Source Project: delion   Source File: HomepageEditor.java    License: 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 Project: AndroidChromium   Source File: HomepagePreferences.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_title);
    addPreferencesFromResource(R.xml.homepage_preferences);

    mHomepageSwitch = (ChromeSwitchPreference) findPreference(PREF_HOMEPAGE_SWITCH);
    boolean isHomepageEnabled = mHomepageManager.getPrefHomepageEnabled();
    mHomepageSwitch.setChecked(isHomepageEnabled);
    mHomepageSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            mHomepageManager.setPrefHomepageEnabled((boolean) newValue);
            return true;
        }
    });

    mHomepageEdit = findPreference(PREF_HOMEPAGE_EDIT);
    updateCurrentHomepageUrl();
}
 
Example 4
Source Project: AndroidChromium   Source File: HomepageEditor.java    License: 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 5
Source Project: 365browser   Source File: TabModelImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void closeAllTabs(boolean allowDelegation, boolean uponExit) {
    mTabSaver.cancelLoadingTabs(isIncognito());

    if (uponExit) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (allowDelegation && mModelDelegate.closeAllTabsRequest(isIncognito())) return;

    if (HomepageManager.isHomepageEnabled(ContextUtils.getApplicationContext())) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    closeAllTabs(true, false, true);
}
 
Example 6
Source Project: 365browser   Source File: HomepagePreferences.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_title);
    addPreferencesFromResource(R.xml.homepage_preferences);

    mHomepageSwitch = (ChromeSwitchPreference) findPreference(PREF_HOMEPAGE_SWITCH);
    boolean isHomepageEnabled = mHomepageManager.getPrefHomepageEnabled();
    mHomepageSwitch.setChecked(isHomepageEnabled);
    mHomepageSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            mHomepageManager.setPrefHomepageEnabled((boolean) newValue);
            return true;
        }
    });

    mHomepageEdit = findPreference(PREF_HOMEPAGE_EDIT);
    updateCurrentHomepageUrl();
}
 
Example 7
Source Project: 365browser   Source File: HomepageEditor.java    License: 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 8
Source Project: delion   Source File: StackLayout.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Called when a UI element is done animating the close tab effect started by
 * {@link #uiRequestingCloseTab(long, int)}.  This actually pushes the close event to the model.
 * @param time      The current time of the app in ms.
 * @param id        The id of the tab to close.
 * @param canUndo   Whether or not this close can be undone.
 * @param incognito Whether or not this was for the incognito stack or not.
 */
public void uiDoneClosingTab(long time, int id, boolean canUndo, boolean incognito) {
    // If homepage is enabled and there is a maximum of 1 tab in both models
    // (this is the last tab), the tab closure cannot be undone.
    canUndo &= !(HomepageManager.isHomepageEnabled(getContext())
                       && (mTabModelSelector.getModel(true).getCount()
                                          + mTabModelSelector.getModel(false).getCount()
                                  < 2));

    // Propagate the tab closure to the model.
    TabModelUtils.closeTabById(mTabModelSelector.getModel(incognito), id, canUndo);
}
 
Example 9
Source Project: delion   Source File: TabModelImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void closeAllTabs(boolean allowDelegation, boolean uponExit) {
    mTabSaver.cancelLoadingTabs(isIncognito());

    if (uponExit) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (allowDelegation && mModelDelegate.closeAllTabsRequest(isIncognito())) return;

    if (HomepageManager.isHomepageEnabled(ContextUtils.getApplicationContext())) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (getCount() == 1) {
        closeTab(getTabAt(0), true, false, true);
        return;
    }

    closeAllTabs(true, false, true);
}
 
Example 10
Source Project: delion   Source File: MainPreferences.java    License: Apache License 2.0 5 votes vote down vote up
private void updatePreferences() {
    if (getPreferenceScreen() != null) getPreferenceScreen().removeAll();
    addPreferencesFromResource(R.xml.main_preferences);

    ChromeBasePreference autofillPref =
            (ChromeBasePreference) findPreference(PREF_AUTOFILL_SETTINGS);
    setOnOffSummary(autofillPref, PersonalDataManager.isAutofillEnabled());
    autofillPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    ChromeBasePreference passwordsPref =
            (ChromeBasePreference) findPreference(PREF_SAVED_PASSWORDS);
    if (PasswordUIView.shouldUseSmartLockBranding()) {
        passwordsPref.setTitle(getResources().getString(
                R.string.prefs_smart_lock_for_passwords));
    }
    setOnOffSummary(passwordsPref,
            PrefServiceBridge.getInstance().isRememberPasswordsEnabled());
    passwordsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    Preference homepagePref = findPreference(PREF_HOMEPAGE);
    if (HomepageManager.shouldShowHomepageSetting()) {
        setOnOffSummary(homepagePref,
                HomepageManager.getInstance(getActivity()).getPrefHomepageEnabled());
    } else {
        getPreferenceScreen().removePreference(homepagePref);
    }

    ChromeBasePreference dataReduction =
            (ChromeBasePreference) findPreference(PREF_DATA_REDUCTION);
    if (DataReductionProxySettings.getInstance().isDataReductionProxyAllowed()) {
        dataReduction.setSummary(
                DataReductionPreferences.generateSummary(getResources()));
        dataReduction.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    } else {
        getPreferenceScreen().removePreference(dataReduction);
    }
}
 
Example 11
Source Project: delion   Source File: ToolbarManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void openHomepage() {
    Tab currentTab = mToolbarModel.getTab();
    if (currentTab == null) return;
    Context context = mToolbar.getContext();
    String homePageUrl = HomepageManager.getHomepageUri(context);
    if (TextUtils.isEmpty(homePageUrl)) {
        homePageUrl = UrlConstants.NTP_URL;
    }
    currentTab.loadUrl(new LoadUrlParams(homePageUrl, PageTransition.HOME_PAGE));
}
 
Example 12
Source Project: AndroidChromium   Source File: StackLayout.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Called when a UI element is done animating the close tab effect started by
 * {@link #uiRequestingCloseTab(long, int)}.  This actually pushes the close event to the model.
 * @param time      The current time of the app in ms.
 * @param id        The id of the tab to close.
 * @param canUndo   Whether or not this close can be undone.
 * @param incognito Whether or not this was for the incognito stack or not.
 */
public void uiDoneClosingTab(long time, int id, boolean canUndo, boolean incognito) {
    // If homepage is enabled and there is a maximum of 1 tab in both models
    // (this is the last tab), the tab closure cannot be undone.
    canUndo &= !(HomepageManager.isHomepageEnabled(getContext())
                       && (mTabModelSelector.getModel(true).getCount()
                                          + mTabModelSelector.getModel(false).getCount()
                                  < 2));

    // Propagate the tab closure to the model.
    TabModelUtils.closeTabById(mTabModelSelector.getModel(incognito), id, canUndo);
}
 
Example 13
Source Project: AndroidChromium   Source File: TabModelImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void closeAllTabs(boolean allowDelegation, boolean uponExit) {
    mTabSaver.cancelLoadingTabs(isIncognito());

    if (uponExit) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (allowDelegation && mModelDelegate.closeAllTabsRequest(isIncognito())) return;

    if (HomepageManager.isHomepageEnabled(ContextUtils.getApplicationContext())) {
        commitAllTabClosures();

        for (int i = 0; i < getCount(); i++) getTabAt(i).setClosing(true);
        while (getCount() > 0) TabModelUtils.closeTabByIndex(this, 0);
        return;
    }

    if (getCount() == 1) {
        closeTab(getTabAt(0), true, false, true);
        return;
    }

    closeAllTabs(true, false, true);
}
 
Example 14
Source Project: AndroidChromium   Source File: ToolbarPhone.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets up click and key listeners once we have native library available to handle clicks.
 */
@Override
public void onNativeLibraryReady() {
    super.onNativeLibraryReady();
    getLocationBar().onNativeLibraryReady();

    enableTabSwitchingResources();

    mHomeButton.setOnClickListener(this);

    mMenuButton.setOnKeyListener(new KeyboardNavigationListener() {
        @Override
        public View getNextFocusForward() {
            return getCurrentTabView();
        }

        @Override
        public View getNextFocusBackward() {
            return mToggleTabStackButton;
        }

        @Override
        protected boolean handleEnterKeyPress() {
            return getMenuButtonHelper().onEnterKeyPress(mMenuButton);
        }
    });
    onHomeButtonUpdate(HomepageManager.isHomepageEnabled(getContext()));

    updateVisualsForToolbarState();
}
 
Example 15
Source Project: AndroidChromium   Source File: ToolbarManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void openHomepage() {
    RecordUserAction.record("Home");

    Tab currentTab = mToolbarModel.getTab();
    if (currentTab == null) return;
    Context context = mToolbar.getContext();
    String homePageUrl = HomepageManager.getHomepageUri(context);
    if (TextUtils.isEmpty(homePageUrl)) {
        homePageUrl = UrlConstants.NTP_URL;
    }
    currentTab.loadUrl(new LoadUrlParams(homePageUrl, PageTransition.HOME_PAGE));
}
 
Example 16
Source Project: 365browser   Source File: ChromeTabbedActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create an initial tab for cold start without restored tabs.
 */
private void createInitialTab() {
    String url = HomepageManager.getHomepageUri(getApplicationContext());
    if (TextUtils.isEmpty(url) || NewTabPage.isNTPUrl(url)) {
        url = UrlConstants.NTP_URL;
    }

    getTabCreator(false).launchUrl(url, TabLaunchType.FROM_CHROME_UI);
}
 
Example 17
Source Project: 365browser   Source File: StackLayout.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Called when a UI element is done animating the close tab effect started by
 * {@link #uiRequestingCloseTab(long, int)}.  This actually pushes the close event to the model.
 * @param time      The current time of the app in ms.
 * @param id        The id of the tab to close.
 * @param canUndo   Whether or not this close can be undone.
 * @param incognito Whether or not this was for the incognito stack or not.
 */
public void uiDoneClosingTab(long time, int id, boolean canUndo, boolean incognito) {
    // If homepage is enabled and there is a maximum of 1 tab in both models
    // (this is the last tab), the tab closure cannot be undone.
    canUndo &= !(HomepageManager.isHomepageEnabled(getContext())
                       && (mTabModelSelector.getModel(true).getCount()
                                          + mTabModelSelector.getModel(false).getCount()
                                  < 2));

    // Propagate the tab closure to the model.
    TabModelUtils.closeTabById(mTabModelSelector.getModel(incognito), id, canUndo);
}
 
Example 18
Source Project: 365browser   Source File: ToolbarPhone.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets up click and key listeners once we have native library available to handle clicks.
 */
@Override
public void onNativeLibraryReady() {
    super.onNativeLibraryReady();
    getLocationBar().onNativeLibraryReady();

    enableTabSwitchingResources();

    mHomeButton.setOnClickListener(this);

    mMenuButton.setOnKeyListener(new KeyboardNavigationListener() {
        @Override
        public View getNextFocusForward() {
            return getCurrentTabView();
        }

        @Override
        public View getNextFocusBackward() {
            return mToggleTabStackButton;
        }

        @Override
        protected boolean handleEnterKeyPress() {
            return getMenuButtonHelper().onEnterKeyPress(mMenuButton);
        }
    });
    onHomeButtonUpdate(HomepageManager.isHomepageEnabled(getContext()));

    updateVisualsForToolbarState();
}
 
Example 19
Source Project: 365browser   Source File: ToolbarManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void openHomepage() {
    RecordUserAction.record("Home");

    Tab currentTab = mToolbarModel.getTab();
    if (currentTab == null) return;
    Context context = mToolbar.getContext();
    String homePageUrl = HomepageManager.getHomepageUri(context);
    if (TextUtils.isEmpty(homePageUrl)) {
        homePageUrl = UrlConstants.NTP_URL;
    }
    currentTab.loadUrl(new LoadUrlParams(homePageUrl, PageTransition.HOME_PAGE));
}
 
Example 20
Source Project: delion   Source File: ChromeTabbedActivity.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Create an initial tab for cold start without restored tabs.
 */
private void createInitialTab() {
    String url = HomepageManager.getHomepageUri(getApplicationContext());
    if (TextUtils.isEmpty(url)) url = UrlConstants.NTP_URL;
    getTabCreator(false).launchUrl(url, TabLaunchType.FROM_CHROME_UI);
}
 
Example 21
Source Project: delion   Source File: ToolbarPhone.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Sets up click and key listeners once we have native library available to handle clicks.
 */
@Override
public void onNativeLibraryReady() {
    super.onNativeLibraryReady();
    getLocationBar().onNativeLibraryReady();

    if (FeatureUtilities.isTabSwitchingEnabledInDocumentMode(getContext())) {
        // We might have hidden some buttons at onFinishInflate() because it was called
        // before native library is ready and chrome switch can be correctly read.
        // Now recover those buttons. Since we want to show toolbar even before native
        // library is ready, and as tab switching is experimental, this is unavoidable.
        unhideTabSwitchingResources();
        inflateTabSwitchingResources();
        enableTabSwitchingResources();
    } else if (FeatureUtilities.isDocumentMode(getContext())) {
        removeTabSwitchingResources();
    } else {  // non-document mode
        enableTabSwitchingResources();
    }

    mHomeButton.setOnClickListener(this);

    mMenuButton.setOnKeyListener(new KeyboardNavigationListener() {
        @Override
        public View getNextFocusForward() {
            return getCurrentTabView();
        }

        @Override
        public View getNextFocusBackward() {
            return mToggleTabStackButton;
        }

        @Override
        protected boolean handleEnterKeyPress() {
            return getMenuButtonHelper().onEnterKeyPress(mMenuButton);
        }
    });
    onHomeButtonUpdate(HomepageManager.isHomepageEnabled(getContext()));

    updateVisualsForToolbarState(mIsInTabSwitcherMode);
}
 
Example 22
Source Project: AndroidChromium   Source File: ChromeTabbedActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void initializeCompositor() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.initializeCompositor");
        super.initializeCompositor();

        mTabModelSelectorImpl.onNativeLibraryReady(getTabContentManager());
        mVrShellDelegate.onNativeLibraryReady();

        mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSelectorImpl) {
            @Override
            public void didCloseTab(int tabId, boolean incognito) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            @Override
            public void tabPendingClosure(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(true);
            }

            @Override
            public void tabRemoved(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            private void closeIfNoTabsAndHomepageEnabled(boolean isPendingClosure) {
                if (getTabModelSelector().getTotalTabCount() == 0) {
                    // If the last tab is closed, and homepage is enabled, then exit Chrome.
                    if (HomepageManager.isHomepageEnabled(getApplicationContext())) {
                        finish();
                    } else if (isPendingClosure) {
                        NewTabPageUma.recordNTPImpression(
                                NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
                    }
                }
            }

            @Override
            public void didAddTab(Tab tab, TabLaunchType type) {
                if (type == TabLaunchType.FROM_LONGPRESS_BACKGROUND
                        && !DeviceClassManager.enableAnimations(getApplicationContext())) {
                    Toast.makeText(ChromeTabbedActivity.this,
                            R.string.open_in_new_tab_toast,
                            Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void allTabsPendingClosure(List<Integer> tabIds) {
                NewTabPageUma.recordNTPImpression(
                        NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
            }
        };

        Bundle state = getSavedInstanceState();
        if (state != null && state.containsKey(FRE_RUNNING)) {
            mIsOnFirstRun = state.getBoolean(FRE_RUNNING);
        }
    } finally {
        TraceEvent.end("ChromeTabbedActivity.initializeCompositor");
    }
}
 
Example 23
Source Project: AndroidChromium   Source File: ChromeTabbedActivity.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Create an initial tab for cold start without restored tabs.
 */
private void createInitialTab() {
    String url = HomepageManager.getHomepageUri(getApplicationContext());
    if (TextUtils.isEmpty(url)) url = UrlConstants.NTP_URL;
    getTabCreator(false).launchUrl(url, TabLaunchType.FROM_CHROME_UI);
}
 
Example 24
Source Project: AndroidChromium   Source File: DeferredStartupHandler.java    License: 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 25
Source Project: AndroidChromium   Source File: MainPreferences.java    License: Apache License 2.0 4 votes vote down vote up
private void updatePreferences() {
    if (getPreferenceScreen() != null) getPreferenceScreen().removeAll();
    addPreferencesFromResource(R.xml.main_preferences);

    addBlimpPreferences();

    if (TemplateUrlService.getInstance().isLoaded()) {
        updateSummary();
    } else {
        TemplateUrlService.getInstance().registerLoadListener(this);
        TemplateUrlService.getInstance().load();
        ChromeBasePreference searchEnginePref =
                (ChromeBasePreference) findPreference(PREF_SEARCH_ENGINE);
        searchEnginePref.setEnabled(false);
    }

    ChromeBasePreference autofillPref =
            (ChromeBasePreference) findPreference(PREF_AUTOFILL_SETTINGS);
    setOnOffSummary(autofillPref, PersonalDataManager.isAutofillEnabled());
    autofillPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    ChromeBasePreference passwordsPref =
            (ChromeBasePreference) findPreference(PREF_SAVED_PASSWORDS);

    ProfileSyncService syncService = ProfileSyncService.get();

    if (AndroidSyncSettings.isSyncEnabled(getActivity().getApplicationContext())
              && syncService.isBackendInitialized()
              && !syncService.isUsingSecondaryPassphrase()
              && ChromeFeatureList.isEnabled(VIEW_PASSWORDS)) {
        passwordsPref.setKey(PREF_MANAGE_ACCOUNT_LINK);
        passwordsPref.setTitle(R.string.redirect_to_passwords_text);
        passwordsPref.setSummary(R.string.redirect_to_passwords_link);
        passwordsPref.setOnPreferenceClickListener(this);
        passwordsPref.setManagedPreferenceDelegate(null);
    } else {
        if (PasswordUIView.shouldUseSmartLockBranding()) {
            passwordsPref.setTitle(getResources().getString(
                     R.string.prefs_smart_lock_for_passwords));
        } else {
            passwordsPref.setTitle(getResources().getString(
                      R.string.prefs_saved_passwords));
        }
        passwordsPref.setFragment(SavePasswordsPreferences.class.getCanonicalName());
        setOnOffSummary(passwordsPref,
                PrefServiceBridge.getInstance().isRememberPasswordsEnabled());
        passwordsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    }

    Preference homepagePref = findPreference(PREF_HOMEPAGE);
    if (HomepageManager.shouldShowHomepageSetting()) {
        setOnOffSummary(homepagePref,
                HomepageManager.getInstance(getActivity()).getPrefHomepageEnabled());
    } else {
        getPreferenceScreen().removePreference(homepagePref);
    }

    ChromeBasePreference dataReduction =
            (ChromeBasePreference) findPreference(PREF_DATA_REDUCTION);
    if (DataReductionProxySettings.getInstance().isDataReductionProxyAllowed()) {
        dataReduction.setSummary(
                DataReductionPreferences.generateSummary(getResources()));
        dataReduction.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    } else {
        getPreferenceScreen().removePreference(dataReduction);
    }

    if (!SigninManager.get(getActivity()).isSigninSupported()) {
        getPreferenceScreen().removePreference(findPreference(PREF_SIGN_IN));
    }
}
 
Example 26
Source Project: 365browser   Source File: ChromeTabbedActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void initializeCompositor() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.initializeCompositor");
        super.initializeCompositor();

        mTabModelSelectorImpl.onNativeLibraryReady(getTabContentManager());

        mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSelectorImpl) {
            @Override
            public void didCloseTab(int tabId, boolean incognito) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            @Override
            public void tabPendingClosure(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(true);
            }

            @Override
            public void tabRemoved(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            private void closeIfNoTabsAndHomepageEnabled(boolean isPendingClosure) {
                if (getTabModelSelector().getTotalTabCount() == 0) {
                    // If the last tab is closed, and homepage is enabled, then exit Chrome.
                    if (HomepageManager.isHomepageEnabled(getApplicationContext())) {
                        finish();
                    } else if (isPendingClosure) {
                        NewTabPageUma.recordNTPImpression(
                                NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
                    }
                }
            }

            @Override
            public void didAddTab(Tab tab, TabLaunchType type) {
                if (type == TabLaunchType.FROM_LONGPRESS_BACKGROUND
                        && !DeviceClassManager.enableAnimations()) {
                    Toast.makeText(ChromeTabbedActivity.this,
                            R.string.open_in_new_tab_toast,
                            Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void allTabsPendingClosure(List<Tab> tabs) {
                NewTabPageUma.recordNTPImpression(
                        NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
            }
        };

        Bundle state = getSavedInstanceState();
        if (state != null && state.containsKey(FRE_RUNNING)) {
            mIsOnFirstRun = state.getBoolean(FRE_RUNNING);
        }
    } finally {
        TraceEvent.end("ChromeTabbedActivity.initializeCompositor");
    }
}
 
Example 27
Source Project: 365browser   Source File: MainPreferences.java    License: Apache License 2.0 4 votes vote down vote up
private void updatePreferences() {
    if (getPreferenceScreen() != null) getPreferenceScreen().removeAll();

    PreferenceUtils.addPreferencesFromResource(this, R.xml.main_preferences);

    if (TemplateUrlService.getInstance().isLoaded()) {
        updateSummary();
    } else {
        TemplateUrlService.getInstance().registerLoadListener(this);
        TemplateUrlService.getInstance().load();
        ChromeBasePreference searchEnginePref =
                (ChromeBasePreference) findPreference(PREF_SEARCH_ENGINE);
        searchEnginePref.setEnabled(false);
    }

    ChromeBasePreference autofillPref =
            (ChromeBasePreference) findPreference(PREF_AUTOFILL_SETTINGS);
    autofillPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    ChromeBasePreference passwordsPref =
            (ChromeBasePreference) findPreference(PREF_SAVED_PASSWORDS);

    ProfileSyncService syncService = ProfileSyncService.get();

    if (AndroidSyncSettings.isSyncEnabled(getActivity().getApplicationContext())
            && syncService.isEngineInitialized() && !syncService.isUsingSecondaryPassphrase()
            && ChromeFeatureList.isEnabled(VIEW_PASSWORDS)) {
        passwordsPref.setKey(PREF_MANAGE_ACCOUNT_LINK);
        passwordsPref.setTitle(R.string.redirect_to_passwords_text);
        passwordsPref.setSummary(R.string.redirect_to_passwords_link);
        passwordsPref.setOnPreferenceClickListener(this);
        passwordsPref.setManagedPreferenceDelegate(null);
    } else {
        passwordsPref.setTitle(getResources().getString(R.string.prefs_saved_passwords));
        passwordsPref.setFragment(SavePasswordsPreferences.class.getCanonicalName());
        setOnOffSummary(passwordsPref,
                PrefServiceBridge.getInstance().isRememberPasswordsEnabled());
        passwordsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate);
    }

    Preference homepagePref = findPreference(PREF_HOMEPAGE);
    if (HomepageManager.shouldShowHomepageSetting()) {
        setOnOffSummary(homepagePref,
                HomepageManager.getInstance(getActivity()).getPrefHomepageEnabled());
    } else {
        getPreferenceScreen().removePreference(homepagePref);
    }

    ChromeBasePreference dataReduction =
            (ChromeBasePreference) findPreference(PREF_DATA_REDUCTION);
    dataReduction.setSummary(DataReductionPreferences.generateSummary(getResources()));
    dataReduction.setManagedPreferenceDelegate(mManagedPreferenceDelegate);

    if (!SigninManager.get(getActivity()).isSigninSupported()) {
        getPreferenceScreen().removePreference(findPreference(PREF_SIGN_IN));
    }
}