Chromium Code Reviews| 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; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.Activity; | 9 import android.app.Activity; |
| 10 import android.app.SearchManager; | 10 import android.app.SearchManager; |
| 11 import android.app.assist.AssistContent; | 11 import android.app.assist.AssistContent; |
| 12 import android.content.ActivityNotFoundException; | |
| 12 import android.content.Context; | 13 import android.content.Context; |
| 13 import android.content.Intent; | 14 import android.content.Intent; |
| 14 import android.content.res.Configuration; | 15 import android.content.res.Configuration; |
| 15 import android.graphics.Bitmap; | 16 import android.graphics.Bitmap; |
| 16 import android.graphics.Color; | 17 import android.graphics.Color; |
| 17 import android.graphics.Rect; | 18 import android.graphics.Rect; |
| 18 import android.graphics.drawable.ColorDrawable; | 19 import android.graphics.drawable.ColorDrawable; |
| 19 import android.graphics.drawable.Drawable; | 20 import android.graphics.drawable.Drawable; |
| 20 import android.net.Uri; | 21 import android.net.Uri; |
| 21 import android.os.Build; | 22 import android.os.Build; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 37 import android.view.accessibility.AccessibilityManager; | 38 import android.view.accessibility.AccessibilityManager; |
| 38 import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeL istener; | 39 import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeL istener; |
| 39 import android.view.accessibility.AccessibilityManager.TouchExplorationStateChan geListener; | 40 import android.view.accessibility.AccessibilityManager.TouchExplorationStateChan geListener; |
| 40 | 41 |
| 41 import org.chromium.base.ActivityState; | 42 import org.chromium.base.ActivityState; |
| 42 import org.chromium.base.ApiCompatibilityUtils; | 43 import org.chromium.base.ApiCompatibilityUtils; |
| 43 import org.chromium.base.ApplicationStatus; | 44 import org.chromium.base.ApplicationStatus; |
| 44 import org.chromium.base.BaseSwitches; | 45 import org.chromium.base.BaseSwitches; |
| 45 import org.chromium.base.Callback; | 46 import org.chromium.base.Callback; |
| 46 import org.chromium.base.CommandLine; | 47 import org.chromium.base.CommandLine; |
| 48 import org.chromium.base.ContextUtils; | |
| 49 import org.chromium.base.Log; | |
| 47 import org.chromium.base.SysUtils; | 50 import org.chromium.base.SysUtils; |
| 48 import org.chromium.base.TraceEvent; | 51 import org.chromium.base.TraceEvent; |
| 49 import org.chromium.base.VisibleForTesting; | 52 import org.chromium.base.VisibleForTesting; |
| 50 import org.chromium.base.metrics.RecordHistogram; | 53 import org.chromium.base.metrics.RecordHistogram; |
| 51 import org.chromium.base.metrics.RecordUserAction; | 54 import org.chromium.base.metrics.RecordUserAction; |
| 52 import org.chromium.chrome.R; | 55 import org.chromium.chrome.R; |
| 53 import org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate; | 56 import org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate; |
| 54 import org.chromium.chrome.browser.IntentHandler.TabOpenType; | 57 import org.chromium.chrome.browser.IntentHandler.TabOpenType; |
| 55 import org.chromium.chrome.browser.appmenu.AppMenu; | 58 import org.chromium.chrome.browser.appmenu.AppMenu; |
| 56 import org.chromium.chrome.browser.appmenu.AppMenuHandler; | 59 import org.chromium.chrome.browser.appmenu.AppMenuHandler; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 import org.chromium.content_public.browser.readback_types.ReadbackResponse; | 144 import org.chromium.content_public.browser.readback_types.ReadbackResponse; |
| 142 import org.chromium.policy.CombinedPolicyProvider; | 145 import org.chromium.policy.CombinedPolicyProvider; |
| 143 import org.chromium.policy.CombinedPolicyProvider.PolicyChangeListener; | 146 import org.chromium.policy.CombinedPolicyProvider.PolicyChangeListener; |
| 144 import org.chromium.printing.PrintManagerDelegateImpl; | 147 import org.chromium.printing.PrintManagerDelegateImpl; |
| 145 import org.chromium.printing.PrintingController; | 148 import org.chromium.printing.PrintingController; |
| 146 import org.chromium.printing.PrintingControllerImpl; | 149 import org.chromium.printing.PrintingControllerImpl; |
| 147 import org.chromium.ui.base.ActivityWindowAndroid; | 150 import org.chromium.ui.base.ActivityWindowAndroid; |
| 148 import org.chromium.ui.base.DeviceFormFactor; | 151 import org.chromium.ui.base.DeviceFormFactor; |
| 149 import org.chromium.ui.base.PageTransition; | 152 import org.chromium.ui.base.PageTransition; |
| 150 import org.chromium.ui.base.WindowAndroid; | 153 import org.chromium.ui.base.WindowAndroid; |
| 154 import org.chromium.webapk.lib.client.WebApkValidator; | |
| 151 | 155 |
| 152 import java.util.ArrayList; | 156 import java.util.ArrayList; |
| 153 import java.util.List; | 157 import java.util.List; |
| 154 import java.util.concurrent.TimeUnit; | 158 import java.util.concurrent.TimeUnit; |
| 155 | 159 |
| 156 import javax.annotation.Nullable; | 160 import javax.annotation.Nullable; |
| 157 | 161 |
| 158 /** | 162 /** |
| 159 * A {@link AsyncInitializationActivity} that builds and manages a {@link Compos itorViewHolder} | 163 * A {@link AsyncInitializationActivity} that builds and manages a {@link Compos itorViewHolder} |
| 160 * and associated classes. | 164 * and associated classes. |
| (...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1759 && PrefServiceBridge.getInstance().isPrintingEnabled()) { | 1763 && PrefServiceBridge.getInstance().isPrintingEnabled()) { |
| 1760 printingController.startPrint(new TabPrinter(currentTab), | 1764 printingController.startPrint(new TabPrinter(currentTab), |
| 1761 new PrintManagerDelegateImpl(this)); | 1765 new PrintManagerDelegateImpl(this)); |
| 1762 RecordUserAction.record("MobileMenuPrint"); | 1766 RecordUserAction.record("MobileMenuPrint"); |
| 1763 } | 1767 } |
| 1764 } else if (id == R.id.add_to_homescreen_id) { | 1768 } else if (id == R.id.add_to_homescreen_id) { |
| 1765 AddToHomescreenManager addToHomescreenManager = | 1769 AddToHomescreenManager addToHomescreenManager = |
| 1766 new AddToHomescreenManager(this, currentTab); | 1770 new AddToHomescreenManager(this, currentTab); |
| 1767 addToHomescreenManager.start(); | 1771 addToHomescreenManager.start(); |
| 1768 RecordUserAction.record("MobileMenuAddToHomescreen"); | 1772 RecordUserAction.record("MobileMenuAddToHomescreen"); |
| 1773 } else if (id == R.id.open_webapk_id) { | |
| 1774 Context context = ContextUtils.getApplicationContext(); | |
| 1775 String packageName = WebApkValidator.queryWebApkPackage(context, cur rentTab.getUrl()); | |
| 1776 Intent launchIntent = | |
| 1777 context.getPackageManager().getLaunchIntentForPackage(packag eName); | |
| 1778 if (launchIntent != null) { | |
| 1779 try { | |
| 1780 context.startActivity(launchIntent); | |
| 1781 RecordUserAction.record("MobileMenuOpenWebAPK"); | |
| 1782 } catch (ActivityNotFoundException e) { | |
| 1783 Log.e(TAG, "Failed to open app : %s!", packageName, e); | |
|
dominickn
2017/02/21 23:04:42
Nit: clarify this to be "open WebAPK".
Should the
gonzalon
2017/02/22 15:50:49
Done, adn added the toast.
| |
| 1784 } | |
| 1785 } | |
| 1769 } else if (id == R.id.request_desktop_site_id) { | 1786 } else if (id == R.id.request_desktop_site_id) { |
| 1770 final boolean reloadOnChange = !currentTab.isNativePage(); | 1787 final boolean reloadOnChange = !currentTab.isNativePage(); |
| 1771 final boolean usingDesktopUserAgent = currentTab.getUseDesktopUserAg ent(); | 1788 final boolean usingDesktopUserAgent = currentTab.getUseDesktopUserAg ent(); |
| 1772 currentTab.setUseDesktopUserAgent(!usingDesktopUserAgent, reloadOnCh ange); | 1789 currentTab.setUseDesktopUserAgent(!usingDesktopUserAgent, reloadOnCh ange); |
| 1773 RecordUserAction.record("MobileMenuRequestDesktopSite"); | 1790 RecordUserAction.record("MobileMenuRequestDesktopSite"); |
| 1774 } else if (id == R.id.reader_mode_prefs_id) { | 1791 } else if (id == R.id.reader_mode_prefs_id) { |
| 1775 if (currentTab.getWebContents() != null) { | 1792 if (currentTab.getWebContents() != null) { |
| 1776 RecordUserAction.record("DomDistiller_DistilledPagePrefsOpened") ; | 1793 RecordUserAction.record("DomDistiller_DistilledPagePrefsOpened") ; |
| 1777 AlertDialog.Builder builder = | 1794 AlertDialog.Builder builder = |
| 1778 new AlertDialog.Builder(this, R.style.AlertDialogTheme); | 1795 new AlertDialog.Builder(this, R.style.AlertDialogTheme); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2010 "Android.MultiWindowMode.IsTabletScreenWidthBelow600", | 2027 "Android.MultiWindowMode.IsTabletScreenWidthBelow600", |
| 2011 mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP); | 2028 mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP); |
| 2012 | 2029 |
| 2013 if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) { | 2030 if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) { |
| 2014 RecordHistogram.recordLinearCountHistogram( | 2031 RecordHistogram.recordLinearCountHistogram( |
| 2015 "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1, | 2032 "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1, |
| 2016 DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50); | 2033 DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50); |
| 2017 } | 2034 } |
| 2018 } | 2035 } |
| 2019 } | 2036 } |
| OLD | NEW |