| 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_util.h" | |
| 18 #include "chrome/browser/favicon/favicon_service.h" | 17 #include "chrome/browser/favicon/favicon_service.h" |
| 19 #include "chrome/browser/favicon/favicon_service_factory.h" | 18 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 20 #include "chrome/browser/history/history_types.h" | 19 #include "chrome/browser/history/history_types.h" |
| 21 #include "chrome/browser/notifications/desktop_notification_service.h" | 20 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 22 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 21 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 23 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" | 22 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" |
| 24 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" | 23 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/profiles/profile_info_cache.h" | 25 #include "chrome/browser/profiles/profile_info_cache.h" |
| 27 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 28 #include "chrome/common/extensions/api/notifications.h" | 27 #include "chrome/common/extensions/api/notifications.h" |
| 29 #include "chrome/common/extensions/extension_constants.h" | 28 #include "chrome/common/extensions/extension_constants.h" |
| 30 #include "components/favicon_base/favicon_types.h" | 29 #include "components/favicon_base/favicon_types.h" |
| 31 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/notification_source.h" | 31 #include "content/public/browser/notification_source.h" |
| 33 #include "extensions/browser/event_router.h" | 32 #include "extensions/browser/event_router.h" |
| 34 #include "extensions/browser/extension_registry.h" | 33 #include "extensions/browser/extension_registry.h" |
| 35 #include "extensions/browser/extension_util.h" | |
| 36 #include "extensions/common/constants.h" | 34 #include "extensions/common/constants.h" |
| 37 #include "extensions/common/extension.h" | 35 #include "extensions/common/extension.h" |
| 38 #include "extensions/common/permissions/permissions_data.h" | 36 #include "extensions/common/permissions/permissions_data.h" |
| 39 #include "grit/theme_resources.h" | 37 #include "grit/theme_resources.h" |
| 40 #include "grit/ui_strings.h" | 38 #include "grit/ui_strings.h" |
| 41 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 42 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
| 43 #include "ui/gfx/image/image.h" | 41 #include "ui/gfx/image/image.h" |
| 44 #include "ui/message_center/message_center_style.h" | 42 #include "ui/message_center/message_center_style.h" |
| 45 | 43 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 profile, extension_misc::EXTENSION_ICON_SMALL, this)); | 223 profile, extension_misc::EXTENSION_ICON_SMALL, this)); |
| 226 for (extensions::ExtensionSet::const_iterator iter = extension_set.begin(); | 224 for (extensions::ExtensionSet::const_iterator iter = extension_set.begin(); |
| 227 iter != extension_set.end(); | 225 iter != extension_set.end(); |
| 228 ++iter) { | 226 ++iter) { |
| 229 const extensions::Extension* extension = iter->get(); | 227 const extensions::Extension* extension = iter->get(); |
| 230 if (!extension->permissions_data()->HasAPIPermission( | 228 if (!extension->permissions_data()->HasAPIPermission( |
| 231 extensions::APIPermission::kNotification)) { | 229 extensions::APIPermission::kNotification)) { |
| 232 continue; | 230 continue; |
| 233 } | 231 } |
| 234 | 232 |
| 235 // Exclude cached ephemeral apps that are not currently running. | |
| 236 if (extensions::util::IsEphemeralApp(extension->id(), profile) && | |
| 237 extensions::util::IsExtensionIdle(extension->id(), profile)) { | |
| 238 continue; | |
| 239 } | |
| 240 | |
| 241 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); | 233 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); |
| 242 notifiers->push_back(new Notifier( | 234 notifiers->push_back(new Notifier( |
| 243 notifier_id, | 235 notifier_id, |
| 244 base::UTF8ToUTF16(extension->name()), | 236 base::UTF8ToUTF16(extension->name()), |
| 245 notification_service->IsNotifierEnabled(notifier_id))); | 237 notification_service->IsNotifierEnabled(notifier_id))); |
| 246 app_icon_loader_->FetchImage(extension->id()); | 238 app_icon_loader_->FetchImage(extension->id()); |
| 247 } | 239 } |
| 248 | 240 |
| 249 if (notifier::ChromeNotifierServiceFactory::UseSyncedNotifications( | 241 if (notifier::ChromeNotifierServiceFactory::UseSyncedNotifications( |
| 250 CommandLine::ForCurrentProcess())) { | 242 CommandLine::ForCurrentProcess())) { |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 // creating a primary profile, and causes an infinite loop. | 536 // creating a primary profile, and causes an infinite loop. |
| 545 // Thus, it would be better to delay creating group for guest login. | 537 // Thus, it would be better to delay creating group for guest login. |
| 546 base::MessageLoopProxy::current()->PostTask( | 538 base::MessageLoopProxy::current()->PostTask( |
| 547 FROM_HERE, | 539 FROM_HERE, |
| 548 base::Bind( | 540 base::Bind( |
| 549 &MessageCenterSettingsController::CreateNotifierGroupForGuestLogin, | 541 &MessageCenterSettingsController::CreateNotifierGroupForGuestLogin, |
| 550 weak_factory_.GetWeakPtr())); | 542 weak_factory_.GetWeakPtr())); |
| 551 } | 543 } |
| 552 #endif | 544 #endif |
| 553 } | 545 } |
| OLD | NEW |