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

Side by Side Diff: chrome/browser/extensions/api/notifications/notifications_api.cc

Issue 13421008: Fix menu for 'disable extension'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/notifications/message_center_notification_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extensions/api/notifications/notifications_api.h" 5 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // Ignore options if running on the old notification runtime. 146 // Ignore options if running on the old notification runtime.
147 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue()); 147 scoped_ptr<DictionaryValue> optional_fields(new DictionaryValue());
148 148
149 NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate( 149 NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate(
150 this, 150 this,
151 profile(), 151 profile(),
152 extension_->id(), 152 extension_->id(),
153 id)); // ownership is passed to Notification 153 id)); // ownership is passed to Notification
154 Notification notification(type, extension_->url(), icon_url, title, message, 154 Notification notification(type, extension_->url(), icon_url, title, message,
155 WebKit::WebTextDirectionDefault, 155 WebKit::WebTextDirectionDefault,
156 string16(), UTF8ToUTF16(api_delegate->id()), 156 UTF8ToUTF16(extension_->name()),
157 UTF8ToUTF16(api_delegate->id()),
157 optional_fields.get(), api_delegate); 158 optional_fields.get(), api_delegate);
158 159
159 g_browser_process->notification_ui_manager()->Add(notification, profile()); 160 g_browser_process->notification_ui_manager()->Add(notification, profile());
160 } 161 }
161 #else // defined(ENABLE_MESSAGE_CENTER) 162 #else // defined(ENABLE_MESSAGE_CENTER)
162 void NotificationsApiFunction::CreateNotification( 163 void NotificationsApiFunction::CreateNotification(
163 const std::string& id, 164 const std::string& id,
164 api::notifications::NotificationOptions* options) { 165 api::notifications::NotificationOptions* options) {
165 message_center::NotificationType type = 166 message_center::NotificationType type =
166 MapApiTemplateTypeToType(options->type); 167 MapApiTemplateTypeToType(options->type);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 optional_fields->Set(message_center::kItemsKey, items); 228 optional_fields->Set(message_center::kItemsKey, items);
228 } 229 }
229 230
230 NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate( 231 NotificationsApiDelegate* api_delegate(new NotificationsApiDelegate(
231 this, 232 this,
232 profile(), 233 profile(),
233 extension_->id(), 234 extension_->id(),
234 id)); // ownership is passed to Notification 235 id)); // ownership is passed to Notification
235 Notification notification(type, extension_->url(), icon_url, title, message, 236 Notification notification(type, extension_->url(), icon_url, title, message,
236 WebKit::WebTextDirectionDefault, 237 WebKit::WebTextDirectionDefault,
237 string16(), UTF8ToUTF16(api_delegate->id()), 238 UTF8ToUTF16(extension_->name()),
239 UTF8ToUTF16(api_delegate->id()),
238 optional_fields.get(), api_delegate); 240 optional_fields.get(), api_delegate);
239 241
240 g_browser_process->notification_ui_manager()->Add(notification, profile()); 242 g_browser_process->notification_ui_manager()->Add(notification, profile());
241 } 243 }
242 #endif // !defined(ENABLE_MESSAGE_CENTER) 244 #endif // !defined(ENABLE_MESSAGE_CENTER)
243 245
244 bool NotificationsApiFunction::IsNotificationsApiEnabled() { 246 bool NotificationsApiFunction::IsNotificationsApiEnabled() {
245 DesktopNotificationService* service = 247 DesktopNotificationService* service =
246 DesktopNotificationServiceFactory::GetForProfile(profile()); 248 DesktopNotificationServiceFactory::GetForProfile(profile());
247 return service->IsExtensionEnabled(extension_->id()); 249 return service->IsExtensionEnabled(extension_->id());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 CancelById(NotificationsApiDelegate::CreateScopedIdentifier( 351 CancelById(NotificationsApiDelegate::CreateScopedIdentifier(
350 extension_->id(), params_->notification_id)); 352 extension_->id(), params_->notification_id));
351 353
352 SetResult(Value::CreateBooleanValue(cancel_result)); 354 SetResult(Value::CreateBooleanValue(cancel_result));
353 SendResponse(true); 355 SendResponse(true);
354 356
355 return true; 357 return true;
356 } 358 }
357 359
358 } // namespace extensions 360 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/notifications/message_center_notification_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698