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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationService.java

Issue 2351113005: [Reland] Refactor WebappRegistry into a singleton instance. (Closed)
Patch Set: Fix WebappModeTest Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.notifications; 5 package org.chromium.chrome.browser.notifications;
6 6
7 import android.app.IntentService; 7 import android.app.IntentService;
8 import android.content.BroadcastReceiver; 8 import android.content.BroadcastReceiver;
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.Intent; 10 import android.content.Intent;
11 import android.os.StrictMode;
11 import android.util.Log; 12 import android.util.Log;
12 13
13 import org.chromium.base.ThreadUtils; 14 import org.chromium.base.ThreadUtils;
14 import org.chromium.base.annotations.SuppressFBWarnings; 15 import org.chromium.base.annotations.SuppressFBWarnings;
15 import org.chromium.base.library_loader.ProcessInitException; 16 import org.chromium.base.library_loader.ProcessInitException;
16 import org.chromium.chrome.browser.init.ChromeBrowserInitializer; 17 import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
18 import org.chromium.chrome.browser.webapps.WebappRegistry;
17 19
18 /** 20 /**
19 * The Notification service receives intents fired as responses to user actions issued on Android 21 * The Notification service receives intents fired as responses to user actions issued on Android
20 * notifications displayed in the notification tray. 22 * notifications displayed in the notification tray.
21 */ 23 */
22 public class NotificationService extends IntentService { 24 public class NotificationService extends IntentService {
23 private static final String TAG = NotificationService.class.getSimpleName(); 25 private static final String TAG = NotificationService.class.getSimpleName();
24 26
25 /** 27 /**
26 * The class which receives the intents from the Android framework. It initi alizes the 28 * The class which receives the intents from the Android framework. It initi alizes the
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 * Initializes Chrome and starts the browser process if it's not running as of yet, and 71 * Initializes Chrome and starts the browser process if it's not running as of yet, and
70 * dispatch |intent| to the NotificationPlatformBridge once this is done. 72 * dispatch |intent| to the NotificationPlatformBridge once this is done.
71 * 73 *
72 * @param intent The intent containing the notification's information. 74 * @param intent The intent containing the notification's information.
73 */ 75 */
74 @SuppressFBWarnings("DM_EXIT") 76 @SuppressFBWarnings("DM_EXIT")
75 private void dispatchIntentOnUIThread(Intent intent) { 77 private void dispatchIntentOnUIThread(Intent intent) {
76 try { 78 try {
77 ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup( ); 79 ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup( );
78 80
81 // Warm up the WebappRegistry and all web app SharedPreferences, as we will need check
gone 2016/09/29 21:06:44 need to check
dominickn 2016/09/30 00:17:01 Done.
82 // if this notification should launch a standalone web app. This no- ops if the registry
83 // is already initialized, but triggers a strict mode violation othe rwise (i.e. the
84 // browser isn't running). Temporarily disable strict mode to work a round the violation.
85 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads( );
86 try {
87 WebappRegistry.warmUpSharedPrefs("");
88 } finally {
89 StrictMode.setThreadPolicy(oldPolicy);
90 }
91
79 // Now that the browser process is initialized, we pass forward the call to the 92 // Now that the browser process is initialized, we pass forward the call to the
80 // NotificationPlatformBridge which will take care of delivering the appropriate events. 93 // NotificationPlatformBridge which will take care of delivering the appropriate events.
81 if (!NotificationPlatformBridge.dispatchNotificationEvent(intent)) { 94 if (!NotificationPlatformBridge.dispatchNotificationEvent(intent)) {
82 Log.w(TAG, "Unable to dispatch the notification event to Chrome. "); 95 Log.w(TAG, "Unable to dispatch the notification event to Chrome. ");
83 } 96 }
84 97
85 // TODO(peter): Verify that the lifetime of the NotificationService is sufficient 98 // TODO(peter): Verify that the lifetime of the NotificationService is sufficient
86 // when a notification event could be dispatched successfully. 99 // when a notification event could be dispatched successfully.
87 100
88 } catch (ProcessInitException e) { 101 } catch (ProcessInitException e) {
89 Log.e(TAG, "Unable to start the browser process.", e); 102 Log.e(TAG, "Unable to start the browser process.", e);
90 System.exit(-1); 103 System.exit(-1);
91 } 104 }
92 } 105 }
93 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698