OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.app.AlarmManager; | 7 import android.app.AlarmManager; |
8 import android.app.Notification; | 8 import android.app.Notification; |
9 import android.app.NotificationManager; | 9 import android.app.NotificationManager; |
10 import android.app.PendingIntent; | 10 import android.app.PendingIntent; |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 // This is useful for tracking whether a notification is pressed soon af
ter an update or | 460 // This is useful for tracking whether a notification is pressed soon af
ter an update or |
461 // much later. | 461 // much later. |
462 SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); | 462 SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); |
463 SharedPreferences.Editor editor = prefs.edit(); | 463 SharedPreferences.Editor editor = prefs.edit(); |
464 editor.putLong(PREFS_NOTIFICATION_UPDATE_TIMESTAMP, SystemClock.elapsedR
ealtime()); | 464 editor.putLong(PREFS_NOTIFICATION_UPDATE_TIMESTAMP, SystemClock.elapsedR
ealtime()); |
465 editor.apply(); | 465 editor.apply(); |
466 } | 466 } |
467 | 467 |
468 private void showNotification() { | 468 private void showNotification() { |
469 // We should only show notifications if there's no other notification-ba
sed client. | 469 // We should only show notifications if there's no other notification-ba
sed client. |
470 if (PhysicalWebEnvironment | 470 if (!PhysicalWeb.shouldIgnoreOtherClients() |
471 .getInstance((ChromeApplication) mContext.getApplicationContext(
)) | 471 && PhysicalWebEnvironment |
472 .hasNotificationBasedClient()) { | 472 .getInstance((ChromeApplication) mContext.getApplication
Context()) |
| 473 .hasNotificationBasedClient()) { |
473 return; | 474 return; |
474 } | 475 } |
475 | 476 |
476 if (PhysicalWeb.isOnboarding(mContext)) { | 477 if (PhysicalWeb.isOnboarding(mContext)) { |
477 if (PhysicalWeb.getOptInNotifyCount(mContext) < PhysicalWeb.OPTIN_NO
TIFY_MAX_TRIES) { | 478 if (PhysicalWeb.getOptInNotifyCount(mContext) < PhysicalWeb.OPTIN_NO
TIFY_MAX_TRIES) { |
478 // high priority notification | 479 // high priority notification |
479 createOptInNotification(true); | 480 createOptInNotification(true); |
480 PhysicalWeb.recordOptInNotification(mContext); | 481 PhysicalWeb.recordOptInNotification(mContext); |
481 PhysicalWebUma.onOptInHighPriorityNotificationShown(mContext); | 482 PhysicalWebUma.onOptInHighPriorityNotificationShown(mContext); |
482 } else { | 483 } else { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 || mResolvedUrls.contains(url) | 635 || mResolvedUrls.contains(url) |
635 || mUrlInfoMap.containsKey(url) | 636 || mUrlInfoMap.containsKey(url) |
636 || mUrlsSortedByTimestamp.contains(url); | 637 || mUrlsSortedByTimestamp.contains(url); |
637 } | 638 } |
638 | 639 |
639 @VisibleForTesting | 640 @VisibleForTesting |
640 int getMaxCacheSize() { | 641 int getMaxCacheSize() { |
641 return MAX_CACHE_SIZE; | 642 return MAX_CACHE_SIZE; |
642 } | 643 } |
643 } | 644 } |
OLD | NEW |