org.chromium.base.ObserverList Java Examples

The following examples show how to use org.chromium.base.ObserverList. 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: LayoutManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link LayoutManager} instance.
 * @param host A {@link LayoutManagerHost} instance.
 */
public LayoutManager(LayoutManagerHost host) {
    mHost = host;
    mPxToDp = 1.f / mHost.getContext().getResources().getDisplayMetrics().density;
    mSceneChangeObservers = new ObserverList<SceneChangeObserver>();

    int hostWidth = host.getWidth();
    int hostHeight = host.getHeight();
    mLastViewportPx.set(0, 0, hostWidth, hostHeight);
    mLastVisibleViewportPx.set(0, 0, hostWidth, hostHeight);
    mLastFullscreenViewportPx.set(0, 0, hostWidth, hostHeight);

    mLastContentWidthDp = hostWidth * mPxToDp;
    mLastContentHeightDp = hostHeight * mPxToDp;
    mLastViewportDp.set(0, 0, mLastContentWidthDp, mLastContentHeightDp);
    mLastVisibleViewportDp.set(0, 0, mLastContentWidthDp, mLastContentHeightDp);
    mLastFullscreenViewportDp.set(0, 0, mLastContentWidthDp, mLastContentHeightDp);

    mCachedVisibleViewport = new Rect();

    mLastHeightMinusBrowserControlsDp = mLastContentHeightDp;
}
 
Example #2
Source File: TabModelImpl.java    From 365browser with Apache License 2.0 6 votes vote down vote up
public TabModelImpl(boolean incognito, boolean isTabbedActivity, TabCreator regularTabCreator,
        TabCreator incognitoTabCreator, TabModelSelectorUma uma,
        TabModelOrderController orderController, TabContentManager tabContentManager,
        TabPersistentStore tabSaver, TabModelDelegate modelDelegate, boolean supportUndo) {
    super(incognito, isTabbedActivity);
    initializeNative();
    mRegularTabCreator = regularTabCreator;
    mIncognitoTabCreator = incognitoTabCreator;
    mUma = uma;
    mOrderController = orderController;
    mTabContentManager = tabContentManager;
    mTabSaver = tabSaver;
    mModelDelegate = modelDelegate;
    mIsUndoSupported = supportUndo;
    mObservers = new ObserverList<TabModelObserver>();
    mRecentlyClosedBridge = new RecentlyClosedBridge(getProfile());
}
 
Example #3
Source File: UrlManager.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Construct the UrlManager.
 */
@VisibleForTesting
public UrlManager() {
    mPwsClient = new PwsClientImpl();
    mObservers = new ObserverList<Listener>();
    mNearbyUrls = new HashSet<>();
    mUrlInfoMap = new HashMap<>();
    mPwsResultMap = new HashMap<>();
    mUrlsSortedByTimestamp = new PriorityQueue<String>(1, new Comparator<String>() {
        @Override
        public int compare(String url1, String url2) {
            Long timestamp1 = Long.valueOf(mUrlInfoMap.get(url1).getFirstSeenTimestamp());
            Long timestamp2 = Long.valueOf(mUrlInfoMap.get(url2).getFirstSeenTimestamp());
            return timestamp1.compareTo(timestamp2);
        }
    });
    initSharedPreferences();
    registerNativeInitStartupCallback();
}
 
Example #4
Source File: LayoutManagerChrome.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the {@link LayoutManagerChrome} instance.
 * @param host              A {@link LayoutManagerHost} instance.
 */
public LayoutManagerChrome(LayoutManagerHost host, boolean createOverviewLayout) {
    super(host);
    Context context = host.getContext();
    LayoutRenderHost renderHost = host.getLayoutRenderHost();

    mOverviewModeObservers = new ObserverList<OverviewModeObserver>();

    // Build Event Filter Handlers
    mToolbarSwipeHandler = createToolbarSwipeHandler(this);

    // Build Layouts
    mOverviewListLayout = new OverviewListLayout(context, this, renderHost);
    mToolbarSwipeLayout = new ToolbarSwipeLayout(context, this, renderHost);
    if (createOverviewLayout) {
        mOverviewLayout = new StackLayout(context, this, renderHost);
    }
}
 
Example #5
Source File: UrlManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Construct the UrlManager.
 * @param context An instance of android.content.Context
 */
@VisibleForTesting
public UrlManager(Context context) {
    mContext = context;
    mNotificationManager = new NotificationManagerProxyImpl(
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
    mPwsClient = new PwsClientImpl(context);
    mObservers = new ObserverList<Listener>();
    mNearbyUrls = new HashSet<>();
    mUrlInfoMap = new HashMap<>();
    mPwsResultMap = new HashMap<>();
    mUrlsSortedByTimestamp = new PriorityQueue<String>(1, new Comparator<String>() {
        @Override
        public int compare(String url1, String url2) {
            Long scanTimestamp1 = Long.valueOf(mUrlInfoMap.get(url1).getScanTimestamp());
            Long scanTimestamp2 = Long.valueOf(mUrlInfoMap.get(url2).getScanTimestamp());
            return scanTimestamp1.compareTo(scanTimestamp2);
        }
    });
    initSharedPreferences();
    registerNativeInitStartupCallback();
}
 
Example #6
Source File: TabModelImpl.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
public TabModelImpl(boolean incognito, boolean isTabbedActivity, TabCreator regularTabCreator,
        TabCreator incognitoTabCreator, TabModelSelectorUma uma,
        TabModelOrderController orderController, TabContentManager tabContentManager,
        TabPersistentStore tabSaver, TabModelDelegate modelDelegate, boolean supportUndo) {
    super(incognito, isTabbedActivity);
    initializeNative();
    mRegularTabCreator = regularTabCreator;
    mIncognitoTabCreator = incognitoTabCreator;
    mUma = uma;
    mOrderController = orderController;
    mTabContentManager = tabContentManager;
    mTabSaver = tabSaver;
    mModelDelegate = modelDelegate;
    mIsUndoSupported = supportUndo;
    mObservers = new ObserverList<TabModelObserver>();
    mRecentlyClosedBridge = new RecentlyClosedBridge(getProfile());
}
 
Example #7
Source File: LayoutManagerChrome.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the {@link LayoutManagerChrome} instance.
 * @param host              A {@link LayoutManagerHost} instance.
 * @param overviewLayoutFactoryDelegate A {@link OverviewLayoutFactoryDelegate} instance.
 */
public LayoutManagerChrome(
        LayoutManagerHost host, OverviewLayoutFactoryDelegate overviewLayoutFactoryDelegate) {
    super(host);
    Context context = host.getContext();
    LayoutRenderHost renderHost = host.getLayoutRenderHost();

    mOverviewModeObservers = new ObserverList<OverviewModeObserver>();

    // Build Event Filter Handlers
    mToolbarSwipeHandler = new ToolbarSwipeHandler(this);

    // Build Event Filters
    mBlackHoleEventFilter = new BlackHoleEventFilter(context, this);
    mGestureEventFilter = new GestureEventFilter(context, this, mGestureHandler);

    // Build Layouts
    mOverviewListLayout =
            new OverviewListLayout(context, this, renderHost, mBlackHoleEventFilter);
    mToolbarSwipeLayout =
            new ToolbarSwipeLayout(context, this, renderHost, mBlackHoleEventFilter);
    if (overviewLayoutFactoryDelegate != null) {
        mOverviewLayout = overviewLayoutFactoryDelegate.createOverviewLayout(
                context, this, renderHost, mGestureEventFilter);
    }
}
 
Example #8
Source File: LayoutManagerChrome.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the {@link LayoutManagerChrome} instance.
 * @param host              A {@link LayoutManagerHost} instance.
 * @param overviewLayoutFactoryDelegate A {@link OverviewLayoutFactoryDelegate} instance.
 */
public LayoutManagerChrome(
        LayoutManagerHost host, OverviewLayoutFactoryDelegate overviewLayoutFactoryDelegate) {
    super(host);
    Context context = host.getContext();
    LayoutRenderHost renderHost = host.getLayoutRenderHost();

    mOverviewModeObservers = new ObserverList<OverviewModeObserver>();

    // Build Event Filter Handlers
    mToolbarSwipeHandler = new ToolbarSwipeHandler(this);

    // Build Event Filters
    mBlackHoleEventFilter = new BlackHoleEventFilter(context, this);
    mGestureEventFilter = new GestureEventFilter(context, this, mGestureHandler);

    // Build Layouts
    mOverviewListLayout =
            new OverviewListLayout(context, this, renderHost, mBlackHoleEventFilter);
    mToolbarSwipeLayout =
            new ToolbarSwipeLayout(context, this, renderHost, mBlackHoleEventFilter);
    if (overviewLayoutFactoryDelegate != null) {
        mOverviewLayout = overviewLayoutFactoryDelegate.createOverviewLayout(
                context, this, renderHost, mGestureEventFilter);
    }
}
 
Example #9
Source File: LayoutManager.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link LayoutManager} instance.
 * @param host A {@link LayoutManagerHost} instance.
 */
public LayoutManager(LayoutManagerHost host) {
    mHost = host;
    mPxToDp = 1.f / mHost.getContext().getResources().getDisplayMetrics().density;
    mSceneChangeObservers = new ObserverList<SceneChangeObserver>();

    int hostWidth = host.getWidth();
    int hostHeight = host.getHeight();
    mLastViewportPx.set(0, 0, hostWidth, hostHeight);
    mLastVisibleViewportPx.set(0, 0, hostWidth, hostHeight);
    mLastFullscreenViewportPx.set(0, 0, hostWidth, hostHeight);

    mLastContentWidthDp = hostWidth * mPxToDp;
    mLastContentHeightDp = hostHeight * mPxToDp;
    mLastViewportDp.set(0, 0, mLastContentWidthDp, mLastContentHeightDp);
    mLastVisibleViewportDp.set(0, 0, mLastContentWidthDp, mLastContentHeightDp);
    mLastFullscreenViewportDp.set(0, 0, mLastContentWidthDp, mLastContentHeightDp);

    mLastHeightMinusTopControlsDp = mLastContentHeightDp;
}
 
Example #10
Source File: TabModelImpl.java    From delion with Apache License 2.0 6 votes vote down vote up
public TabModelImpl(boolean incognito, TabCreator regularTabCreator,
        TabCreator incognitoTabCreator, TabModelSelectorUma uma,
        TabModelOrderController orderController, TabContentManager tabContentManager,
        TabPersistentStore tabSaver, TabModelDelegate modelDelegate, boolean supportUndo) {
    super(incognito);
    initializeNative();
    mRegularTabCreator = regularTabCreator;
    mIncognitoTabCreator = incognitoTabCreator;
    mUma = uma;
    mOrderController = orderController;
    mTabContentManager = tabContentManager;
    mTabSaver = tabSaver;
    mModelDelegate = modelDelegate;
    mIsUndoSupported = supportUndo;
    mObservers = new ObserverList<TabModelObserver>();
}
 
Example #11
Source File: NetworkChangeNotifier.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@VisibleForTesting
protected NetworkChangeNotifier() {
    mNativeChangeNotifiers = new ArrayList<Long>();
    mConnectionTypeObservers = new ObserverList<ConnectionTypeObserver>();
    mConnectivityManager =
            (ConnectivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.CONNECTIVITY_SERVICE);
}
 
Example #12
Source File: SmoothProgressBar.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new progress bar with range 0...100 and initial progress of 0.
 * @param context the application environment.
 * @param attrs the xml attributes that should be used to initialize this view.
 */
public SmoothProgressBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    setMax(MAX * mResolutionMutiplier);

    mObservers = new ObserverList<ProgressChangeListener>();
    mObserversIterator = mObservers.rewindableIterator();

}
 
Example #13
Source File: UrlManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Construct the UrlManager.
 * @param context An instance of android.content.Context
 */
public UrlManager(Context context) {
    mContext = context;
    mNotificationManager = new NotificationManagerProxyImpl(
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
    mPwsClient = new PwsClientImpl(context);
    mObservers = new ObserverList<Listener>();
    mNearbyUrls = new HashSet<>();
    mResolvedUrls = new HashSet<>();
    mUrlInfoMap = new HashMap<>();
    mUrlsSortedByTimestamp = new PriorityQueue<String>(1, mScanTimestampComparator);
    initSharedPreferences();
}
 
Example #14
Source File: ContentViewCore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new ContentViewCore. Embedders must call initialize() after constructing
 * a ContentViewCore and before using it.
 *
 * @param context The context used to create this.
 */
public ContentViewCore(Context context, String productVersion) {
    mContext = context;
    mProductVersion = productVersion;
    mRenderCoordinates = new RenderCoordinates();
    mAccessibilityManager = (AccessibilityManager)
            getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    mSystemCaptioningBridge = CaptioningBridgeFactory.getSystemCaptioningBridge(mContext);
    mGestureStateListeners = new ObserverList<GestureStateListener>();
    mGestureStateListenersIterator = mGestureStateListeners.rewindableIterator();

    mWindowAndroidChangedObservers = new ObserverList<WindowAndroidChangedObserver>();
}
 
Example #15
Source File: SmoothProgressBar.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new progress bar with range 0...100 and initial progress of 0.
 * @param context the application environment.
 * @param attrs the xml attributes that should be used to initialize this view.
 */
public SmoothProgressBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    setMax(MAX * mResolutionMutiplier);

    mObservers = new ObserverList<ProgressChangeListener>();
    mObserversIterator = mObservers.rewindableIterator();

}
 
Example #16
Source File: NetworkChangeNotifier.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private NetworkChangeNotifier(Context context) {
    mContext = context.getApplicationContext();
    mNativeChangeNotifiers = new ArrayList<Integer>();
    mConnectionTypeObservers = new ObserverList<ConnectionTypeObserver>();
}
 
Example #17
Source File: OAuth2TokenService.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private OAuth2TokenService(int nativeOAuth2Service) {
    mNativeProfileOAuth2TokenService = nativeOAuth2Service;
    mObservers = new ObserverList<OAuth2TokenServiceObserver>();
}
 
Example #18
Source File: NetworkChangeNotifier.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
protected NetworkChangeNotifier() {
    mNativeChangeNotifiers = new ArrayList<Long>();
    mConnectionTypeObservers = new ObserverList<ConnectionTypeObserver>();
}
 
Example #19
Source File: CipherFactory.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private CipherFactory() {
    mRandomNumberProvider = new ByteArrayGenerator();
    mObservers = new ObserverList<CipherDataObserver>();
}
 
Example #20
Source File: MediaSessionImpl.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private MediaSessionImpl(long nativeMediaSession) {
    mNativeMediaSessionAndroid = nativeMediaSession;
    mObservers = new ObserverList<MediaSessionObserver>();
    mObserversIterator = mObservers.rewindableIterator();
}
 
Example #21
Source File: MediaSessionImpl.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public ObserverList.RewindableIterator<MediaSessionObserver> getObserversForTesting() {
    return mObservers.rewindableIterator();
}
 
Example #22
Source File: FontSizePrefs.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private FontSizePrefs(Context context) {
    mFontSizePrefsAndroidPtr = nativeInit();
    mApplicationContext = context.getApplicationContext();
    mSharedPreferences = ContextUtils.getAppSharedPreferences();
    mObserverList = new ObserverList<FontSizePrefsObserver>();
}
 
Example #23
Source File: OAuth2TokenService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private OAuth2TokenService(long nativeOAuth2Service) {
    mNativeOAuth2TokenServiceDelegateAndroid = nativeOAuth2Service;
    mObservers = new ObserverList<OAuth2TokenServiceObserver>();
    AccountTrackerService.get().addSystemAccountsSeededListener(this);
}
 
Example #24
Source File: OfflineContentAggregatorBridge.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * A private constructor meant to be called by the C++ OfflineContentAggregatorBridge.
 * @param nativeOfflineContentAggregatorBridge A C++ pointer to the
 * OfflineContentAggregatorBridge.
 */
private OfflineContentAggregatorBridge(long nativeOfflineContentAggregatorBridge) {
    mNativeOfflineContentAggregatorBridge = nativeOfflineContentAggregatorBridge;
    mItemsAvailable = false;
    mObservers = new ObserverList<OfflineContentProvider.Observer>();
}
 
Example #25
Source File: OAuth2TokenService.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private OAuth2TokenService(int nativeOAuth2Service) {
    mNativeProfileOAuth2TokenService = nativeOAuth2Service;
    mObservers = new ObserverList<OAuth2TokenServiceObserver>();
}
 
Example #26
Source File: NetworkChangeNotifier.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private NetworkChangeNotifier(Context context) {
    mContext = context.getApplicationContext();
    mNativeChangeNotifiers = new ArrayList<Integer>();
    mConnectionTypeObservers = new ObserverList<ConnectionTypeObserver>();
}
 
Example #27
Source File: PageLoadMetrics.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/** Adds an observer. */
public static boolean addObserver(Observer observer) {
    ThreadUtils.assertOnUiThread();
    if (sObservers == null) sObservers = new ObserverList<>();
    return sObservers.addObserver(observer);
}
 
Example #28
Source File: HomepageManager.java    From delion with Apache License 2.0 4 votes vote down vote up
private HomepageManager(Context context) {
    mSharedPreferences = ContextUtils.getAppSharedPreferences();
    mHomepageStateListeners = new ObserverList<HomepageManager.HomepageStateListener>();
}
 
Example #29
Source File: OAuth2TokenService.java    From delion with Apache License 2.0 4 votes vote down vote up
private OAuth2TokenService(Context context, long nativeOAuth2Service) {
    mNativeOAuth2TokenServiceDelegateAndroid = nativeOAuth2Service;
    mObservers = new ObserverList<OAuth2TokenServiceObserver>();
    AccountTrackerService.get(context).addSystemAccountsSeededListener(this);
}
 
Example #30
Source File: FontSizePrefs.java    From delion with Apache License 2.0 4 votes vote down vote up
private FontSizePrefs(Context context) {
    mFontSizePrefsAndroidPtr = nativeInit();
    mApplicationContext = context.getApplicationContext();
    mSharedPreferences = ContextUtils.getAppSharedPreferences();
    mObserverList = new ObserverList<FontSizePrefsObserver>();
}