| 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 #include "chrome/browser/push_messaging/push_messaging_notification_manager.h" | 5 #include "chrome/browser/push_messaging/push_messaging_notification_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <bitset> | 9 #include <bitset> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "content/public/browser/render_frame_host.h" | 29 #include "content/public/browser/render_frame_host.h" |
| 30 #include "content/public/browser/storage_partition.h" | 30 #include "content/public/browser/storage_partition.h" |
| 31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 32 #include "content/public/common/notification_resources.h" | 32 #include "content/public/common/notification_resources.h" |
| 33 #include "content/public/common/url_constants.h" | 33 #include "content/public/common/url_constants.h" |
| 34 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 34 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 35 #include "third_party/WebKit/public/platform/modules/budget_service/budget_servi
ce.mojom.h" | 35 #include "third_party/WebKit/public/platform/modules/budget_service/budget_servi
ce.mojom.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "url/gurl.h" | 37 #include "url/gurl.h" |
| 38 | 38 |
| 39 #if BUILDFLAG(ANDROID_JAVA_UI) | 39 #if defined(OS_ANDROID) |
| 40 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 40 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
| 41 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 41 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| 42 #else | 42 #else |
| 43 #include "chrome/browser/ui/browser.h" | 43 #include "chrome/browser/ui/browser.h" |
| 44 #include "chrome/browser/ui/browser_list.h" | 44 #include "chrome/browser/ui/browser_list.h" |
| 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 using content::BrowserThread; | 48 using content::BrowserThread; |
| 49 using content::NotificationDatabaseData; | 49 using content::NotificationDatabaseData; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 141 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 142 // TODO(johnme): Hiding an existing notification should also count as a useful | 142 // TODO(johnme): Hiding an existing notification should also count as a useful |
| 143 // user-visible action done in response to a push message - but make sure that | 143 // user-visible action done in response to a push message - but make sure that |
| 144 // sending two messages in rapid succession which show then hide a | 144 // sending two messages in rapid succession which show then hide a |
| 145 // notification doesn't count. | 145 // notification doesn't count. |
| 146 int notification_count = success ? data.size() : 0; | 146 int notification_count = success ? data.size() : 0; |
| 147 bool notification_shown = notification_count > 0; | 147 bool notification_shown = notification_count > 0; |
| 148 bool notification_needed = true; | 148 bool notification_needed = true; |
| 149 | 149 |
| 150 // Sites with a currently visible tab don't need to show notifications. | 150 // Sites with a currently visible tab don't need to show notifications. |
| 151 #if BUILDFLAG(ANDROID_JAVA_UI) | 151 #if defined(OS_ANDROID) |
| 152 for (auto it = TabModelList::begin(); it != TabModelList::end(); ++it) { | 152 for (auto it = TabModelList::begin(); it != TabModelList::end(); ++it) { |
| 153 Profile* profile = (*it)->GetProfile(); | 153 Profile* profile = (*it)->GetProfile(); |
| 154 WebContents* active_web_contents = (*it)->GetActiveWebContents(); | 154 WebContents* active_web_contents = (*it)->GetActiveWebContents(); |
| 155 #else | 155 #else |
| 156 for (auto* browser : *BrowserList::GetInstance()) { | 156 for (auto* browser : *BrowserList::GetInstance()) { |
| 157 Profile* profile = browser->profile(); | 157 Profile* profile = browser->profile(); |
| 158 WebContents* active_web_contents = | 158 WebContents* active_web_contents = |
| 159 browser->tab_strip_model()->GetActiveWebContents(); | 159 browser->tab_strip_model()->GetActiveWebContents(); |
| 160 #endif | 160 #endif |
| 161 if (IsTabVisible(profile, active_web_contents, origin)) { | 161 if (IsTabVisible(profile, active_web_contents, origin)) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // Do not pass service worker scope. The origin will be used instead of the | 318 // Do not pass service worker scope. The origin will be used instead of the |
| 319 // service worker scope to determine whether a notification should be | 319 // service worker scope to determine whether a notification should be |
| 320 // attributed to a WebAPK on Android. This is OK because this code path is hit | 320 // attributed to a WebAPK on Android. This is OK because this code path is hit |
| 321 // rarely. | 321 // rarely. |
| 322 PlatformNotificationServiceImpl::GetInstance()->DisplayPersistentNotification( | 322 PlatformNotificationServiceImpl::GetInstance()->DisplayPersistentNotification( |
| 323 profile_, notification_id, GURL() /* service_worker_scope */, origin, | 323 profile_, notification_id, GURL() /* service_worker_scope */, origin, |
| 324 notification_data, NotificationResources()); | 324 notification_data, NotificationResources()); |
| 325 | 325 |
| 326 message_handled_closure.Run(); | 326 message_handled_closure.Run(); |
| 327 } | 327 } |
| OLD | NEW |