OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_notification_manager.h" | 5 #include "chrome/browser/notifications/message_center_notification_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "chrome/browser/chrome_notification_types.h" | |
13 #include "chrome/browser/extensions/api/notification_provider/notification_provi
der_api.h" | 12 #include "chrome/browser/extensions/api/notification_provider/notification_provi
der_api.h" |
14 #include "chrome/browser/notifications/desktop_notification_service.h" | 13 #include "chrome/browser/notifications/desktop_notification_service.h" |
15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 14 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
16 #include "chrome/browser/notifications/extension_welcome_notification.h" | 15 #include "chrome/browser/notifications/extension_welcome_notification.h" |
17 #include "chrome/browser/notifications/extension_welcome_notification_factory.h" | 16 #include "chrome/browser/notifications/extension_welcome_notification_factory.h" |
18 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" | 17 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" |
19 #include "chrome/browser/notifications/message_center_settings_controller.h" | 18 #include "chrome/browser/notifications/message_center_settings_controller.h" |
20 #include "chrome/browser/notifications/notification.h" | 19 #include "chrome/browser/notifications/notification.h" |
21 #include "chrome/browser/notifications/notification_conversion_helper.h" | 20 #include "chrome/browser/notifications/notification_conversion_helper.h" |
22 #include "chrome/browser/notifications/screen_lock_notification_blocker.h" | 21 #include "chrome/browser/notifications/screen_lock_notification_blocker.h" |
23 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/browser_finder.h" | |
25 #include "chrome/browser/ui/chrome_pages.h" | |
26 #include "chrome/browser/ui/host_desktop.h" | |
27 #include "chrome/common/extensions/api/notification_provider.h" | 23 #include "chrome/common/extensions/api/notification_provider.h" |
28 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
29 #include "content/public/browser/notification_service.h" | |
30 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
31 #include "content/public/common/url_constants.h" | 26 #include "content/public/common/url_constants.h" |
32 #include "extensions/browser/extension_registry.h" | 27 #include "extensions/browser/extension_registry.h" |
33 #include "extensions/browser/extension_system.h" | |
34 #include "extensions/browser/info_map.h" | |
35 #include "extensions/common/extension_set.h" | 28 #include "extensions/common/extension_set.h" |
36 #include "extensions/common/permissions/permissions_data.h" | 29 #include "extensions/common/permissions/permissions_data.h" |
37 #include "ui/gfx/image/image_skia.h" | 30 #include "ui/gfx/image/image_skia.h" |
38 #include "ui/message_center/message_center_style.h" | 31 #include "ui/message_center/message_center_style.h" |
39 #include "ui/message_center/message_center_tray.h" | 32 #include "ui/message_center/message_center_tray.h" |
40 #include "ui/message_center/message_center_types.h" | 33 #include "ui/message_center/message_center_types.h" |
41 #include "ui/message_center/notifier_settings.h" | 34 #include "ui/message_center/notifier_settings.h" |
42 | 35 |
43 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
44 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos
.h" | 37 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos
.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 blockers_.push_back(new ScreenLockNotificationBlocker(message_center)); | 80 blockers_.push_back(new ScreenLockNotificationBlocker(message_center)); |
88 #endif | 81 #endif |
89 blockers_.push_back(new FullscreenNotificationBlocker(message_center)); | 82 blockers_.push_back(new FullscreenNotificationBlocker(message_center)); |
90 | 83 |
91 #if defined(OS_WIN) || defined(OS_MACOSX) \ | 84 #if defined(OS_WIN) || defined(OS_MACOSX) \ |
92 || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | 85 || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
93 // On Windows, Linux and Mac, the notification manager owns the tray icon and | 86 // On Windows, Linux and Mac, the notification manager owns the tray icon and |
94 // views.Other platforms have global ownership and Create will return NULL. | 87 // views.Other platforms have global ownership and Create will return NULL. |
95 tray_.reset(message_center::CreateMessageCenterTray()); | 88 tray_.reset(message_center::CreateMessageCenterTray()); |
96 #endif | 89 #endif |
97 registrar_.Add(this, | |
98 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
99 content::NotificationService::AllSources()); | |
100 } | 90 } |
101 | 91 |
102 MessageCenterNotificationManager::~MessageCenterNotificationManager() { | 92 MessageCenterNotificationManager::~MessageCenterNotificationManager() { |
103 message_center_->SetNotifierSettingsProvider(NULL); | 93 message_center_->SetNotifierSettingsProvider(NULL); |
104 message_center_->RemoveObserver(this); | 94 message_center_->RemoveObserver(this); |
105 | 95 |
106 STLDeleteContainerPairSecondPointers(profile_notifications_.begin(), | 96 STLDeleteContainerPairSecondPointers(profile_notifications_.begin(), |
107 profile_notifications_.end()); | 97 profile_notifications_.end()); |
108 profile_notifications_.clear(); | 98 profile_notifications_.clear(); |
109 } | 99 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 tray->GetMessageCenterTray()->HideMessageCenterBubble(); | 308 tray->GetMessageCenterTray()->HideMessageCenterBubble(); |
319 } | 309 } |
320 #endif | 310 #endif |
321 } | 311 } |
322 | 312 |
323 void MessageCenterNotificationManager::SetMessageCenterTrayDelegateForTest( | 313 void MessageCenterNotificationManager::SetMessageCenterTrayDelegateForTest( |
324 message_center::MessageCenterTrayDelegate* delegate) { | 314 message_center::MessageCenterTrayDelegate* delegate) { |
325 tray_.reset(delegate); | 315 tray_.reset(delegate); |
326 } | 316 } |
327 | 317 |
328 void MessageCenterNotificationManager::Observe( | |
329 int type, | |
330 const content::NotificationSource& source, | |
331 const content::NotificationDetails& details) { | |
332 if (type == chrome::NOTIFICATION_FULLSCREEN_CHANGED) { | |
333 const bool is_fullscreen = *content::Details<bool>(details).ptr(); | |
334 | |
335 if (is_fullscreen && tray_.get() && tray_->GetMessageCenterTray()) | |
336 tray_->GetMessageCenterTray()->HidePopupBubble(); | |
337 } | |
338 } | |
339 | |
340 //////////////////////////////////////////////////////////////////////////////// | 318 //////////////////////////////////////////////////////////////////////////////// |
341 // ImageDownloads | 319 // ImageDownloads |
342 | 320 |
343 MessageCenterNotificationManager::ImageDownloads::ImageDownloads( | 321 MessageCenterNotificationManager::ImageDownloads::ImageDownloads( |
344 message_center::MessageCenter* message_center, | 322 message_center::MessageCenter* message_center, |
345 ImageDownloadsObserver* observer) | 323 ImageDownloadsObserver* observer) |
346 : message_center_(message_center), | 324 : message_center_(message_center), |
347 pending_downloads_(0), | 325 pending_downloads_(0), |
348 observer_(observer) { | 326 observer_(observer) { |
349 } | 327 } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 it != registry->enabled_extensions().end(); | 520 it != registry->enabled_extensions().end(); |
543 ++it) { | 521 ++it) { |
544 if ((*it->get()).permissions_data()->HasAPIPermission( | 522 if ((*it->get()).permissions_data()->HasAPIPermission( |
545 extensions::APIPermission::ID::kNotificationProvider)) { | 523 extensions::APIPermission::ID::kNotificationProvider)) { |
546 extension_id = (*it->get()).id(); | 524 extension_id = (*it->get()).id(); |
547 return extension_id; | 525 return extension_id; |
548 } | 526 } |
549 } | 527 } |
550 return extension_id; | 528 return extension_id; |
551 } | 529 } |
OLD | NEW |