OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/notifications/message_center_settings_controller.h" | 5 #include "chrome/browser/notifications/message_center_settings_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/i18n/string_compare.h" | 10 #include "base/i18n/string_compare.h" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/task/cancelable_task_tracker.h" | 13 #include "base/task/cancelable_task_tracker.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/extensions/app_icon_loader_impl.h" | 16 #include "chrome/browser/extensions/app_icon_loader_impl.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_util.h" |
18 #include "chrome/browser/favicon/favicon_service.h" | 19 #include "chrome/browser/favicon/favicon_service.h" |
19 #include "chrome/browser/favicon/favicon_service_factory.h" | 20 #include "chrome/browser/favicon/favicon_service_factory.h" |
20 #include "chrome/browser/history/history_types.h" | 21 #include "chrome/browser/history/history_types.h" |
21 #include "chrome/browser/notifications/desktop_notification_service.h" | 22 #include "chrome/browser/notifications/desktop_notification_service.h" |
22 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 23 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
23 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" | 24 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" |
24 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" | 25 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" |
25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/profiles/profile_info_cache.h" | 27 #include "chrome/browser/profiles/profile_info_cache.h" |
27 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 profile, extension_misc::EXTENSION_ICON_SMALL, this)); | 223 profile, extension_misc::EXTENSION_ICON_SMALL, this)); |
223 for (extensions::ExtensionSet::const_iterator iter = extension_set->begin(); | 224 for (extensions::ExtensionSet::const_iterator iter = extension_set->begin(); |
224 iter != extension_set->end(); | 225 iter != extension_set->end(); |
225 ++iter) { | 226 ++iter) { |
226 const extensions::Extension* extension = iter->get(); | 227 const extensions::Extension* extension = iter->get(); |
227 if (!extension->HasAPIPermission( | 228 if (!extension->HasAPIPermission( |
228 extensions::APIPermission::kNotification)) { | 229 extensions::APIPermission::kNotification)) { |
229 continue; | 230 continue; |
230 } | 231 } |
231 | 232 |
| 233 // Exclude cached ephemeral apps that are not currently running. |
| 234 if (extension->is_ephemeral() && |
| 235 extensions::util::IsExtensionIdle(extension->id(), profile)) { |
| 236 continue; |
| 237 } |
| 238 |
232 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); | 239 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); |
233 notifiers->push_back(new Notifier( | 240 notifiers->push_back(new Notifier( |
234 notifier_id, | 241 notifier_id, |
235 base::UTF8ToUTF16(extension->name()), | 242 base::UTF8ToUTF16(extension->name()), |
236 notification_service->IsNotifierEnabled(notifier_id))); | 243 notification_service->IsNotifierEnabled(notifier_id))); |
237 app_icon_loader_->FetchImage(extension->id()); | 244 app_icon_loader_->FetchImage(extension->id()); |
238 } | 245 } |
239 | 246 |
240 if (notifier::ChromeNotifierServiceFactory::UseSyncedNotifications( | 247 if (notifier::ChromeNotifierServiceFactory::UseSyncedNotifications( |
241 CommandLine::ForCurrentProcess())) { | 248 CommandLine::ForCurrentProcess())) { |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // creating a primary profile, and causes an infinite loop. | 540 // creating a primary profile, and causes an infinite loop. |
534 // Thus, it would be better to delay creating group for guest login. | 541 // Thus, it would be better to delay creating group for guest login. |
535 base::MessageLoopProxy::current()->PostTask( | 542 base::MessageLoopProxy::current()->PostTask( |
536 FROM_HERE, | 543 FROM_HERE, |
537 base::Bind( | 544 base::Bind( |
538 &MessageCenterSettingsController::CreateNotifierGroupForGuestLogin, | 545 &MessageCenterSettingsController::CreateNotifierGroupForGuestLogin, |
539 weak_factory_.GetWeakPtr())); | 546 weak_factory_.GetWeakPtr())); |
540 } | 547 } |
541 #endif | 548 #endif |
542 } | 549 } |
OLD | NEW |