 Chromium Code Reviews
 Chromium Code Reviews Issue 456223002:
  Add NotifyOnShowSettings implementation of notification provider API  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 456223002:
  Add NotifyOnShowSettings implementation of notification provider API  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/notification_provider/notification_provi der_api.h" | 5 #include "chrome/browser/extensions/api/notification_provider/notification_provi der_api.h" | 
| 6 | 6 | 
| 7 #include "base/callback.h" | 7 #include "base/callback.h" | 
| 8 #include "base/guid.h" | 8 #include "base/guid.h" | 
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" | 
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" | 
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" | 
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" | 
| 13 #include "chrome/browser/notifications/notification.h" | 13 #include "chrome/browser/notifications/notification.h" | 
| 14 #include "chrome/browser/notifications/notification_ui_manager.h" | 14 #include "chrome/browser/notifications/notification_ui_manager.h" | 
| 15 #include "chrome/common/chrome_version_info.h" | 15 #include "chrome/common/chrome_version_info.h" | 
| 16 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" | 
| 17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" | 
| 18 #include "extensions/common/features/feature.h" | 18 #include "extensions/common/features/feature.h" | 
| 19 #include "ui/base/layout.h" | 19 #include "ui/base/layout.h" | 
| 20 #include "ui/message_center/message_center.h" | |
| 21 #include "ui/message_center/notifier_settings.h" | |
| 20 #include "url/gurl.h" | 22 #include "url/gurl.h" | 
| 21 | 23 | 
| 22 namespace extensions { | 24 namespace extensions { | 
| 23 | 25 | 
| 24 NotificationProviderEventRouter::NotificationProviderEventRouter( | 26 NotificationProviderEventRouter::NotificationProviderEventRouter( | 
| 25 Profile* profile) | 27 Profile* profile) | 
| 26 : profile_(profile) { | 28 : profile_(profile) { | 
| 27 } | 29 } | 
| 28 | 30 | 
| 29 NotificationProviderEventRouter::~NotificationProviderEventRouter() { | 31 NotificationProviderEventRouter::~NotificationProviderEventRouter() { | 
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 NotificationProviderNotifyOnShowSettingsFunction:: | 208 NotificationProviderNotifyOnShowSettingsFunction:: | 
| 207 ~NotificationProviderNotifyOnShowSettingsFunction() { | 209 ~NotificationProviderNotifyOnShowSettingsFunction() { | 
| 208 } | 210 } | 
| 209 | 211 | 
| 210 ExtensionFunction::ResponseAction | 212 ExtensionFunction::ResponseAction | 
| 211 NotificationProviderNotifyOnShowSettingsFunction::Run() { | 213 NotificationProviderNotifyOnShowSettingsFunction::Run() { | 
| 212 scoped_ptr<api::notification_provider::NotifyOnShowSettings::Params> params = | 214 scoped_ptr<api::notification_provider::NotifyOnShowSettings::Params> params = | 
| 213 api::notification_provider::NotifyOnShowSettings::Params::Create(*args_); | 215 api::notification_provider::NotifyOnShowSettings::Params::Create(*args_); | 
| 214 EXTENSION_FUNCTION_VALIDATE(params.get()); | 216 EXTENSION_FUNCTION_VALIDATE(params.get()); | 
| 215 | 217 | 
| 218 message_center::NotifierSettingsProvider* settings_provider = | |
| 219 message_center::MessageCenter::Get()->GetNotifierSettingsProvider(); | |
| 
dewittj
2014/08/12 18:21:05
This is better, but it feels like you are skipping
 
liyanhou
2014/08/13 21:06:26
Done.
 | |
| 220 | |
| 221 message_center::NotifierId notifier_id( | |
| 222 message_center::NotifierId::NotifierType::APPLICATION, | |
| 223 params->notifier_id); | |
| 224 | |
| 225 bool has_advanced_settings = | |
| 226 settings_provider->NotifierHasAdvancedSettings(notifier_id); | |
| 227 if (has_advanced_settings) | |
| 228 settings_provider->OnNotifierAdvancedSettingsRequested(notifier_id, NULL); | |
| 216 return RespondNow(ArgumentList( | 229 return RespondNow(ArgumentList( | 
| 217 api::notification_provider::NotifyOnShowSettings::Results::Create(true))); | 230 api::notification_provider::NotifyOnShowSettings::Results::Create( | 
| 231 has_advanced_settings))); | |
| 218 } | 232 } | 
| 219 | 233 | 
| 220 NotificationProviderGetNotifierFunction:: | 234 NotificationProviderGetNotifierFunction:: | 
| 221 NotificationProviderGetNotifierFunction() { | 235 NotificationProviderGetNotifierFunction() { | 
| 222 } | 236 } | 
| 223 | 237 | 
| 224 NotificationProviderGetNotifierFunction:: | 238 NotificationProviderGetNotifierFunction:: | 
| 225 ~NotificationProviderGetNotifierFunction() { | 239 ~NotificationProviderGetNotifierFunction() { | 
| 226 } | 240 } | 
| 227 | 241 | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 243 | 257 | 
| 244 ExtensionFunction::ResponseAction | 258 ExtensionFunction::ResponseAction | 
| 245 NotificationProviderGetAllNotifiersFunction::Run() { | 259 NotificationProviderGetAllNotifiersFunction::Run() { | 
| 246 std::vector<linked_ptr<api::notification_provider::Notifier> > notifiers; | 260 std::vector<linked_ptr<api::notification_provider::Notifier> > notifiers; | 
| 247 | 261 | 
| 248 return RespondNow(ArgumentList( | 262 return RespondNow(ArgumentList( | 
| 249 api::notification_provider::GetAllNotifiers::Results::Create(notifiers))); | 263 api::notification_provider::GetAllNotifiers::Results::Create(notifiers))); | 
| 250 } | 264 } | 
| 251 | 265 | 
| 252 } // namespace extensions | 266 } // namespace extensions | 
| OLD | NEW |