Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeBrowserProviderStaging.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeBrowserProviderStaging.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeBrowserProviderStaging.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeBrowserProviderStaging.java
new file mode 100644
index 0000000000000000000000000000000000000000..b3f22f4f645aa863a0b9a06f9f8ee1f1664151ec
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/ChromeBrowserProviderStaging.java
@@ -0,0 +1,82 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser;
+
+import android.Manifest;
+import android.content.pm.PackageManager;
+
+import org.chromium.base.annotations.SuppressFBWarnings;
+import org.chromium.base.library_loader.LibraryProcessType;
+import org.chromium.base.library_loader.ProcessInitException;
+import org.chromium.chrome.browser.externalauth.ExternalAuthUtils;
+import org.chromium.content.app.ContentApplication;
+import org.chromium.content.browser.BrowserStartupController;
+
+/**
+ * App-specific version of ChromeBrowserProvider that deals with app-side initialization,
+ * notifications and operations depending on the sync status.
+ *
+ * TODO(newt): merge with ChromeBrowserProvider after upstreaming.
+ */
+public class ChromeBrowserProviderStaging extends ChromeBrowserProvider {
+
+ @Override
+ public boolean onCreate() {
+ ContentApplication.initCommandLine(getContext());
+
+ BrowserStartupController.get(getContext(), LibraryProcessType.PROCESS_BROWSER)
+ .addStartupCompletedObserver(
+ new BrowserStartupController.StartupCallback() {
+ @Override
+ public void onSuccess(boolean alreadyStarted) {
+ ensureNativeChromeLoadedOnUIThread();
+ }
+
+ @Override
+ public void onFailure() {
+ }
+ });
+
+ return super.onCreate();
+ }
+
+ @SuppressFBWarnings("DM_EXIT")
+ @Override
+ protected boolean ensureNativeChromeLoadedOnUIThread() {
+ if (isNativeSideInitialized()) return true;
+ // Only start the GoogleServicesManager if we were initialized via a call to the browser
+ // provider. If it wasn't, let the Chrome browser worry about sequencing the
+ // initialization.
+ boolean shouldStartGoogleServicesManager = mContentProviderApiCalled;
+ try {
+ ((ChromiumApplication) getContext().getApplicationContext())
+ .startChromeBrowserProcessesSync(shouldStartGoogleServicesManager);
+ } catch (ProcessInitException e) {
+ // Chrome browser runs in the background, so exit silently; but do exit, since
+ // otherwise the next attempt to use Chrome will find a broken JNI.
+ System.exit(-1);
+ }
+ return super.ensureNativeChromeLoadedOnUIThread();
+ }
+
+ @Override
+ protected boolean hasReadAccess() {
+ return hasPermission(Manifest.permission.READ_HISTORY_BOOKMARKS);
+ }
+
+ @Override
+ protected boolean hasWriteAccess() {
+ return hasPermission(Manifest.permission.WRITE_HISTORY_BOOKMARKS);
+ }
+
+ private boolean hasPermission(String permission) {
+ boolean hasPermission = getContext().checkCallingOrSelfPermission(permission)
+ == PackageManager.PERMISSION_GRANTED;
+ boolean isSystemOrGoogleCaller = ExternalAuthUtils.getInstance().isCallerValid(
+ getContext(), ExternalAuthUtils.FLAG_SHOULD_BE_GOOGLE_SIGNED
+ | ExternalAuthUtils.FLAG_SHOULD_BE_SYSTEM);
+ return hasPermission || isSystemOrGoogleCaller;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698