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

Side by Side Diff: ui/message_center/notification_list.cc

Issue 12335024: Change eventTime field to standard chrome.* API format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « ui/message_center/notification.h ('k') | no next file » | 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 "ui/message_center/notification_list.h" 5 #include "ui/message_center/notification_list.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const DictionaryValue* optional_fields) { 57 const DictionaryValue* optional_fields) {
58 Notification notification; 58 Notification notification;
59 notification.type = type; 59 notification.type = type;
60 notification.id = id; 60 notification.id = id;
61 notification.title = title; 61 notification.title = title;
62 notification.message = message; 62 notification.message = message;
63 notification.display_source = display_source; 63 notification.display_source = display_source;
64 notification.extension_id = extension_id; 64 notification.extension_id = extension_id;
65 65
66 // Initialize primitive fields before unpacking optional fields. 66 // Initialize primitive fields before unpacking optional fields.
67 // timestamp initializes to default NULL time.
68 notification.priority = ui::notifications::DEFAULT_PRIORITY; 67 notification.priority = ui::notifications::DEFAULT_PRIORITY;
69 notification.unread_count = 0;
70 68
71 UnpackOptionalFields(optional_fields, &notification); 69 UnpackOptionalFields(optional_fields, &notification);
72 70
73 PushNotification(notification); 71 PushNotification(notification);
74 } 72 }
75 73
76 void NotificationList::UnpackOptionalFields(const DictionaryValue* fields, 74 void NotificationList::UnpackOptionalFields(const DictionaryValue* fields,
77 Notification* notification) { 75 Notification* notification) {
78 if (!fields) 76 if (!fields)
79 return; 77 return;
80 78
81 fields->GetInteger(ui::notifications::kPriorityKey, &notification->priority); 79 fields->GetInteger(ui::notifications::kPriorityKey, &notification->priority);
82 if (fields->HasKey(ui::notifications::kTimestampKey)) { 80 if (fields->HasKey(ui::notifications::kTimestampKey)) {
83 std::string time_string; 81 double time_double;
84 fields->GetString(ui::notifications::kTimestampKey, &time_string); 82 fields->GetDouble(ui::notifications::kTimestampKey, &time_double);
85 base::Time::FromString(time_string.c_str(), &notification->timestamp); 83 notification->timestamp = base::Time::FromJsTime(time_double);
86 } 84 }
87 fields->GetInteger(ui::notifications::kUnreadCountKey,
88 &notification->unread_count);
89 if (fields->HasKey(ui::notifications::kButtonOneTitleKey) || 85 if (fields->HasKey(ui::notifications::kButtonOneTitleKey) ||
90 fields->HasKey(ui::notifications::kButtonOneIconUrlKey)) { 86 fields->HasKey(ui::notifications::kButtonOneIconUrlKey)) {
91 string16 title; 87 string16 title;
92 string16 icon; 88 string16 icon;
93 if (fields->GetString(ui::notifications::kButtonOneTitleKey, &title) || 89 if (fields->GetString(ui::notifications::kButtonOneTitleKey, &title) ||
94 fields->GetString(ui::notifications::kButtonOneIconUrlKey, &icon)) { 90 fields->GetString(ui::notifications::kButtonOneIconUrlKey, &icon)) {
95 notification->button_titles.push_back(title); 91 notification->button_titles.push_back(title);
96 notification->button_icons.push_back(gfx::ImageSkia()); 92 notification->button_icons.push_back(gfx::ImageSkia());
97 if (fields->GetString(ui::notifications::kButtonTwoTitleKey, &title) || 93 if (fields->GetString(ui::notifications::kButtonTwoTitleKey, &title) ||
98 fields->GetString(ui::notifications::kButtonTwoIconUrlKey, &icon)) { 94 fields->GetString(ui::notifications::kButtonTwoIconUrlKey, &icon)) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (priority == ui::notifications::DEFAULT_PRIORITY && 422 if (priority == ui::notifications::DEFAULT_PRIORITY &&
427 popup_count >= kMaxVisiblePopupNotifications) { 423 popup_count >= kMaxVisiblePopupNotifications) {
428 ++(*first); 424 ++(*first);
429 } else { 425 } else {
430 ++popup_count; 426 ++popup_count;
431 } 427 }
432 } 428 }
433 } 429 }
434 430
435 } // namespace message_center 431 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/notification.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698