OLD | NEW |
---|---|
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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/notifications/notification.h" | 12 #include "chrome/browser/notifications/notification.h" |
13 #include "chrome/browser/notifications/notification_ui_manager.h" | 13 #include "chrome/browser/notifications/notification_ui_manager.h" |
14 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_delegate.h" | 14 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_delegate.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "sync/protocol/sync.pb.h" | 16 #include "sync/protocol/sync.pb.h" |
17 #include "sync/protocol/synced_notification_specifics.pb.h" | 17 #include "sync/protocol/synced_notification_specifics.pb.h" |
18 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
19 #include "ui/message_center/message_center_util.h" | 19 #include "ui/message_center/message_center_util.h" |
20 #include "ui/message_center/notification_types.h" | 20 #include "ui/message_center/notification_types.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 const char kExtensionScheme[] = "chrome-extension://"; | 23 const char kExtensionScheme[] = "chrome-extension://"; |
24 | 24 |
25 // The name of our first synced notification service. | |
26 // TODO(petewil): remove this hardcoding once we have the synced notification | |
27 // signalling sync data type set up to provide this. | |
28 // https://code.google.com/p/chromium/issues/detail?id=248337 | |
dewittj
2013/07/19 19:43:06
Same bug reference comment.
| |
29 const char kFirstSyncedNotificationServiceId[] = "Google+"; | |
30 | |
31 | |
25 // Today rich notifications only supports two buttons, make sure we don't | 32 // Today rich notifications only supports two buttons, make sure we don't |
26 // try to supply them with more than this number of buttons. | 33 // try to supply them with more than this number of buttons. |
27 const unsigned int kMaxNotificationButtonIndex = 2; | 34 const unsigned int kMaxNotificationButtonIndex = 2; |
28 | 35 |
29 bool UseRichNotifications() { | 36 bool UseRichNotifications() { |
30 return message_center::IsRichNotificationEnabled(); | 37 return message_center::IsRichNotificationEnabled(); |
31 } | 38 } |
32 | 39 |
33 } // namespace | 40 } // namespace |
34 | 41 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 | 470 |
464 // Convert the prioroty to the scheme used by the notification center. | 471 // Convert the prioroty to the scheme used by the notification center. |
465 if (protobuf_priority == | 472 if (protobuf_priority == |
466 sync_pb::CoalescedSyncedNotification_Priority_LOW) { | 473 sync_pb::CoalescedSyncedNotification_Priority_LOW) { |
467 return message_center::LOW_PRIORITY; | 474 return message_center::LOW_PRIORITY; |
468 } else if (protobuf_priority == | 475 } else if (protobuf_priority == |
469 sync_pb::CoalescedSyncedNotification_Priority_STANDARD) { | 476 sync_pb::CoalescedSyncedNotification_Priority_STANDARD) { |
470 return message_center::DEFAULT_PRIORITY; | 477 return message_center::DEFAULT_PRIORITY; |
471 } else if (protobuf_priority == | 478 } else if (protobuf_priority == |
472 sync_pb::CoalescedSyncedNotification_Priority_HIGH) { | 479 sync_pb::CoalescedSyncedNotification_Priority_HIGH) { |
473 return message_center::HIGH_PRIORITY; | 480 // High priority synced notifications are considered default priority in |
481 // Chrome. | |
482 return message_center::DEFAULT_PRIORITY; | |
474 } else { | 483 } else { |
475 // Complain if this is a new priority we have not seen before. | 484 // Complain if this is a new priority we have not seen before. |
476 DCHECK(protobuf_priority < | 485 DCHECK(protobuf_priority < |
477 sync_pb::CoalescedSyncedNotification_Priority_LOW || | 486 sync_pb::CoalescedSyncedNotification_Priority_LOW || |
478 sync_pb::CoalescedSyncedNotification_Priority_HIGH < | 487 sync_pb::CoalescedSyncedNotification_Priority_HIGH < |
479 protobuf_priority); | 488 protobuf_priority); |
480 return kUndefinedPriority; | 489 return kUndefinedPriority; |
481 } | 490 } |
482 } | 491 } |
483 | 492 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
568 std::string SyncedNotification::GetContainedNotificationMessage( | 577 std::string SyncedNotification::GetContainedNotificationMessage( |
569 int index) const { | 578 int index) const { |
570 if (specifics_.coalesced_notification().render_info().expanded_info(). | 579 if (specifics_.coalesced_notification().render_info().expanded_info(). |
571 collapsed_info_size() < index + 1) | 580 collapsed_info_size() < index + 1) |
572 return std::string(); | 581 return std::string(); |
573 | 582 |
574 return specifics_.coalesced_notification().render_info().expanded_info(). | 583 return specifics_.coalesced_notification().render_info().expanded_info(). |
575 collapsed_info(index).simple_collapsed_layout().description(); | 584 collapsed_info(index).simple_collapsed_layout().description(); |
576 } | 585 } |
577 | 586 |
587 std::string SyncedNotification::GetSendingServiceId() const { | |
588 // TODO(petewil): We are building a new protocol (a new sync datatype) to send | |
589 // the service name and icon from the server. For now this method is | |
590 // hardcoded to the name of our first service using synced notifications. | |
591 // Once the new protocol is built, remove this hardcoding. | |
592 return kFirstSyncedNotificationServiceId; | |
593 } | |
594 | |
578 } // namespace notifier | 595 } // namespace notifier |
OLD | NEW |