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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebBroadcastService.java

Issue 2753683002: Build a Bridge to Eddystone Encoder in Components (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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.physicalweb; 5 package org.chromium.chrome.browser.physicalweb;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.app.Service; 8 import android.app.Service;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.SharedPreferences; 10 import android.content.SharedPreferences;
(...skipping 18 matching lines...) Expand all
29 * service get's restarted it will restart broadcasting as well by gathering the URL from 29 * service get's restarted it will restart broadcasting as well by gathering the URL from
30 * shared preferences. This will create a seemless experience to the user by beh aving as 30 * shared preferences. This will create a seemless experience to the user by beh aving as
31 * though broadcasting is not connected to the Chrome application. 31 * though broadcasting is not connected to the Chrome application.
32 * 32 *
33 * bluetooth.le.AdvertiseCallback and bluetooth.BluetoothAdapter require API lev el 21. 33 * bluetooth.le.AdvertiseCallback and bluetooth.BluetoothAdapter require API lev el 21.
34 * This will only be run on M and above. 34 * This will only be run on M and above.
35 **/ 35 **/
36 36
37 @TargetApi(Build.VERSION_CODES.LOLLIPOP) 37 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
38 public class PhysicalWebBroadcastService extends Service { 38 public class PhysicalWebBroadcastService extends Service {
39 private static final String TAG = "PhysicalWebBService";
mattreynolds 2017/03/14 23:21:12 Remove if unused.
39 public static final String DISPLAY_URL_KEY = "display_url"; 40 public static final String DISPLAY_URL_KEY = "display_url";
40 41
41 public static final String PREVIOUS_BROADCAST_URL_KEY = "previousUrl"; 42 public static final String PREVIOUS_BROADCAST_URL_KEY = "previousUrl";
42 43
43 private boolean mStartedByRestart; 44 private boolean mStartedByRestart;
44 45
45 @Override 46 @Override
46 public int onStartCommand(Intent intent, int flags, int startId) { 47 public int onStartCommand(Intent intent, int flags, int startId) {
47 String displayUrl = fetchDisplayUrl(intent); 48 String displayUrl = fetchDisplayUrl(intent);
48 49
49 // This should never happen. 50 // This should never happen.
50 if (displayUrl == null) { 51 if (displayUrl == null) {
51 stopSelf(); 52 stopSelf();
52 return START_STICKY; 53 return START_STICKY;
53 } 54 }
55 // TODO(iankc): implement shortening, broadcasting, and notifications.
54 56
55 // TODO(iankc): implement parsing, broadcasting, and notifications.
56 stopSelf(); 57 stopSelf();
57 return START_STICKY; 58 return START_STICKY;
58 } 59 }
59 60
60 @Override 61 @Override
61 public IBinder onBind(Intent intent) { 62 public IBinder onBind(Intent intent) {
62 return null; 63 return null;
63 } 64 }
64 65
65 private String fetchDisplayUrl(Intent intent) { 66 private String fetchDisplayUrl(Intent intent) {
66 mStartedByRestart = intent == null; 67 mStartedByRestart = intent == null;
67 if (mStartedByRestart) { 68 if (mStartedByRestart) {
68 SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences (); 69 SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences ();
69 return sharedPrefs.getString(PREVIOUS_BROADCAST_URL_KEY, null); 70 return sharedPrefs.getString(PREVIOUS_BROADCAST_URL_KEY, null);
70 } 71 }
71 72
72 String displayUrl = intent.getStringExtra(DISPLAY_URL_KEY); 73 String displayUrl = intent.getStringExtra(DISPLAY_URL_KEY);
73 ContextUtils.getAppSharedPreferences() 74 ContextUtils.getAppSharedPreferences()
74 .edit() 75 .edit()
75 .putString(PREVIOUS_BROADCAST_URL_KEY, displayUrl) 76 .putString(PREVIOUS_BROADCAST_URL_KEY, displayUrl)
76 .commit(); 77 .commit();
77 return displayUrl; 78 return displayUrl;
78 } 79 }
80
81 private native byte[] nativeEncodeUrl(String url);
79 } 82 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/BUILD.gn » ('j') | chrome/browser/android/physical_web/eddystone_encoder_bridge.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698