org.chromium.chrome.browser.ChromeActivity Java Examples
The following examples show how to use
org.chromium.chrome.browser.ChromeActivity.
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: AppMenuIconRowFooter.java From 365browser with Apache License 2.0 | 6 votes |
/** * Initializes the icons, setting enabled state, drawables, and content descriptions. * @param activity The {@link ChromeActivity} displaying the menu. * @param appMenu The {@link AppMenu} that contains the icon row. * @param bookmarkBridge The {@link BookmarkBridge} used to retrieve information about * bookmarks. */ public void initialize( ChromeActivity activity, AppMenu appMenu, BookmarkBridge bookmarkBridge) { mActivity = activity; mAppMenu = appMenu; Tab currentTab = mActivity.getActivityTab(); mForwardButton.setEnabled(currentTab.canGoForward()); updateBookmarkMenuItem(bookmarkBridge, currentTab); mDownloadButton.setEnabled(DownloadUtils.isAllowedToDownloadPage(currentTab)); mReloadButton.setImageResource(R.drawable.btn_reload_stop); loadingStateChanged(currentTab.isLoading()); }
Example #2
Source File: AutofillPopupBridge.java From 365browser with Apache License 2.0 | 6 votes |
public AutofillPopupBridge(View anchorView, long nativeAutofillPopupViewAndroid, WindowAndroid windowAndroid) { mNativeAutofillPopup = nativeAutofillPopupViewAndroid; Activity activity = windowAndroid.getActivity().get(); if (activity == null) { mAutofillPopup = null; mContext = null; // Clean up the native counterpart. This is posted to allow the native counterpart // to fully finish the construction of this glue object before we attempt to delete it. new Handler().post(new Runnable() { @Override public void run() { dismissed(); } }); } else { mAutofillPopup = new AutofillPopup(activity, anchorView, this); mContext = activity; mBrowserAccessibilityManager = ((ChromeActivity) activity) .getCurrentContentViewCore() .getBrowserAccessibilityManager(); } }
Example #3
Source File: VrShellDelegate.java From 365browser with Apache License 2.0 | 6 votes |
private VrShellDelegate(ChromeActivity activity, VrClassesWrapper wrapper) { mActivity = activity; mVrClassesWrapper = wrapper; // If an activity isn't resumed at the point, it must have been paused. mPaused = ApplicationStatus.getStateForActivity(activity) != ActivityState.RESUMED; updateVrSupportLevel(); mNativeVrShellDelegate = nativeInit(); mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency(); mEnterVrHandler = new Handler(); Choreographer.getInstance().postFrameCallback(new FrameCallback() { @Override public void doFrame(long frameTimeNanos) { if (mNativeVrShellDelegate == 0) return; Display display = ((WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); nativeUpdateVSyncInterval( mNativeVrShellDelegate, frameTimeNanos, 1.0d / display.getRefreshRate()); } }); ApplicationStatus.registerStateListenerForAllActivities(this); }
Example #4
Source File: UpdateMenuItemHelper.java From delion with Apache License 2.0 | 6 votes |
/** * Handles a click on the update menu item. * @param activity The current {@link ChromeActivity}. */ public void onMenuItemClicked(ChromeActivity activity) { if (mUpdateUrl == null) return; // If the update menu item is showing because it was forced on through about://flags // then mLatestVersion may be null. if (mLatestVersion != null) { PrefServiceBridge.getInstance().setLatestVersionWhenClickedUpdateMenuItem( mLatestVersion); } // Fire an intent to open the URL. try { Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(mUpdateUrl)); activity.startActivity(launchIntent); recordItemClickedHistogram(ITEM_CLICKED_INTENT_LAUNCHED); PrefServiceBridge.getInstance().setClickedUpdateMenuItem(true); } catch (ActivityNotFoundException e) { Log.e(TAG, "Failed to launch Activity for: %s", mUpdateUrl); recordItemClickedHistogram(ITEM_CLICKED_INTENT_FAILED); } }
Example #5
Source File: NewTabPageUma.java From 365browser with Apache License 2.0 | 6 votes |
/** * Records how much time elapsed from start until the search box became available to the user. */ public static void recordSearchAvailableLoadTime(ChromeActivity activity) { // Log the time it took for the search box to be displayed at startup, based on the // timestamp on the intent for the activity. If the user has interacted with the // activity already, it's not a startup, and the timestamp on the activity would not be // relevant either. if (activity.getLastUserInteractionTime() != 0) return; long timeFromIntent = SystemClock.elapsedRealtime() - IntentHandler.getTimestampFromIntent(activity.getIntent()); if (activity.hadWarmStart()) { RecordHistogram.recordMediumTimesHistogram( "NewTabPage.SearchAvailableLoadTime2.WarmStart", timeFromIntent, TimeUnit.MILLISECONDS); } else { RecordHistogram.recordMediumTimesHistogram( "NewTabPage.SearchAvailableLoadTime2.ColdStart", timeFromIntent, TimeUnit.MILLISECONDS); } }
Example #6
Source File: ScreenshotTask.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Prepares screenshot (possibly asynchronously) and invokes the callback when the screenshot * is available, or collection has failed. The asynchronous path is only taken when the activity * that is passed in is a {@link ChromeActivity}. * The callback is always invoked asynchronously. */ public static void create(Activity activity, final ScreenshotTaskCallback callback) { if (activity instanceof ChromeActivity) { Rect rect = new Rect(); activity.getWindow().getDecorView().getRootView().getWindowVisibleDisplayFrame(rect); createCompositorScreenshot(((ChromeActivity) activity).getWindowAndroid(), rect, callback); return; } final Bitmap bitmap = prepareScreenshot(activity, null); ThreadUtils.postOnUiThread(new Runnable() { @Override public void run() { callback.onGotBitmap(bitmap); } }); }
Example #7
Source File: ShareActivity.java From 365browser with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { Intent intent = getIntent(); if (intent == null) return; if (!Intent.ACTION_SEND.equals(intent.getAction())) return; if (!IntentUtils.safeHasExtra(intent, ShareHelper.EXTRA_TASK_ID)) return; ChromeActivity triggeringActivity = getTriggeringActivity(); if (triggeringActivity == null) return; handleShareAction(triggeringActivity); } finally { finish(); } }
Example #8
Source File: NewTabPageUma.java From 365browser with Apache License 2.0 | 6 votes |
/** * Records the type of load for the NTP, such as cold or warm start. */ public static void recordLoadType(ChromeActivity activity) { if (activity.getLastUserInteractionTime() > 0) { RecordHistogram.recordEnumeratedHistogram( "NewTabPage.LoadType", LOAD_TYPE_OTHER, LOAD_TYPE_COUNT); return; } if (activity.hadWarmStart()) { RecordHistogram.recordEnumeratedHistogram( "NewTabPage.LoadType", LOAD_TYPE_WARM_START, LOAD_TYPE_COUNT); return; } RecordHistogram.recordEnumeratedHistogram( "NewTabPage.LoadType", LOAD_TYPE_COLD_START, LOAD_TYPE_COUNT); }
Example #9
Source File: HistorySheetContent.java From 365browser with Apache License 2.0 | 5 votes |
/** * @param activity The activity displaying the history manager UI. * @param snackbarManager The {@link SnackbarManager} used to display snackbars. */ public HistorySheetContent(final ChromeActivity activity, SnackbarManager snackbarManager) { mHistoryManager = new HistoryManager(activity, false, snackbarManager); mContentView = mHistoryManager.getView(); mToolbarView = mHistoryManager.detachToolbarView(); mToolbarView.addObserver(new SelectableListToolbar.SelectableListToolbarObserver() { @Override public void onThemeColorChanged(boolean isLightTheme) { activity.getBottomSheet().updateHandleTint(); } }); ((BottomToolbarPhone) activity.getToolbarManager().getToolbar()) .setOtherToolbarStyle(mToolbarView); }
Example #10
Source File: UpdateMenuItemHelper.java From 365browser with Apache License 2.0 | 5 votes |
private boolean updateAvailable(ChromeActivity activity) { if (!mAlreadyCheckedForUpdates) { checkForUpdateOnBackgroundThread(activity); return false; } return mUpdateAvailable; }
Example #11
Source File: Tab.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return {@link ChromeActivity} that currently contains this {@link Tab} in its * {@link TabModel}. */ public ChromeActivity getActivity() { if (getWindowAndroid() == null) return null; Activity activity = WindowAndroid.activityFromContext( getWindowAndroid().getContext().get()); if (activity instanceof ChromeActivity) return (ChromeActivity) activity; return null; }
Example #12
Source File: ReaderModeManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
public ReaderModeManager(TabModelSelector selector, ChromeActivity activity) { super(selector); mTabId = Tab.INVALID_TAB_ID; mTabModelSelector = selector; mChromeActivity = activity; mTabStatusMap = new HashMap<>(); mIsReaderHeuristicAlwaysTrue = isDistillerHeuristicAlwaysTrue(); }
Example #13
Source File: Tab.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Creates a new tab to be loaded lazily. This can be used for tabs opened in the background * that should be loaded when switched to. initialize() needs to be called afterwards to * complete the second level initialization. */ public static Tab createTabForLazyLoad(ChromeActivity activity, boolean incognito, WindowAndroid nativeWindow, TabLaunchType type, int parentId, LoadUrlParams loadUrlParams) { Tab tab = new Tab( INVALID_TAB_ID, parentId, incognito, activity, nativeWindow, type, TabCreationState.FROZEN_FOR_LAZY_LOAD, null); tab.setPendingLoadParams(loadUrlParams); return tab; }
Example #14
Source File: Tab.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Creates a fresh tab. initialize() needs to be called afterwards to complete the second level * initialization. * @param initiallyHidden true iff the tab being created is initially in background */ public static Tab createLiveTab(int id, ChromeActivity activity, boolean incognito, WindowAndroid nativeWindow, TabLaunchType type, int parentId, boolean initiallyHidden) { return new Tab(id, parentId, incognito, activity, nativeWindow, type, initiallyHidden ? TabCreationState.LIVE_IN_BACKGROUND : TabCreationState.LIVE_IN_FOREGROUND, null); }
Example #15
Source File: ActivityDelegate.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @return Running Activity that owns the given Tab, null if the Activity couldn't be found. */ public static Activity getActivityForTabId(int id) { if (id == Tab.INVALID_TAB_ID) return null; for (WeakReference<Activity> ref : ApplicationStatus.getRunningActivities()) { if (!(ref.get() instanceof ChromeActivity)) continue; ChromeActivity activity = (ChromeActivity) ref.get(); if (activity == null) continue; if (activity.getTabModelSelector().getTabById(id) != null) return activity; } return null; }
Example #16
Source File: CustomTabAppMenuPropertiesDelegate.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Creates an {@link CustomTabAppMenuPropertiesDelegate} instance. */ public CustomTabAppMenuPropertiesDelegate(final ChromeActivity activity, List<String> menuEntries, boolean showShare, final boolean isOpenedByChrome, final boolean isMediaViewer) { super(activity); mMenuEntries = menuEntries; mShowShare = showShare; mIsMediaViewer = isMediaViewer; mDefaultBrowserFetcher = new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... params) { String packageLabel = null; if (isOpenedByChrome) { // If the Custom Tab was created by Chrome, Chrome should open it. packageLabel = BuildInfo.getPackageLabel(activity); } else { // Check if there is a default handler for the Intent. If so, grab its label. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(SAMPLE_URL)); PackageManager pm = activity.getPackageManager(); ResolveInfo info = pm.resolveActivity(intent, 0); if (info != null && info.match != 0) { packageLabel = info.loadLabel(pm).toString(); } } return packageLabel == null ? activity.getString(R.string.menu_open_in_product_default) : activity.getString(R.string.menu_open_in_product, packageLabel); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
Example #17
Source File: UpdateMenuItemHelper.java From 365browser 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) { 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 (VersionNumberGetter.isNewerVersionAvailable(activity)) { mUpdateUrl = MarketURLGetter.getMarketUrl(activity); mLatestVersion = VersionNumberGetter.getInstance().getLatestKnownVersion(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 #18
Source File: ContextualSearchTabHelper.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return the Contextual Search manager. */ private ContextualSearchManager getContextualSearchManager() { Activity activity = mTab.getWindowAndroid().getActivity().get(); if (activity instanceof ChromeActivity) { return ((ChromeActivity) activity).getContextualSearchManager(); } return null; }
Example #19
Source File: Tab.java From delion with Apache License 2.0 | 5 votes |
@Override public int getSystemWindowInsetTop() { ChromeActivity activity = getActivity(); if (activity != null) { return activity.getInsetObserverView().getSystemWindowInsetsTop(); } return 0; }
Example #20
Source File: SnackbarView.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @return The parent {@link ViewGroup} that {@link #mView} will be added to. */ private ViewGroup findParentView(Activity activity) { if (activity instanceof ChromeActivity) { return ((ChromeActivity) activity).getCompositorViewHolder(); } else { return (ViewGroup) activity.findViewById(android.R.id.content); } }
Example #21
Source File: CustomTabAppMenuPropertiesDelegate.java From 365browser with Apache License 2.0 | 5 votes |
/** * Creates an {@link CustomTabAppMenuPropertiesDelegate} instance. */ public CustomTabAppMenuPropertiesDelegate(final ChromeActivity activity, List<String> menuEntries, boolean showShare, final boolean isOpenedByChrome, final boolean isMediaViewer, boolean showStar, boolean showDownload) { super(activity); mMenuEntries = menuEntries; mShowShare = showShare; mIsMediaViewer = isMediaViewer; mShowStar = showStar; mShowDownload = showDownload; mIsOpenedByChrome = isOpenedByChrome; }
Example #22
Source File: Tab.java From 365browser with Apache License 2.0 | 5 votes |
/** * Creates a fresh tab. initialize() needs to be called afterwards to complete the second level * initialization. * @param initiallyHidden true iff the tab being created is initially in background */ public static Tab createLiveTab(int id, ChromeActivity activity, boolean incognito, WindowAndroid nativeWindow, TabLaunchType type, int parentId, boolean initiallyHidden) { return new Tab(id, parentId, incognito, activity, nativeWindow, type, initiallyHidden ? TabCreationState.LIVE_IN_BACKGROUND : TabCreationState.LIVE_IN_FOREGROUND, null); }
Example #23
Source File: Tab.java From delion with Apache License 2.0 | 5 votes |
/** * Creates a new tab to be loaded lazily. This can be used for tabs opened in the background * that should be loaded when switched to. initialize() needs to be called afterwards to * complete the second level initialization. */ public static Tab createTabForLazyLoad(ChromeActivity activity, boolean incognito, WindowAndroid nativeWindow, TabLaunchType type, int parentId, LoadUrlParams loadUrlParams) { Tab tab = new Tab( INVALID_TAB_ID, parentId, incognito, activity, nativeWindow, type, TabCreationState.FROZEN_FOR_LAZY_LOAD, null); tab.setPendingLoadParams(loadUrlParams); return tab; }
Example #24
Source File: UpdateMenuItemHelper.java From AndroidChromium with Apache License 2.0 | 5 votes |
private boolean updateAvailable(ChromeActivity activity) { if (!mAlreadyCheckedForUpdates) { checkForUpdateOnBackgroundThread(activity); return false; } return mUpdateAvailable; }
Example #25
Source File: RecentTabsPage.java From 365browser with Apache License 2.0 | 5 votes |
/** * Constructor returns an instance of RecentTabsPage. * * @param activity The activity this view belongs to. * @param recentTabsManager The RecentTabsManager which provides the model data. */ public RecentTabsPage(ChromeActivity activity, RecentTabsManager recentTabsManager) { mActivity = activity; mRecentTabsManager = recentTabsManager; mTitle = activity.getResources().getString(R.string.recent_tabs); mThemeColor = ApiCompatibilityUtils.getColor( activity.getResources(), R.color.default_primary_color); mRecentTabsManager.setUpdatedCallback(this); LayoutInflater inflater = LayoutInflater.from(activity); mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null); mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview); mAdapter = new RecentTabsRowAdapter(activity, recentTabsManager); mListView.setAdapter(mAdapter); mListView.setOnChildClickListener(this); mListView.setGroupIndicator(null); mListView.setOnGroupCollapseListener(this); mListView.setOnGroupExpandListener(this); mListView.setOnCreateContextMenuListener(this); mView.addOnAttachStateChangeListener(this); ApplicationStatus.registerStateListenerForActivity(this, activity); // {@link #mInForeground} will be updated once the view is attached to the window. if (activity.getBottomSheet() != null) { View recentTabsRoot = mView.findViewById(R.id.recent_tabs_root); ApiCompatibilityUtils.setPaddingRelative(recentTabsRoot, ApiCompatibilityUtils.getPaddingStart(recentTabsRoot), 0, ApiCompatibilityUtils.getPaddingEnd(recentTabsRoot), activity.getResources().getDimensionPixelSize( R.dimen.bottom_control_container_height)); } onUpdated(); }
Example #26
Source File: CustomTabBottomBarDelegate.java From AndroidChromium with Apache License 2.0 | 5 votes |
private static void sendPendingIntentWithUrl(PendingIntent pendingIntent, Intent extraIntent, ChromeActivity activity) { Intent addedIntent = extraIntent == null ? new Intent() : new Intent(extraIntent); Tab tab = activity.getActivityTab(); if (tab != null) addedIntent.setData(Uri.parse(tab.getUrl())); try { pendingIntent.send(activity, 0, addedIntent, null, null); } catch (CanceledException e) { Log.e(TAG, "CanceledException when sending pending intent."); } }
Example #27
Source File: Tab.java From delion with Apache License 2.0 | 5 votes |
/** * @return {@link ChromeActivity} that currently contains this {@link Tab} in its * {@link TabModel}. */ ChromeActivity getActivity() { Activity activity = WindowAndroid.activityFromContext( getWindowAndroid().getContext().get()); if (activity instanceof ChromeActivity) return (ChromeActivity) activity; return null; }
Example #28
Source File: Tab.java From delion with Apache License 2.0 | 5 votes |
@Override public int getSystemWindowInsetBottom() { ChromeActivity activity = getActivity(); if (activity != null && activity.getInsetObserverView() != null) { return activity.getInsetObserverView().getSystemWindowInsetsBottom(); } return 0; }
Example #29
Source File: Tab.java From delion with Apache License 2.0 | 5 votes |
@Override public int getSystemWindowInsetRight() { ChromeActivity activity = getActivity(); if (activity != null) { return activity.getInsetObserverView().getSystemWindowInsetsRight(); } return 0; }
Example #30
Source File: Tab.java From delion with Apache License 2.0 | 5 votes |
@Override public int getSystemWindowInsetLeft() { ChromeActivity activity = getActivity(); if (activity != null) { return activity.getInsetObserverView().getSystemWindowInsetsLeft(); } return 0; }