| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.tab; | 5 package org.chromium.chrome.browser.tab; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.Intent; | 8 import android.content.Intent; |
| 9 import android.net.MailTo; | 9 import android.net.MailTo; |
| 10 import android.net.Uri; | 10 import android.net.Uri; |
| 11 import android.provider.Browser; |
| 11 import android.provider.ContactsContract; | 12 import android.provider.ContactsContract; |
| 12 | 13 |
| 13 import org.chromium.base.metrics.RecordUserAction; | 14 import org.chromium.base.metrics.RecordUserAction; |
| 15 import org.chromium.chrome.browser.DefaultBrowserInfo; |
| 14 import org.chromium.chrome.browser.IntentHandler; | 16 import org.chromium.chrome.browser.IntentHandler; |
| 15 import org.chromium.chrome.browser.UrlConstants; | 17 import org.chromium.chrome.browser.UrlConstants; |
| 16 import org.chromium.chrome.browser.contextmenu.ContextMenuItemDelegate; | 18 import org.chromium.chrome.browser.contextmenu.ContextMenuItemDelegate; |
| 19 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
| 17 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; | 20 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; |
| 18 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; | 21 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; |
| 19 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 22 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 20 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 23 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| 21 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; | 24 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; |
| 22 import org.chromium.chrome.browser.util.IntentUtils; | 25 import org.chromium.chrome.browser.util.IntentUtils; |
| 23 import org.chromium.chrome.browser.util.UrlUtilities; | 26 import org.chromium.chrome.browser.util.UrlUtilities; |
| 24 import org.chromium.content_public.browser.LoadUrlParams; | 27 import org.chromium.content_public.browser.LoadUrlParams; |
| 25 import org.chromium.content_public.common.Referrer; | 28 import org.chromium.content_public.common.Referrer; |
| 26 import org.chromium.ui.base.Clipboard; | 29 import org.chromium.ui.base.Clipboard; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 228 } |
| 226 | 229 |
| 227 if (!activityStarted) { | 230 if (!activityStarted) { |
| 228 Context context = mTab.getActivity(); | 231 Context context = mTab.getActivity(); |
| 229 if (context == null) context = mTab.getApplicationContext(); | 232 if (context == null) context = mTab.getApplicationContext(); |
| 230 context.startActivity(chromeIntent); | 233 context.startActivity(chromeIntent); |
| 231 activityStarted = true; | 234 activityStarted = true; |
| 232 } | 235 } |
| 233 } | 236 } |
| 234 | 237 |
| 238 @Override |
| 239 public void onOpenInNewChromeTabFromCCT(String linkUrl, boolean isIncognito)
{ |
| 240 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)); |
| 241 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 242 intent.setPackage(mTab.getApplicationContext().getPackageName()); |
| 243 intent.putExtra(ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PAR
ENT, false); |
| 244 if (isIncognito) { |
| 245 intent.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, true); |
| 246 intent.putExtra( |
| 247 Browser.EXTRA_APPLICATION_ID, mTab.getApplicationContext().g
etPackageName()); |
| 248 IntentHandler.addTrustedIntentExtras(intent); |
| 249 } |
| 250 IntentUtils.safeStartActivity(mTab.getActivity(), intent); |
| 251 } |
| 252 |
| 253 @Override |
| 254 public String getTitleForOpenTabInExternalApp() { |
| 255 return DefaultBrowserInfo.getTitleOpenInDefaultBrowser(false); |
| 256 } |
| 257 |
| 258 @Override |
| 259 public void onOpenInDefaultBrowser(String url) { |
| 260 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
| 261 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 262 IntentUtils.safeStartActivity(mTab.getActivity(), intent); |
| 263 } |
| 264 |
| 235 /** | 265 /** |
| 236 * Checks if spdy proxy is enabled for input url. | 266 * Checks if spdy proxy is enabled for input url. |
| 237 * @param url Input url to check for spdy setting. | 267 * @param url Input url to check for spdy setting. |
| 238 * @return true if url is enabled for spdy proxy. | 268 * @return true if url is enabled for spdy proxy. |
| 239 */ | 269 */ |
| 240 private boolean isSpdyProxyEnabledForUrl(String url) { | 270 private boolean isSpdyProxyEnabledForUrl(String url) { |
| 241 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled
() | 271 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled
() |
| 242 && url != null && !url.toLowerCase(Locale.US).startsWith( | 272 && url != null && !url.toLowerCase(Locale.US).startsWith( |
| 243 UrlConstants.HTTPS_URL_PREFIX) | 273 UrlConstants.HTTPS_URL_PREFIX) |
| 244 && !isIncognito()) { | 274 && !isIncognito()) { |
| 245 return true; | 275 return true; |
| 246 } | 276 } |
| 247 return false; | 277 return false; |
| 248 } | 278 } |
| 249 | 279 |
| 250 } | 280 } |
| OLD | NEW |