Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/browser/extensions/api/notification_provider/notification_provider_api.cc

Issue 456223002: Add NotifyOnShowSettings implementation of notification provider API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_center_settings_controller.h"
14 #include "chrome/browser/profiles/profile_info_cache.h"
15 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/common/chrome_version_info.h" 16 #include "chrome/common/chrome_version_info.h"
14 #include "extensions/browser/event_router.h" 17 #include "extensions/browser/event_router.h"
18 #include "extensions/browser/extension_system.h"
15 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
16 #include "extensions/common/features/feature.h" 20 #include "extensions/common/features/feature.h"
17 #include "ui/base/layout.h" 21 #include "ui/base/layout.h"
22 #include "ui/message_center/notifier_settings.h"
18 #include "url/gurl.h" 23 #include "url/gurl.h"
19 24
20 namespace extensions { 25 namespace extensions {
21 26
22 NotificationProviderEventRouter::NotificationProviderEventRouter( 27 NotificationProviderEventRouter::NotificationProviderEventRouter(
23 Profile* profile) 28 Profile* profile)
24 : profile_(profile) { 29 : profile_(profile) {
25 } 30 }
26 31
27 NotificationProviderEventRouter::~NotificationProviderEventRouter() { 32 NotificationProviderEventRouter::~NotificationProviderEventRouter() {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 NotificationProviderNotifyOnShowSettingsFunction:: 183 NotificationProviderNotifyOnShowSettingsFunction::
179 ~NotificationProviderNotifyOnShowSettingsFunction() { 184 ~NotificationProviderNotifyOnShowSettingsFunction() {
180 } 185 }
181 186
182 ExtensionFunction::ResponseAction 187 ExtensionFunction::ResponseAction
183 NotificationProviderNotifyOnShowSettingsFunction::Run() { 188 NotificationProviderNotifyOnShowSettingsFunction::Run() {
184 scoped_ptr<api::notification_provider::NotifyOnShowSettings::Params> params = 189 scoped_ptr<api::notification_provider::NotifyOnShowSettings::Params> params =
185 api::notification_provider::NotifyOnShowSettings::Params::Create(*args_); 190 api::notification_provider::NotifyOnShowSettings::Params::Create(*args_);
186 EXTENSION_FUNCTION_VALIDATE(params.get()); 191 EXTENSION_FUNCTION_VALIDATE(params.get());
187 192
193 ProfileInfoCache* profile_info_cache =
194 &g_browser_process->profile_manager()->GetProfileInfoCache();
195
196 scoped_ptr<MessageCenterSettingsController> settings_controller(
197 new MessageCenterSettingsController(profile_info_cache));
dewittj 2014/08/11 21:16:16 I'd rather that you use the settings controller th
liyanhou 2014/08/12 17:15:00 Done.
198
199 message_center::NotifierId notifier_id(
200 message_center::NotifierId::NotifierType::APPLICATION,
201 params->notifier_id);
202
203 bool has_advanced_settings =
204 settings_controller->NotifierHasAdvancedSettings(notifier_id);
205 if (has_advanced_settings)
206 settings_controller->OnNotifierAdvancedSettingsRequested(notifier_id, NULL);
188 return RespondNow(ArgumentList( 207 return RespondNow(ArgumentList(
189 api::notification_provider::NotifyOnShowSettings::Results::Create(true))); 208 api::notification_provider::NotifyOnShowSettings::Results::Create(
209 has_advanced_settings)));
190 } 210 }
191 211
192 NotificationProviderGetNotifierFunction:: 212 NotificationProviderGetNotifierFunction::
193 NotificationProviderGetNotifierFunction() { 213 NotificationProviderGetNotifierFunction() {
194 } 214 }
195 215
196 NotificationProviderGetNotifierFunction:: 216 NotificationProviderGetNotifierFunction::
197 ~NotificationProviderGetNotifierFunction() { 217 ~NotificationProviderGetNotifierFunction() {
198 } 218 }
199 219
(...skipping 15 matching lines...) Expand all
215 235
216 ExtensionFunction::ResponseAction 236 ExtensionFunction::ResponseAction
217 NotificationProviderGetAllNotifiersFunction::Run() { 237 NotificationProviderGetAllNotifiersFunction::Run() {
218 std::vector<linked_ptr<api::notification_provider::Notifier> > notifiers; 238 std::vector<linked_ptr<api::notification_provider::Notifier> > notifiers;
219 239
220 return RespondNow(ArgumentList( 240 return RespondNow(ArgumentList(
221 api::notification_provider::GetAllNotifiers::Results::Create(notifiers))); 241 api::notification_provider::GetAllNotifiers::Results::Create(notifiers)));
222 } 242 }
223 243
224 } // namespace extensions 244 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698