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

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

Issue 15582004: Move NotificationDelegate into message_center. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Copy delegate in notification update too. 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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.h" 5 #include "ui/message_center/notification.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/message_center/notification_types.h" 8 #include "ui/message_center/notification_types.h"
9 9
10 namespace { 10 namespace {
(...skipping 11 matching lines...) Expand all
22 ButtonInfo::ButtonInfo(const string16& title) 22 ButtonInfo::ButtonInfo(const string16& title)
23 : title(title) { 23 : title(title) {
24 } 24 }
25 25
26 Notification::Notification(NotificationType type, 26 Notification::Notification(NotificationType type,
27 const std::string& id, 27 const std::string& id,
28 const string16& title, 28 const string16& title,
29 const string16& message, 29 const string16& message,
30 const string16& display_source, 30 const string16& display_source,
31 const std::string& extension_id, 31 const std::string& extension_id,
32 const DictionaryValue* optional_fields) 32 const DictionaryValue* optional_fields,
33 : type_(type), 33 NotificationDelegate* delegate)
34 id_(id), 34 : type_(type),
35 title_(title), 35 id_(id),
36 message_(message), 36 title_(title),
37 display_source_(display_source), 37 message_(message),
38 extension_id_(extension_id), 38 display_source_(display_source),
39 priority_(DEFAULT_PRIORITY), 39 extension_id_(extension_id),
40 timestamp_(base::Time::Now()), 40 priority_(DEFAULT_PRIORITY),
41 serial_number_(g_next_serial_number_++), 41 timestamp_(base::Time::Now()),
42 shown_as_popup_(false), 42 serial_number_(g_next_serial_number_++),
43 is_read_(false), 43 shown_as_popup_(false),
44 is_expanded_(false), 44 is_read_(false),
45 never_timeout_(false) { 45 is_expanded_(false),
46 never_timeout_(false),
47 delegate_(delegate) {
46 // This can override some data members initialized to deafule values above. 48 // This can override some data members initialized to deafule values above.
47 ApplyOptionalFields(optional_fields); 49 ApplyOptionalFields(optional_fields);
48 } 50 }
49 51
50 Notification::~Notification() { 52 Notification::~Notification() {
51 } 53 }
52 54
53 void Notification::CopyState(Notification* base) { 55 void Notification::CopyState(Notification* base) {
54 shown_as_popup_ = base->shown_as_popup(); 56 shown_as_popup_ = base->shown_as_popup();
55 is_read_ = base->is_read(); 57 is_read_ = base->is_read();
56 is_expanded_ = base->is_expanded(); 58 is_expanded_ = base->is_expanded();
57 never_timeout_ = base->never_timeout(); 59 never_timeout_ = base->never_timeout();
60 if (!delegate_.get())
61 delegate_ = base->delegate();
58 } 62 }
59 63
60 bool Notification::SetButtonIcon(size_t index, const gfx::Image& icon) { 64 bool Notification::SetButtonIcon(size_t index, const gfx::Image& icon) {
61 if (index >= buttons_.size()) 65 if (index >= buttons_.size())
62 return false; 66 return false;
63 buttons_[index].icon = icon; 67 buttons_[index].icon = icon;
64 return true; 68 return true;
65 } 69 }
66 70
67 void Notification::ApplyOptionalFields(const DictionaryValue* fields) { 71 void Notification::ApplyOptionalFields(const DictionaryValue* fields) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 item->GetString(kItemTitleKey, &title); 103 item->GetString(kItemTitleKey, &title);
100 item->GetString(kItemMessageKey, &message); 104 item->GetString(kItemMessageKey, &message);
101 items_.push_back(NotificationItem(title, message)); 105 items_.push_back(NotificationItem(title, message));
102 } 106 }
103 } 107 }
104 108
105 fields->GetBoolean(kPrivateNeverTimeoutKey, &never_timeout_); 109 fields->GetBoolean(kPrivateNeverTimeoutKey, &never_timeout_);
106 } 110 }
107 111
108 } // namespace message_center 112 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698