From 98d5fce7c687cfcc956b10d44946d31f39b6dc15 Mon Sep 17 00:00:00 2001 From: "Shimeng (Simon) Wang" Date: Tue, 16 Mar 2010 13:23:39 -0700 Subject: [PATCH] Remove the logic of setting dasher account's home page. Bug:2300219 Change-Id: Ibe790a7aaa812b5262c53f542539deead628dc77 --- AndroidManifest.xml | 2 - src/com/android/browser/BrowserActivity.java | 164 +-------------------------- src/com/android/browser/BrowserSettings.java | 15 --- 3 files changed, 2 insertions(+), 179 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e3e64d4..798fc3a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -20,8 +20,6 @@ - - diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 4a4e325..55e5177 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -135,8 +135,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class BrowserActivity extends Activity - implements View.OnCreateContextMenuListener, DownloadListener, - AccountManagerCallback { + implements View.OnCreateContextMenuListener, DownloadListener { /* Define some aliases to make these debugging flags easier to refer to. * This file imports android.provider.Browser, so we can't just refer to "Browser.DEBUG". @@ -152,81 +151,6 @@ public class BrowserActivity extends Activity private static final int SHORTCUT_DICTIONARY_SEARCH = 3; private static final int SHORTCUT_GOOGLE_MOBILE_LOCAL_SEARCH = 4; - private Account[] mAccountsGoogle; - private Account[] mAccountsPreferHosted; - - // XXX: These constants should be exposed through some public api. Hardcode - // the values for now until some solution for gsf can be worked out. - // http://b/issue?id=2425179 - private static final String ACCOUNT_TYPE = "com.google"; - private static final String FEATURE_LEGACY_GOOGLE = "legacy_google"; - private static final String FEATURE_LEGACY_HOSTED_OR_GOOGLE = - "legacy_hosted_or_google"; - - private void startReadOfGoogleAccounts() { - mAccountsGoogle = null; - mAccountsPreferHosted = null; - - AccountManager.get(this).getAccountsByTypeAndFeatures( - ACCOUNT_TYPE, new String[]{ FEATURE_LEGACY_HOSTED_OR_GOOGLE }, - this, null); - } - - /** This implements AccountManagerCallback */ - public void run(AccountManagerFuture accountManagerFuture) { - try { - if (mAccountsGoogle == null) { - mAccountsGoogle = accountManagerFuture.getResult(); - - AccountManager.get(this).getAccountsByTypeAndFeatures( - ACCOUNT_TYPE, new String[]{ FEATURE_LEGACY_GOOGLE }, - this, null); - } else { - mAccountsPreferHosted = accountManagerFuture.getResult(); - setupHomePage(); - } - } catch (OperationCanceledException e) { - setupHomePage(); - } catch (IOException e) { - setupHomePage(); - } catch (AuthenticatorException e) { - setupHomePage(); - } - } - - private void setupHomePage() { - // get the default home page - String homepage = mSettings.getHomePage(); - - if (mAccountsPreferHosted != null && mAccountsGoogle != null) { - // three cases: - // - // hostedUser == googleUser - // The device has only a google account - // - // hostedUser != googleUser - // The device has a hosted account and a google account - // - // hostedUser != null, googleUser == null - // The device has only a hosted account (so far) - String hostedUser = mAccountsPreferHosted.length == 0 - ? null - : mAccountsPreferHosted[0].name; - String googleUser = mAccountsGoogle.length == 0 ? null : mAccountsGoogle[0].name; - - // developers might have no accounts at all - if (hostedUser == null) return; - - if (googleUser == null || !hostedUser.equals(googleUser)) { - String domain = hostedUser.substring(hostedUser.lastIndexOf('@')+1); - homepage = homepage.replace("?", "/a/" + domain + "?"); - } - } - - mSettings.setHomePage(BrowserActivity.this, homepage); - resumeAfterCredentials(); - } - private static class ClearThumbnails extends AsyncTask { @Override public Void doInBackground(File... files) { @@ -420,21 +344,9 @@ public class BrowserActivity extends Activity webView.setInitialScale(scale); } } - // If we are not restoring from an icicle, then there is a high - // likely hood this is the first run. So, check to see if the - // homepage needs to be configured and copy any plugins from our - // asset directory to the data partition. - if ((extra == null || !extra.getBoolean("testing")) - && !mSettings.isLoginInitialized()) { - startReadOfGoogleAccounts(); - } if (urlData.isEmpty()) { - if (mSettings.isLoginInitialized()) { - loadUrl(webView, mSettings.getHomePage()); - } else { - waitForCredentials(); - } + loadUrl(webView, mSettings.getHomePage()); } else { loadUrlDataIn(t, urlData); } @@ -821,13 +733,6 @@ public class BrowserActivity extends Activity mWakeLock.release(); } - if (mCredsDlg != null) { - if (!mHandler.hasMessages(CANCEL_CREDS_REQUEST)) { - // In case credential request never comes back - mHandler.sendEmptyMessageDelayed(CANCEL_CREDS_REQUEST, 6000); - } - } - registerReceiver(mNetworkStateIntentReceiver, mNetworkStateChangedFilter); WebView.enablePlatformNotifications(); @@ -1072,12 +977,6 @@ public class BrowserActivity extends Activity .obtainMessage(RELEASE_WAKELOCK), WAKELOCK_TIMEOUT); } - // Clear the credentials toast if it is up - if (mCredsDlg != null && mCredsDlg.isShowing()) { - mCredsDlg.dismiss(); - } - mCredsDlg = null; - // FIXME: This removes the active tabs page and resets the menu to // MAIN_MENU. A better solution might be to do this work in onNewIntent // but then we would need to save it in onSaveInstanceState and restore @@ -1198,57 +1097,6 @@ public class BrowserActivity extends Activity } } - // FIXME: Do we want to call this when loading google for the first time? - /* - * This function is called when we are launching for the first time. We - * are waiting for the login credentials before loading Google home - * pages. This way the user will be logged in straight away. - */ - private void waitForCredentials() { - // Show a toast - mCredsDlg = new ProgressDialog(this); - mCredsDlg.setIndeterminate(true); - mCredsDlg.setMessage(getText(R.string.retrieving_creds_dlg_msg)); - // If the user cancels the operation, then cancel the Google - // Credentials request. - mCredsDlg.setCancelMessage(mHandler.obtainMessage(CANCEL_CREDS_REQUEST)); - mCredsDlg.show(); - - // We set a timeout for the retrieval of credentials in onResume() - // as that is when we have freed up some CPU time to get - // the login credentials. - } - - /* - * If we have received the credentials or we have timed out and we are - * showing the credentials dialog, then it is time to move on. - */ - private void resumeAfterCredentials() { - if (mCredsDlg == null) { - return; - } - - // Clear the toast - if (mCredsDlg.isShowing()) { - mCredsDlg.dismiss(); - } - mCredsDlg = null; - - // Clear any pending timeout - mHandler.removeMessages(CANCEL_CREDS_REQUEST); - - // Load the page - WebView w = mTabControl.getCurrentWebView(); - if (w != null) { - loadUrl(w, mSettings.getHomePage()); - } - - // Update the settings, need to do this last as it can take a moment - // to persist the settings. In the mean time we could be loading - // content. - mSettings.setLoginInitialized(this); - } - // Open the icon database and retain all the icons for visited sites. private void retainIconsOnStartup() { final WebIconDatabase db = WebIconDatabase.getInstance(); @@ -2351,7 +2199,6 @@ public class BrowserActivity extends Activity // Message Ids private static final int FOCUS_NODE_HREF = 102; - private static final int CANCEL_CREDS_REQUEST = 103; private static final int RELEASE_WAKELOCK = 107; static final int UPDATE_BOOKMARK_THUMBNAIL = 108; @@ -2449,10 +2296,6 @@ public class BrowserActivity extends Activity stopLoading(); break; - case CANCEL_CREDS_REQUEST: - resumeAfterCredentials(); - break; - case RELEASE_WAKELOCK: if (mWakeLock.isHeld()) { mWakeLock.release(); @@ -3978,9 +3821,6 @@ public class BrowserActivity extends Activity /* hold a ref so we can auto-cancel if necessary */ private AlertDialog mAlertDialog; - // Wait for credentials before loading google.com - private ProgressDialog mCredsDlg; - // The up-to-date URL and title (these can be different from those stored // in WebView, since it takes some time for the information in WebView to // get updated) diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index 1c534a2..6b05dcd 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -71,7 +71,6 @@ class BrowserSettings extends Observable { private boolean openInBackground; private String defaultTextEncodingName; private String homeUrl = ""; - private boolean loginInitialized; private boolean autoFitPage; private boolean landscapeOnly; private boolean loadsPageInOverviewMode; @@ -297,7 +296,6 @@ class BrowserSettings extends Observable { CookieManager.getInstance().acceptCookie()); CookieManager.getInstance().setAcceptCookie(accept_cookies); openInBackground = p.getBoolean("open_in_background", openInBackground); - loginInitialized = p.getBoolean("login_initialized", loginInitialized); textSize = WebSettings.TextSize.valueOf( p.getString(PREF_TEXT_SIZE, textSize.name())); zoomDensity = WebSettings.ZoomDensity.valueOf( @@ -386,18 +384,6 @@ class BrowserSettings extends Observable { homeUrl = url; } - public boolean isLoginInitialized() { - return loginInitialized; - } - - public void setLoginInitialized(Context context) { - loginInitialized = true; - Editor ed = PreferenceManager. - getDefaultSharedPreferences(context).edit(); - ed.putBoolean("login_initialized", loginInitialized); - ed.commit(); - } - public WebSettings.TextSize getTextSize() { return textSize; } @@ -607,7 +593,6 @@ class BrowserSettings extends Observable { rememberPasswords = true; saveFormData = true; openInBackground = false; - loginInitialized = false; autoFitPage = true; landscapeOnly = false; loadsPageInOverviewMode = true; -- 2.11.0