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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionFactory.java

Issue 2512123002: Shape Detection: QR detection in Chrome Android using Play Services (Closed)
Patch Set: dcheng@ request to check for |numPixels| overflow Created 4 years 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/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionFactory.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..c3c3e56426e4d65a5ebfaeb158421113aae3404c
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionFactory.java
@@ -0,0 +1,39 @@
+// Copyright 2016 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.shapedetection;
+
+import android.app.Activity;
+
+import org.chromium.blink.mojom.BarcodeDetection;
+import org.chromium.content.browser.ContentViewCore;
+import org.chromium.content_public.browser.WebContents;
+import org.chromium.services.service_manager.InterfaceFactory;
+import org.chromium.ui.base.WindowAndroid;
+
+/**
+ * Factory class registered to create BarcodeDetections upon request.
+ */
+public class BarcodeDetectionFactory implements InterfaceFactory<BarcodeDetection> {
+ private final WebContents mWebContents;
+
+ public BarcodeDetectionFactory(WebContents webContents) {
+ mWebContents = webContents;
+ }
+
+ @Override
+ public BarcodeDetection createImpl() {
+ // Get android.content.Context out of |mWebContents|.
+ final ContentViewCore contentViewCore = ContentViewCore.fromWebContents(mWebContents);
+ if (contentViewCore == null) return null;
+
+ final WindowAndroid window = contentViewCore.getWindowAndroid();
+ if (window == null) return null;
+
+ final Activity context = window.getActivity().get();
+ if (context == null) return null;
+
+ return new BarcodeDetectionImpl(context);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698