org.chromium.chrome.browser.tabmodel.document.TabDelegate Java Examples

The following examples show how to use org.chromium.chrome.browser.tabmodel.document.TabDelegate. 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: CustomTabDelegateFactory.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void openNewTab(String url, String extraHeaders, ResourceRequestBody postData,
        int disposition, boolean isRendererInitiated) {
    // If attempting to open an incognito tab, always send the user to tabbed mode.
    if (disposition == WindowOpenDisposition.OFF_THE_RECORD) {
        if (isRendererInitiated) {
            throw new IllegalStateException(
                    "Invalid attempt to open an incognito tab from the renderer");
        }
        LoadUrlParams loadUrlParams = new LoadUrlParams(url);
        loadUrlParams.setVerbatimHeaders(extraHeaders);
        loadUrlParams.setPostData(postData);
        loadUrlParams.setIsRendererInitiated(isRendererInitiated);

        Class<? extends ChromeTabbedActivity> tabbedClass =
                MultiWindowUtils.getInstance().getTabbedActivityForIntent(
                        null, ContextUtils.getApplicationContext());
        AsyncTabCreationParams tabParams = new AsyncTabCreationParams(loadUrlParams,
                new ComponentName(ContextUtils.getApplicationContext(), tabbedClass));
        new TabDelegate(true).createNewTab(tabParams,
                TabLaunchType.FROM_LONGPRESS_FOREGROUND, TabModel.INVALID_TAB_INDEX);
        return;
    }

    super.openNewTab(url, extraHeaders, postData, disposition, isRendererInitiated);
}
 
Example #2
Source File: BookmarkActionBar.java    From delion with Apache License 2.0 5 votes vote down vote up
private static void openBookmarksInNewTabs(
        List<BookmarkId> bookmarks, TabDelegate tabDelegate, BookmarkModel model) {
    for (BookmarkId id : bookmarks) {
        tabDelegate.createNewTab(new LoadUrlParams(model.getBookmarkById(id).getUrl()),
                TabLaunchType.FROM_LONGPRESS_BACKGROUND, null);
    }
}
 
Example #3
Source File: ClearBrowsingDataPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Set the texts that notify the user about data in their google account and that deleting
 * cookies doesn't sign you out of chrome.
 */
protected void initFootnote() {
    // The general information footnote informs users about data that will not be deleted.
    // If the user is signed in, it also informs users about the behavior of synced deletions.
    // and we show an additional Google-specific footnote. This footnote informs users that they
    // will not be signed out of their Google account, and if the web history service indicates
    // that they have other forms of browsing history, then also about that.
    TextMessageWithLinkAndIconPreference google_summary =
            (TextMessageWithLinkAndIconPreference) findPreference(PREF_GOOGLE_SUMMARY);
    TextMessageWithLinkAndIconPreference general_summary =
            (TextMessageWithLinkAndIconPreference) findPreference(PREF_GENERAL_SUMMARY);

    google_summary.setLinkClickDelegate(new Runnable() {
        @Override
        public void run() {
            new TabDelegate(false /* incognito */).launchUrl(
                    WEB_HISTORY_URL, TabLaunchType.FROM_CHROME_UI);
        }
    });
    general_summary.setLinkClickDelegate(new Runnable() {
        @Override
        public void run() {
            HelpAndFeedback.getInstance(getActivity()).show(
                    getActivity(),
                    getResources().getString(R.string.help_context_clear_browsing_data),
                    Profile.getLastUsedProfile(),
                    null);
        }
    });
    if (ChromeSigninController.get().isSignedIn()) {
        general_summary.setSummary(
                R.string.clear_browsing_data_footnote_sync_and_site_settings);
    } else {
        getPreferenceScreen().removePreference(google_summary);
        general_summary.setSummary(R.string.clear_browsing_data_footnote_site_settings);
    }
}
 
Example #4
Source File: OtherFormsOfHistoryDialogFragment.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.other_forms_of_history_dialog, null);

    // Linkify the <link></link> span in the dialog text.
    TextView textView = (TextView) view.findViewById(R.id.text);
    final SpannableString textWithLink = SpanApplier.applySpans(
            textView.getText().toString(),
            new SpanApplier.SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {
                @Override
                public void onClick(View widget) {
                    new TabDelegate(false /* incognito */).launchUrl(
                            WEB_HISTORY_URL, TabLaunchType.FROM_CHROME_UI);
                }
            }));

    textView.setText(textWithLink);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    // Construct the dialog.
    AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setView(view)
            .setTitle(R.string.clear_browsing_data_history_dialog_title)
            .setPositiveButton(
                    R.string.ok_got_it, this)
            .create();

    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
 
Example #5
Source File: ClearBrowsingDataPreferencesBasic.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ClearBrowsingDataTabCheckBoxPreference historyCheckbox =
            (ClearBrowsingDataTabCheckBoxPreference) findPreference(PREF_HISTORY);
    ClearBrowsingDataTabCheckBoxPreference cookiesCheckbox =
            (ClearBrowsingDataTabCheckBoxPreference) findPreference(PREF_COOKIES);

    historyCheckbox.setLinkClickDelegate(new Runnable() {
        @Override
        public void run() {
            new TabDelegate(false /* incognito */)
                    .launchUrl(MY_ACTIVITY_URL, TabModel.TabLaunchType.FROM_CHROME_UI);
        }
    });

    if (ChromeSigninController.get().isSignedIn()) {
        if (isHistorySyncEnabled()) {
            historyCheckbox.setSummary(R.string.clear_browsing_history_summary_synced);
        } else {
            historyCheckbox.setSummary(R.string.clear_browsing_history_summary_signed_in);
        }
        cookiesCheckbox.setSummary(
                R.string.clear_cookies_and_site_data_signed_in_summary_basic);
    }
}
 
Example #6
Source File: TabContextMenuItemDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onOpenInOtherWindow(String url, Referrer referrer) {
    TabDelegate tabDelegate = new TabDelegate(mTab.isIncognito());
    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setReferrer(referrer);
    tabDelegate.createTabInOtherWindow(loadUrlParams, mTab.getActivity(), mTab.getParentId());
}
 
Example #7
Source File: OfflinePageDownloadBridge.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * 'Opens' the offline page identified by the GUID.
 * This is done by creating a new tab and navigating it to the saved local snapshot.
 * No automatic redirection is happening based on the connection status.
 * If the item with specified GUID is not found or can't be opened, nothing happens.
 * @param guid          GUID of the item to open.
 * @param componentName If specified, targets a specific Activity to open the offline page in.
 */
@Override
public void openItem(String guid, @Nullable ComponentName componentName) {
    OfflinePageDownloadItem item = getItem(guid);
    if (item == null) return;

    LoadUrlParams params = OfflinePageUtils.getLoadUrlParamsForOpeningOfflineVersion(
            item.getUrl(), nativeGetOfflineIdByGuid(mNativeOfflinePageDownloadBridge, guid));
    AsyncTabCreationParams asyncParams = componentName == null
            ? new AsyncTabCreationParams(params)
            : new AsyncTabCreationParams(params, componentName);
    final TabDelegate tabDelegate = new TabDelegate(false);
    tabDelegate.createNewTab(asyncParams, TabLaunchType.FROM_CHROME_UI, Tab.INVALID_TAB_ID);
}
 
Example #8
Source File: BookmarkActionBar.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private static void openBookmarksInNewTabs(
        List<BookmarkId> bookmarks, TabDelegate tabDelegate, BookmarkModel model) {
    for (BookmarkId id : bookmarks) {
        tabDelegate.createNewTab(new LoadUrlParams(model.getBookmarkById(id).getUrl()),
                TabLaunchType.FROM_LONGPRESS_BACKGROUND, null);
    }
}
 
Example #9
Source File: OtherFormsOfHistoryDialogFragment.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.other_forms_of_history_dialog, null);

    // Linkify the <link></link> span in the dialog text.
    TextView textView = (TextView) view.findViewById(R.id.text);
    final SpannableString textWithLink = SpanApplier.applySpans(
            textView.getText().toString(),
            new SpanApplier.SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {
                @Override
                public void onClick(View widget) {
                    new TabDelegate(false /* incognito */).launchUrl(
                            WEB_HISTORY_URL, TabLaunchType.FROM_CHROME_UI);
                }
            }));

    textView.setText(textWithLink);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    // Construct the dialog.
    AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setView(view)
            .setTitle(R.string.clear_browsing_data_history_dialog_title)
            .setPositiveButton(
                    R.string.ok_got_it, this)
            .create();

    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
 
Example #10
Source File: TabContextMenuItemDelegate.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onOpenInOtherWindow(String url, Referrer referrer) {
    TabDelegate tabDelegate = new TabDelegate(mTab.isIncognito());
    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setReferrer(referrer);
    tabDelegate.createTabInOtherWindow(loadUrlParams, mTab.getActivity(), mTab.getParentId());
}
 
Example #11
Source File: OfflinePageDownloadBridge.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * 'Opens' the offline page identified by the GUID.
 * This is done by creating a new tab and navigating it to the saved local snapshot.
 * No automatic redirection is happening based on the connection status.
 * If the item with specified GUID is not found or can't be opened, nothing happens.
 * @param guid          GUID of the item to open.
 * @param componentName If specified, targets a specific Activity to open the offline page in.
 */
@Override
public void openItem(String guid, @Nullable ComponentName componentName) {
    OfflinePageDownloadItem item = getItem(guid);
    if (item == null) return;

    LoadUrlParams params = OfflinePageUtils.getLoadUrlParamsForOpeningOfflineVersion(
            item.getUrl(), nativeGetOfflineIdByGuid(mNativeOfflinePageDownloadBridge, guid));
    AsyncTabCreationParams asyncParams = componentName == null
            ? new AsyncTabCreationParams(params)
            : new AsyncTabCreationParams(params, componentName);
    final TabDelegate tabDelegate = new TabDelegate(false);
    tabDelegate.createNewTab(asyncParams, TabLaunchType.FROM_CHROME_UI, Tab.INVALID_TAB_ID);
}
 
Example #12
Source File: BookmarkActionBar.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private static void openBookmarksInNewTabs(
        List<BookmarkId> bookmarks, TabDelegate tabDelegate, BookmarkModel model) {
    for (BookmarkId id : bookmarks) {
        tabDelegate.createNewTab(new LoadUrlParams(model.getBookmarkById(id).getUrl()),
                TabLaunchType.FROM_LONGPRESS_BACKGROUND, null);
    }
}
 
Example #13
Source File: OtherFormsOfHistoryDialogFragment.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.other_forms_of_history_dialog, null);

    // Linkify the <link></link> span in the dialog text.
    TextView textView = (TextView) view.findViewById(R.id.text);
    final SpannableString textWithLink = SpanApplier.applySpans(
            textView.getText().toString(),
            new SpanApplier.SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {
                @Override
                public void onClick(View widget) {
                    new TabDelegate(false /* incognito */).launchUrl(
                            WEB_HISTORY_URL, TabLaunchType.FROM_CHROME_UI);
                }
            }));

    textView.setText(textWithLink);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    // Construct the dialog.
    AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setView(view)
            .setTitle(R.string.clear_browsing_data_history_dialog_title)
            .setPositiveButton(
                    R.string.ok_got_it, this)
            .create();

    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
 
Example #14
Source File: TabContextMenuItemDelegate.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onOpenInOtherWindow(String url, Referrer referrer) {
    TabDelegate tabDelegate = new TabDelegate(mTab.isIncognito());
    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setReferrer(referrer);
    tabDelegate.createTabInOtherWindow(loadUrlParams, mTab.getActivity(), mTab.getParentId());
}
 
Example #15
Source File: FullScreenActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
protected Pair<TabDelegate, TabDelegate> createTabCreators() {
    return Pair.create(createTabDelegate(false), createTabDelegate(true));
}
 
Example #16
Source File: FullScreenActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/** Creates TabDelegates for opening new Tabs. */
protected TabDelegate createTabDelegate(boolean incognito) {
    return new TabDelegate(incognito);
}
 
Example #17
Source File: EmbedContentViewActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
protected TabDelegate createTabDelegate(boolean incognito) {
    return new TabDelegate(incognito);
}
 
Example #18
Source File: FullScreenActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
protected Pair<TabDelegate, TabDelegate> createTabCreators() {
    return Pair.create(createTabDelegate(false), createTabDelegate(true));
}
 
Example #19
Source File: FullScreenActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/** Creates TabDelegates for opening new Tabs. */
protected TabDelegate createTabDelegate(boolean incognito) {
    return new TabDelegate(incognito);
}
 
Example #20
Source File: FullScreenActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
/** Creates TabDelegates for opening new Tabs. */
protected TabDelegate createTabDelegate(boolean incognito) {
    return new TabDelegate(incognito);
}
 
Example #21
Source File: EmbedContentViewActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
protected TabDelegate createTabDelegate(boolean incognito) {
    return new TabDelegate(incognito);
}
 
Example #22
Source File: SuggestionsNavigationDelegateImpl.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private void openUrlInNewWindow(LoadUrlParams loadUrlParams) {
    TabDelegate tabDelegate = new TabDelegate(false);
    tabDelegate.createTabInOtherWindow(loadUrlParams, mActivity, mHost.getParentId());
}