org.chromium.chrome.browser.ChromeSwitches Java Examples
The following examples show how to use
org.chromium.chrome.browser.ChromeSwitches.
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: InstantAppsHandler.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Cache whether the Instant Apps feature is enabled. * This should only be called with the native library loaded. */ public void cacheInstantAppsEnabled() { Context context = ContextUtils.getApplicationContext(); boolean isEnabled = false; boolean wasEnabled = isEnabled(context); CommandLine instance = CommandLine.getInstance(); if (instance.hasSwitch(ChromeSwitches.DISABLE_APP_LINK)) { isEnabled = false; } else if (instance.hasSwitch(ChromeSwitches.ENABLE_APP_LINK)) { isEnabled = true; } else { String experiment = FieldTrialList.findFullName(INSTANT_APPS_EXPERIMENT_NAME); if (INSTANT_APPS_DISABLED_ARM.equals(experiment)) { isEnabled = false; } else if (INSTANT_APPS_ENABLED_ARM.equals(experiment)) { isEnabled = true; } } if (isEnabled != wasEnabled) { ChromePreferenceManager.getInstance(context).setCachedInstantAppsEnabled(isEnabled); } }
Example #2
Source File: FeatureUtilities.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * @return Which flavor of Herb is being tested. * See {@link ChromeSwitches#HERB_FLAVOR_ELDERBERRY} and its related switches. */ public static String getHerbFlavor() { Context context = ContextUtils.getApplicationContext(); if (isHerbDisallowed(context)) return ChromeSwitches.HERB_FLAVOR_DISABLED; if (!sIsHerbFlavorCached) { sCachedHerbFlavor = null; // Allowing disk access for preferences while prototyping. StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); try { sCachedHerbFlavor = ChromePreferenceManager.getInstance(context).getCachedHerbFlavor(); } finally { StrictMode.setThreadPolicy(oldPolicy); } sIsHerbFlavorCached = true; Log.d(TAG, "Retrieved cached Herb flavor: " + sCachedHerbFlavor); } return sCachedHerbFlavor; }
Example #3
Source File: FeatureUtilities.java From delion with Apache License 2.0 | 6 votes |
/** * @return Which flavor of Herb is being tested. See {@link ChromeSwitches#HERB_FLAVOR_ANISE} * and its related switches. */ public static String getHerbFlavor() { Context context = ContextUtils.getApplicationContext(); if (isHerbDisallowed(context)) return ChromeSwitches.HERB_FLAVOR_DISABLED; if (!sIsHerbFlavorCached) { sCachedHerbFlavor = null; // Allowing disk access for preferences while prototyping. StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); try { sCachedHerbFlavor = ChromePreferenceManager.getInstance(context).getCachedHerbFlavor(); } finally { StrictMode.setThreadPolicy(oldPolicy); } sIsHerbFlavorCached = true; Log.d(TAG, "Retrieved cached Herb flavor: " + sCachedHerbFlavor); } return sCachedHerbFlavor; }
Example #4
Source File: UpdateMenuItemHelper.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * @param activity The current {@link ChromeActivity}. * @return Whether the update badge should be shown in the toolbar. */ public boolean shouldShowToolbarBadge(ChromeActivity activity) { if (getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_BADGE)) { return true; } // The badge is hidden if the update menu item has been clicked until there is an // even newer version of Chrome available. String latestVersionWhenClicked = PrefServiceBridge.getInstance().getLatestVersionWhenClickedUpdateMenuItem(); if (!getBooleanParam(ENABLE_UPDATE_BADGE) || TextUtils.equals(latestVersionWhenClicked, mLatestVersion)) { return false; } return updateAvailable(activity); }
Example #5
Source File: UpdateMenuItemHelper.java From delion with Apache License 2.0 | 6 votes |
/** * @param activity The current {@link ChromeActivity}. * @return Whether the update badge should be shown in the toolbar. */ public boolean shouldShowToolbarBadge(ChromeActivity activity) { if (getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_BADGE)) { return true; } // The badge is hidden if the update menu item has been clicked until there is an // even newer version of Chrome available. String latestVersionWhenClicked = PrefServiceBridge.getInstance().getLatestVersionWhenClickedUpdateMenuItem(); if (!getBooleanParam(ENABLE_UPDATE_BADGE) || TextUtils.equals(latestVersionWhenClicked, mLatestVersion)) { return false; } return updateAvailable(activity); }
Example #6
Source File: ChromeLauncherActivity.java From 365browser with Apache License 2.0 | 6 votes |
/** * @return Whether or not a Custom Tab will be forcefully used for the incoming Intent. */ private boolean isHerbIntent() { if (!canBeHijackedByHerb(getIntent())) return false; // Different Herb flavors handle incoming intents differently. String flavor = FeatureUtilities.getHerbFlavor(); if (TextUtils.isEmpty(flavor) || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, flavor)) { return false; } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) { return IntentUtils.safeGetBooleanExtra(getIntent(), ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true); } else { // Legacy Herb Flavors might hit this path before the caching logic corrects it, so // treat this as disabled. return false; } }
Example #7
Source File: FirstRunFlowSequencer.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Starts determining parameters for the First Run. * Once finished, calls onFlowIsKnown(). */ public void start() { if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) || ApiCompatibilityUtils.isDemoUser(mActivity)) { onFlowIsKnown(null); return; } if (!mLaunchProperties.getBoolean(FirstRunActivity.EXTRA_USE_FRE_FLOW_SEQUENCER)) { onFlowIsKnown(mLaunchProperties); return; } new AndroidEduAndChildAccountHelper() { @Override public void onParametersReady() { processFreEnvironment(isAndroidEduDevice(), hasChildAccount()); } }.start(mActivity.getApplicationContext()); }
Example #8
Source File: FirstRunFlowSequencer.java From delion with Apache License 2.0 | 6 votes |
/** * Starts determining parameters for the First Run. * Once finished, calls onFlowIsKnown(). */ public void start() { if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)) { onFlowIsKnown(null); return; } if (!mLaunchProperties.getBoolean(FirstRunActivity.USE_FRE_FLOW_SEQUENCER)) { onFlowIsKnown(mLaunchProperties); return; } new AndroidEduAndChildAccountHelper() { @Override public void onParametersReady() { processFreEnvironment(isAndroidEduDevice(), hasChildAccount()); } }.start(mActivity.getApplicationContext()); }
Example #9
Source File: ChromeLauncherActivity.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * @return Whether or not a Custom Tab will be forcefully used for the incoming Intent. */ private boolean isHerbIntent() { if (!canBeHijackedByHerb(getIntent())) return false; // Different Herb flavors handle incoming intents differently. String flavor = FeatureUtilities.getHerbFlavor(); if (TextUtils.isEmpty(flavor) || TextUtils.equals(ChromeSwitches.HERB_FLAVOR_DISABLED, flavor)) { return false; } else if (TextUtils.equals(flavor, ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) { return IntentUtils.safeGetBooleanExtra(getIntent(), ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, true); } else { // Legacy Herb Flavors might hit this path before the caching logic corrects it, so // treat this as disabled. return false; } }
Example #10
Source File: NotificationPlatformBridge.java From 365browser with Apache License 2.0 | 6 votes |
/** * Determines whether to use standard notification layouts, using NotificationCompat.Builder, * or custom layouts using Chrome's own templates. * * The --{enable,disable}-web-notification-custom-layouts command line flags take precedence. * * Normally a standard layout is used on Android N+, and a custom layout is used on older * versions of Android. But if the notification has a content image, there isn't enough room for * the Site Settings button to go on its own line when showing an image, nor is there enough * room for action button icons, so a standard layout will be used here even on old versions. * * @param hasImage Whether the notification has a content image. * @return Whether custom layouts should be used. */ @VisibleForTesting static boolean useCustomLayouts(boolean hasImage) { CommandLine commandLine = CommandLine.getInstance(); if (commandLine.hasSwitch(ChromeSwitches.ENABLE_WEB_NOTIFICATION_CUSTOM_LAYOUTS)) { return true; } if (commandLine.hasSwitch(ChromeSwitches.DISABLE_WEB_NOTIFICATION_CUSTOM_LAYOUTS)) { return false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { return false; } if (hasImage) { return false; } return true; }
Example #11
Source File: NotificationPlatformBridge.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Determines whether to use standard notification layouts, using NotificationCompat.Builder, * or custom layouts using Chrome's own templates. * * The --{enable,disable}-web-notification-custom-layouts command line flags take precedence. * * Normally a standard layout is used on Android N+, and a custom layout is used on older * versions of Android. But if the notification has a content image, there isn't enough room for * the Site Settings button to go on its own line when showing an image, nor is there enough * room for action button icons, so a standard layout will be used here even on old versions. * * @param hasImage Whether the notification has a content image. * @return Whether custom layouts should be used. */ @VisibleForTesting static boolean useCustomLayouts(boolean hasImage) { CommandLine commandLine = CommandLine.getInstance(); if (commandLine.hasSwitch(ChromeSwitches.ENABLE_WEB_NOTIFICATION_CUSTOM_LAYOUTS)) { return true; } if (commandLine.hasSwitch(ChromeSwitches.DISABLE_WEB_NOTIFICATION_CUSTOM_LAYOUTS)) { return false; } if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { return false; } if (hasImage) { return false; } return true; }
Example #12
Source File: TileGroupDelegateImpl.java From 365browser with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private boolean switchToExistingTab(String url) { String matchPattern = CommandLine.getInstance().getSwitchValue(ChromeSwitches.NTP_SWITCH_TO_EXISTING_TAB); boolean matchByHost; if ("url".equals(matchPattern)) { matchByHost = false; } else if ("host".equals(matchPattern)) { matchByHost = true; } else { return false; } TabModel tabModel = mTabModelSelector.getModel(false); for (int i = tabModel.getCount() - 1; i >= 0; --i) { if (matchURLs(tabModel.getTabAt(i).getUrl(), url, matchByHost)) { TabModelUtils.setIndex(tabModel, i); return true; } } return false; }
Example #13
Source File: ContextualSearchFieldTrial.java From 365browser with Apache License 2.0 | 6 votes |
private static boolean detectEnabled() { if (SysUtils.isLowEndDevice()) { return false; } // Allow this user-flippable flag to disable the feature. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_CONTEXTUAL_SEARCH)) { return false; } // Allow this user-flippable flag to enable the feature. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH)) { return true; } // Allow disabling the feature remotely. if (getBooleanParam(DISABLED_PARAM)) { return false; } return true; }
Example #14
Source File: NewTabPage.java From 365browser with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private boolean switchToExistingTab(String url) { String matchPattern = CommandLine.getInstance().getSwitchValue( ChromeSwitches.NTP_SWITCH_TO_EXISTING_TAB); boolean matchByHost; if ("url".equals(matchPattern)) { matchByHost = false; } else if ("host".equals(matchPattern)) { matchByHost = true; } else { return false; } TabModel tabModel = mTabModelSelector.getModel(false); for (int i = tabModel.getCount() - 1; i >= 0; --i) { if (matchURLs(tabModel.getTabAt(i).getUrl(), url, matchByHost)) { TabModelUtils.setIndex(tabModel, i); return true; } } return false; }
Example #15
Source File: ChromeBrowserInitializer.java From delion with Apache License 2.0 | 6 votes |
private void preInflationStartup() { ThreadUtils.assertOnUiThread(); if (mPreInflationStartupComplete) return; PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, mApplication); // Ensure critical files are available, so they aren't blocked on the file-system // behind long-running accesses in next phase. // Don't do any large file access here! ContentApplication.initCommandLine(mApplication); waitForDebuggerIfNeeded(); ChromeStrictMode.configureStrictMode(); if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK)) { ChromeWebApkHost.init(); } warmUpSharedPrefs(); DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication); ApplicationStatus.registerStateListenerForAllActivities( createActivityStateListener()); mPreInflationStartupComplete = true; }
Example #16
Source File: WebApkUpdateManager.java From 365browser with Apache License 2.0 | 6 votes |
/** * Returns whether the Web Manifest should be refetched to check whether it has been updated. * TODO: Make this method static once there is a static global clock class. * @param info Meta data from WebAPK's Android Manifest. * True if there has not been any update attempts. */ private boolean shouldCheckIfWebManifestUpdated(WebApkInfo info) { if (!sUpdatesEnabled) { return false; } if (CommandLine.getInstance().hasSwitch( ChromeSwitches.CHECK_FOR_WEB_MANIFEST_UPDATE_ON_STARTUP)) { return true; } if (!info.webApkPackageName().startsWith(WEBAPK_PACKAGE_PREFIX)) { return false; } if (isShellApkVersionOutOfDate(info) && WebApkVersion.CURRENT_SHELL_APK_VERSION > mStorage.getLastRequestedShellApkVersion()) { return true; } return mStorage.shouldCheckForUpdate(); }
Example #17
Source File: UpdateMenuItemHelper.java From 365browser with Apache License 2.0 | 6 votes |
/** * @param activity The current {@link ChromeActivity}. * @return Whether the update badge should be shown in the toolbar. */ public boolean shouldShowToolbarBadge(ChromeActivity activity) { if (getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_BADGE)) { return true; } // The badge is hidden if the update menu item has been clicked until there is an // even newer version of Chrome available. String latestVersionWhenClicked = PrefServiceBridge.getInstance().getLatestVersionWhenClickedUpdateMenuItem(); if (TextUtils.equals(latestVersionWhenClicked, mLatestVersion)) { return false; } return updateAvailable(activity); }
Example #18
Source File: FeatureUtilities.java From 365browser with Apache License 2.0 | 6 votes |
/** * @return Which flavor of Herb is being tested. * See {@link ChromeSwitches#HERB_FLAVOR_ELDERBERRY} and its related switches. */ public static String getHerbFlavor() { Context context = ContextUtils.getApplicationContext(); if (isHerbDisallowed(context)) return ChromeSwitches.HERB_FLAVOR_DISABLED; if (!sIsHerbFlavorCached) { sCachedHerbFlavor = null; // Allowing disk access for preferences while prototyping. StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); try { sCachedHerbFlavor = ChromePreferenceManager.getInstance().getCachedHerbFlavor(); } finally { StrictMode.setThreadPolicy(oldPolicy); } sIsHerbFlavorCached = true; Log.d(TAG, "Retrieved cached Herb flavor: " + sCachedHerbFlavor); } return sCachedHerbFlavor; }
Example #19
Source File: FirstRunFlowSequencer.java From 365browser with Apache License 2.0 | 6 votes |
/** * Starts determining parameters for the First Run. * Once finished, calls onFlowIsKnown(). */ public void start() { if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) || ApiCompatibilityUtils.isDemoUser(mActivity)) { onFlowIsKnown(null); return; } new AndroidEduAndChildAccountHelper() { @Override public void onParametersReady() { initializeSharedState(isAndroidEduDevice(), hasChildAccount()); processFreEnvironmentPreNative(); } }.start(mActivity.getApplicationContext()); }
Example #20
Source File: ContextualSearchFieldTrial.java From AndroidChromium with Apache License 2.0 | 6 votes |
private static boolean detectEnabled() { if (SysUtils.isLowEndDevice()) { return false; } // Allow this user-flippable flag to disable the feature. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_CONTEXTUAL_SEARCH)) { return false; } // Allow this user-flippable flag to enable the feature. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH)) { return true; } // Allow disabling the feature remotely. if (getBooleanParam(DISABLED_PARAM)) { return false; } return true; }
Example #21
Source File: UpdateMenuItemHelper.java From 365browser with Apache License 2.0 | 5 votes |
/** * @param activity The current {@link ChromeActivity}. * @return Whether the update menu item should be shown. */ public boolean shouldShowMenuItem(ChromeActivity activity) { if (getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_ITEM)) { return true; } return updateAvailable(activity); }
Example #22
Source File: UpdateMenuItemHelper.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return The {@link UpdateMenuItemHelper} instance. */ public static UpdateMenuItemHelper getInstance() { synchronized (UpdateMenuItemHelper.sGetInstanceLock) { if (sInstance == null) { sInstance = new UpdateMenuItemHelper(); String testMarketUrl = getStringParamValue(ChromeSwitches.MARKET_URL_FOR_TESTING); if (!TextUtils.isEmpty(testMarketUrl)) { sInstance.mUpdateUrl = testMarketUrl; } } return sInstance; } }
Example #23
Source File: FeatureUtilities.java From 365browser with Apache License 2.0 | 5 votes |
/** * Caches which flavor of Herb the user prefers from native. */ private static void cacheHerbFlavor() { Context context = ContextUtils.getApplicationContext(); if (isHerbDisallowed(context)) return; String oldFlavor = getHerbFlavor(); // Check the experiment value before the command line to put the user in the correct group. // The first clause does the null checks so so we can freely use the startsWith() function. String newFlavor = FieldTrialList.findFullName(HERB_EXPERIMENT_NAME); Log.d(TAG, "Experiment flavor: " + newFlavor); if (!TextUtils.isEmpty(newFlavor) && newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) { newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY; } else { newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED; } CommandLine instance = CommandLine.getInstance(); if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_DISABLED_SWITCH)) { newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED; } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_ELDERBERRY_SWITCH)) { newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY; } Log.d(TAG, "Caching flavor: " + newFlavor); sCachedHerbFlavor = newFlavor; if (!TextUtils.equals(oldFlavor, newFlavor)) { ChromePreferenceManager.getInstance().setCachedHerbFlavor(newFlavor); } }
Example #24
Source File: FirstRunFlowSequencer.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Checks if the First Run needs to be launched. * @return The intent to launch the First Run Experience if necessary, or null. * @param context The context. * @param fromIntent The intent that was used to launch Chrome. * @param forLightweightFre Whether this is a check for the Lightweight First Run Experience. */ public static Intent checkIfFirstRunIsNecessary( Context context, Intent fromIntent, boolean forLightweightFre) { // If FRE is disabled (e.g. in tests), proceed directly to the intent handling. if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE) || ApiCompatibilityUtils.isDemoUser(context)) { return null; } if (fromIntent != null && fromIntent.getBooleanExtra(SKIP_FIRST_RUN_EXPERIENCE, false)) { return null; } // If Chrome isn't opened via the Chrome icon, and the user accepted the ToS // in the Setup Wizard, skip any First Run Experience screens and proceed directly // to the intent handling. final boolean fromChromeIcon = fromIntent != null && TextUtils.equals(fromIntent.getAction(), Intent.ACTION_MAIN); if (!fromChromeIcon && ToSAckedReceiver.checkAnyUserHasSeenToS(context)) return null; final boolean baseFreComplete = FirstRunStatus.getFirstRunFlowComplete(); if (!baseFreComplete) { if (forLightweightFre && CommandLine.getInstance().hasSwitch( ChromeSwitches.ENABLE_LIGHTWEIGHT_FIRST_RUN_EXPERIENCE)) { if (!FirstRunStatus.shouldSkipWelcomePage() && !FirstRunStatus.getLightweightFirstRunFlowComplete()) { return createLightweightFirstRunIntent(context, fromChromeIcon); } } else { return createGenericFirstRunIntent(context, fromChromeIcon); } } // Promo pages are removed, so there is nothing else to show in FRE. return null; }
Example #25
Source File: ContextualSearchFieldTrial.java From AndroidChromium with Apache License 2.0 | 5 votes |
static boolean isContextualCardsBarIntegrationEnabled() { if (sIsContextualCardsBarIntegrationEnabled == null) { sIsContextualCardsBarIntegrationEnabled = getBooleanParam( ChromeSwitches.CONTEXTUAL_SEARCH_CONTEXTUAL_CARDS_BAR_INTEGRATION); } return sIsContextualCardsBarIntegrationEnabled; }
Example #26
Source File: UpdateMenuItemHelper.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @param activity The current {@link ChromeActivity}. * @return Whether the update menu item should be shown. */ public boolean shouldShowMenuItem(ChromeActivity activity) { if (getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_ITEM)) { return true; } if (!getBooleanParam(ENABLE_UPDATE_MENU_ITEM)) { return false; } return updateAvailable(activity); }
Example #27
Source File: WebApkUpdateManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Returns whether the Web Manifest should be refetched to check whether it has been updated. * TODO: Make this method static once there is a static global clock class. * @param storage WebappDataStorage with the WebAPK's cached data. * @param metaData Meta data from WebAPK's Android Manifest. * @param previousUpdateSucceeded Whether the previous update attempt succeeded. * True if there has not been any update attempts. */ private boolean shouldCheckIfWebManifestUpdated( WebappDataStorage storage, WebApkMetaData metaData, boolean previousUpdateSucceeded) { // Updating WebAPKs requires "installation from unknown sources" to be enabled. It is // confusing for a user to see a dialog asking them to enable "installation from unknown // sources" when they are in the middle of using the WebAPK (as opposed to after requesting // to add a WebAPK to the homescreen). if (!installingFromUnknownSourcesAllowed()) { return false; } if (CommandLine.getInstance().hasSwitch( ChromeSwitches.CHECK_FOR_WEB_MANIFEST_UPDATE_ON_STARTUP)) { return true; } if (isShellApkVersionOutOfDate(metaData)) return true; long now = currentTimeMillis(); long sinceLastCheckDurationMs = now - storage.getLastCheckForWebManifestUpdateTime(); if (sinceLastCheckDurationMs >= FULL_CHECK_UPDATE_INTERVAL) return true; long sinceLastUpdateRequestDurationMs = now - storage.getLastWebApkUpdateRequestCompletionTime(); return sinceLastUpdateRequestDurationMs >= RETRY_UPDATE_DURATION && !previousUpdateSucceeded; }
Example #28
Source File: ToolbarTablet.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onFinishInflate() { super.onFinishInflate(); mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar); mHomeButton = (TintedImageButton) findViewById(R.id.home_button); mBackButton = (TintedImageButton) findViewById(R.id.back_button); mForwardButton = (TintedImageButton) findViewById(R.id.forward_button); mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button); mShowTabStack = DeviceClassManager.isAccessibilityModeEnabled(getContext()) || CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK); mTabSwitcherButtonDrawable = TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false); mTabSwitcherButtonDrawableLight = TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true); mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button); mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable); updateSwitcherButtonVisibility(mShowTabStack); mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button); mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); mMenuButtonWrapper.setVisibility(View.VISIBLE); if (mAccessibilitySwitcherButton.getVisibility() == View.GONE && mMenuButtonWrapper.getVisibility() == View.GONE) { ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0, getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0); } mSaveOfflineButton = (TintedImageButton) findViewById(R.id.save_offline_button); // Initialize values needed for showing/hiding toolbar buttons when the activity size // changes. mShouldAnimateButtonVisibilityChange = false; mToolbarButtonsVisible = true; mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton}; }
Example #29
Source File: UpdateMenuItemHelper.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Checks if the {@link OmahaClient} knows about an update. * @param activity The current {@link ChromeActivity}. */ public void checkForUpdateOnBackgroundThread(final ChromeActivity activity) { if (!getBooleanParam(ENABLE_UPDATE_MENU_ITEM) && !getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_ITEM) && !getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_BADGE)) { return; } ThreadUtils.assertOnUiThread(); if (mAlreadyCheckedForUpdates) { if (activity.isActivityDestroyed()) return; activity.onCheckForUpdate(mUpdateAvailable); return; } mAlreadyCheckedForUpdates = true; new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { if (OmahaClient.isNewerVersionAvailable(activity)) { mUpdateUrl = OmahaClient.getMarketURL(activity); mLatestVersion = OmahaClient.getLatestVersionNumberString(activity); mUpdateAvailable = true; recordInternalStorageSize(); } else { mUpdateAvailable = false; } return null; } @Override protected void onPostExecute(Void result) { if (activity.isActivityDestroyed()) return; activity.onCheckForUpdate(mUpdateAvailable); recordUpdateHistogram(); } }.execute(); }
Example #30
Source File: UpdateMenuItemHelper.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @return The {@link UpdateMenuItemHelper} instance. */ public static UpdateMenuItemHelper getInstance() { synchronized (UpdateMenuItemHelper.sGetInstanceLock) { if (sInstance == null) { sInstance = new UpdateMenuItemHelper(); String testMarketUrl = getStringParamValue(ChromeSwitches.MARKET_URL_FOR_TESTING); if (!TextUtils.isEmpty(testMarketUrl)) { sInstance.mUpdateUrl = testMarketUrl; } } return sInstance; } }