| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/notifications/system_component_notifier_source_chromeos
.h" |
| 6 |
| 7 #include "ash/common/system/system_notifier.h" |
| 8 #include "chrome/browser/notifications/notifier_state_tracker.h" |
| 9 #include "chrome/browser/notifications/notifier_state_tracker_factory.h" |
| 10 #include "grit/theme_resources.h" |
| 11 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/message_center/notifier_settings.h" |
| 14 #include "ui/strings/grit/ui_strings.h" |
| 15 |
| 16 SystemComponentNotifierSourceChromeOS::SystemComponentNotifierSourceChromeOS( |
| 17 Observer* observer) |
| 18 : observer_(observer) {} |
| 19 |
| 20 std::vector<std::unique_ptr<message_center::Notifier>> |
| 21 SystemComponentNotifierSourceChromeOS::GetNotifierList(Profile* profile) { |
| 22 std::vector<std::unique_ptr<message_center::Notifier>> notifiers; |
| 23 NotifierStateTracker* const notifier_state_tracker = |
| 24 NotifierStateTrackerFactory::GetForProfile(profile); |
| 25 |
| 26 // Screenshot notification feature is only for ChromeOS. See |
| 27 // crbug.com/238358 |
| 28 const base::string16& screenshot_name = |
| 29 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_SCREENSHOT_NAME); |
| 30 message_center::NotifierId screenshot_notifier_id( |
| 31 message_center::NotifierId::SYSTEM_COMPONENT, |
| 32 ash::system_notifier::kNotifierScreenshot); |
| 33 message_center::Notifier* const screenshot_notifier = |
| 34 new message_center::Notifier( |
| 35 screenshot_notifier_id, screenshot_name, |
| 36 notifier_state_tracker->IsNotifierEnabled(screenshot_notifier_id)); |
| 37 screenshot_notifier->icon = |
| 38 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 39 IDR_SCREENSHOT_NOTIFICATION_ICON); |
| 40 notifiers.emplace_back(screenshot_notifier); |
| 41 return notifiers; |
| 42 } |
| 43 |
| 44 void SystemComponentNotifierSourceChromeOS::SetNotifierEnabled( |
| 45 Profile* profile, |
| 46 const message_center::Notifier& notifier, |
| 47 bool enabled) { |
| 48 NotifierStateTrackerFactory::GetForProfile(profile)->SetNotifierEnabled( |
| 49 notifier.notifier_id, enabled); |
| 50 observer_->OnNotifierEnabledChanged(notifier.notifier_id, enabled); |
| 51 } |
| 52 |
| 53 message_center::NotifierId::NotifierType |
| 54 SystemComponentNotifierSourceChromeOS::GetNotifierType() { |
| 55 return message_center::NotifierId::SYSTEM_COMPONENT; |
| 56 } |
| OLD | NEW |