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

Side by Side Diff: chrome/browser/notifications/sync_notifier/synced_notification.cc

Issue 15025002: Remove ENABLE_MESSAGE_CENTER (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing static initializer Created 7 years, 7 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 (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/sync_notifier/synced_notification.h" 5 #include "chrome/browser/notifications/sync_notifier/synced_notification.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/notifications/notification.h" 11 #include "chrome/browser/notifications/notification.h"
12 #include "chrome/browser/notifications/notification_ui_manager.h" 12 #include "chrome/browser/notifications/notification_ui_manager.h"
13 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_delegate.h" 13 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_delegate.h"
14 #include "sync/protocol/sync.pb.h" 14 #include "sync/protocol/sync.pb.h"
15 #include "sync/protocol/synced_notification_specifics.pb.h" 15 #include "sync/protocol/synced_notification_specifics.pb.h"
16 #if defined(ENABLE_MESSAGE_CENTER)
17 #include "ui/message_center/message_center_util.h" 16 #include "ui/message_center/message_center_util.h"
18 #include "ui/message_center/notification_types.h" 17 #include "ui/message_center/notification_types.h"
19 #endif // ENABLE_MESSAGE_CENTER
20 18
21 namespace { 19 namespace {
22 const char kExtensionScheme[] = "chrome-extension://"; 20 const char kExtensionScheme[] = "chrome-extension://";
23 21
24 bool UseRichNotifications() { 22 bool UseRichNotifications() {
25 #if defined(ENABLE_MESSAGE_CENTER)
26 return message_center::IsRichNotificationEnabled(); 23 return message_center::IsRichNotificationEnabled();
27 #else // ENABLE_MESSAGE_CENTER
28 return false;
29 #endif // ENABLE_MESSAGE_CENTER
30 } 24 }
31 25
32 } // namespace 26 } // namespace
33 27
34 namespace notifier { 28 namespace notifier {
35 29
36 COMPILE_ASSERT(static_cast<sync_pb::CoalescedSyncedNotification_ReadState>( 30 COMPILE_ASSERT(static_cast<sync_pb::CoalescedSyncedNotification_ReadState>(
37 SyncedNotification::kUnread) == 31 SyncedNotification::kUnread) ==
38 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD, 32 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD,
39 local_enum_must_match_protobuf_enum); 33 local_enum_must_match_protobuf_enum);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // I change the interface to let NotificationUIManager know the right way. 77 // I change the interface to let NotificationUIManager know the right way.
84 if (SyncedNotification::kRead == GetReadState() || 78 if (SyncedNotification::kRead == GetReadState() ||
85 SyncedNotification::kDismissed == GetReadState() ) { 79 SyncedNotification::kDismissed == GetReadState() ) {
86 DVLOG(2) << "Dismissed notification arrived" 80 DVLOG(2) << "Dismissed notification arrived"
87 << GetHeading() << " " << GetText(); 81 << GetHeading() << " " << GetText();
88 return; 82 return;
89 } 83 }
90 84
91 // Some inputs and fields are only used if there is a notification center. 85 // Some inputs and fields are only used if there is a notification center.
92 if (UseRichNotifications()) { 86 if (UseRichNotifications()) {
93
94 #if defined(ENABLE_MESSAGE_CENTER)
95 double creation_time = static_cast<double>(GetCreationTime()); 87 double creation_time = static_cast<double>(GetCreationTime());
96 int priority = GetPriority(); 88 int priority = GetPriority();
97 int notification_count = GetNotificationCount(); 89 int notification_count = GetNotificationCount();
98 int button_count = GetButtonCount(); 90 int button_count = GetButtonCount();
99 // TODO(petewil): Refactor this for an arbitrary number of buttons. 91 // TODO(petewil): Refactor this for an arbitrary number of buttons.
100 std::string button_one_title = GetButtonOneTitle(); 92 std::string button_one_title = GetButtonOneTitle();
101 std::string button_one_icon_url = GetButtonOneIconUrl(); 93 std::string button_one_icon_url = GetButtonOneIconUrl();
102 std::string button_two_title = GetButtonTwoTitle(); 94 std::string button_two_title = GetButtonTwoTitle();
103 std::string button_two_icon_url = GetButtonTwoIconUrl(); 95 std::string button_two_icon_url = GetButtonTwoIconUrl();
104 96
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 GetAppIconUrl(), 147 GetAppIconUrl(),
156 heading, 148 heading,
157 text, 149 text,
158 WebKit::WebTextDirectionDefault, 150 WebKit::WebTextDirectionDefault,
159 display_source, 151 display_source,
160 replace_key, 152 replace_key,
161 &optional_fields, 153 &optional_fields,
162 delegate); 154 delegate);
163 155
164 notification_manager->Add(ui_notification, profile); 156 notification_manager->Add(ui_notification, profile);
165 #endif // ENABLE_MESSAGE_CENTER
166
167 } else { 157 } else {
168 158
169 Notification ui_notification(GetOriginUrl(), 159 Notification ui_notification(GetOriginUrl(),
170 GetAppIconUrl(), 160 GetAppIconUrl(),
171 heading, 161 heading,
172 text, 162 text,
173 WebKit::WebTextDirectionDefault, 163 WebKit::WebTextDirectionDefault,
174 display_source, 164 display_source,
175 replace_key, 165 replace_key,
176 delegate); 166 delegate);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 return 0; 322 return 0;
333 323
334 return specifics_.coalesced_notification().creation_time_msec(); 324 return specifics_.coalesced_notification().creation_time_msec();
335 } 325 }
336 326
337 int SyncedNotification::GetPriority() const { 327 int SyncedNotification::GetPriority() const {
338 if (!specifics_.coalesced_notification().has_priority()) 328 if (!specifics_.coalesced_notification().has_priority())
339 return kUndefinedPriority; 329 return kUndefinedPriority;
340 int protobuf_priority = specifics_.coalesced_notification().priority(); 330 int protobuf_priority = specifics_.coalesced_notification().priority();
341 331
342 #if defined(ENABLE_MESSAGE_CENTER)
343 // Convert the prioroty to the scheme used by the notification center. 332 // Convert the prioroty to the scheme used by the notification center.
344 if (protobuf_priority == 333 if (protobuf_priority ==
345 sync_pb::CoalescedSyncedNotification_Priority_LOW) { 334 sync_pb::CoalescedSyncedNotification_Priority_LOW) {
346 return message_center::LOW_PRIORITY; 335 return message_center::LOW_PRIORITY;
347 } else if (protobuf_priority == 336 } else if (protobuf_priority ==
348 sync_pb::CoalescedSyncedNotification_Priority_STANDARD) { 337 sync_pb::CoalescedSyncedNotification_Priority_STANDARD) {
349 return message_center::DEFAULT_PRIORITY; 338 return message_center::DEFAULT_PRIORITY;
350 } else if (protobuf_priority == 339 } else if (protobuf_priority ==
351 sync_pb::CoalescedSyncedNotification_Priority_HIGH) { 340 sync_pb::CoalescedSyncedNotification_Priority_HIGH) {
352 return message_center::HIGH_PRIORITY; 341 return message_center::HIGH_PRIORITY;
353 } else { 342 } else {
354 // Complain if this is a new priority we have not seen before. 343 // Complain if this is a new priority we have not seen before.
355 DCHECK(protobuf_priority < 344 DCHECK(protobuf_priority <
356 sync_pb::CoalescedSyncedNotification_Priority_LOW || 345 sync_pb::CoalescedSyncedNotification_Priority_LOW ||
357 sync_pb::CoalescedSyncedNotification_Priority_HIGH < 346 sync_pb::CoalescedSyncedNotification_Priority_HIGH <
358 protobuf_priority); 347 protobuf_priority);
359 return kUndefinedPriority; 348 return kUndefinedPriority;
360 } 349 }
361
362 #else // ENABLE_MESSAGE_CENTER
363 return protobuf_priority;
364
365 #endif // ENABLE_MESSAGE_CENTER
366 } 350 }
367 351
368 int SyncedNotification::GetNotificationCount() const { 352 int SyncedNotification::GetNotificationCount() const {
369 return specifics_.coalesced_notification().render_info(). 353 return specifics_.coalesced_notification().render_info().
370 expanded_info().collapsed_info_size(); 354 expanded_info().collapsed_info_size();
371 } 355 }
372 356
373 int SyncedNotification::GetButtonCount() const { 357 int SyncedNotification::GetButtonCount() const {
374 return specifics_.coalesced_notification().render_info().collapsed_info(). 358 return specifics_.coalesced_notification().render_info().collapsed_info().
375 target_size(); 359 target_size();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 int index) const { 472 int index) const {
489 if (specifics_.coalesced_notification().render_info().expanded_info(). 473 if (specifics_.coalesced_notification().render_info().expanded_info().
490 collapsed_info_size() < index + 1) 474 collapsed_info_size() < index + 1)
491 return std::string(); 475 return std::string();
492 476
493 return specifics_.coalesced_notification().render_info().expanded_info(). 477 return specifics_.coalesced_notification().render_info().expanded_info().
494 collapsed_info(index).simple_collapsed_layout().description(); 478 collapsed_info(index).simple_collapsed_layout().description();
495 } 479 }
496 480
497 } // namespace notifier 481 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698