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

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_notifications.cc

Issue 10026013: Update use of TimeDelta in chrome/browser/*, ui/views/*, and other places. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase onto master. Created 8 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) 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/chromeos/extensions/file_browser_notifications.h" 5 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 CreateNotificationId(type, path, &notification_id); 123 CreateNotificationId(type, path, &notification_id);
124 chromeos::SystemNotification* notification = 124 chromeos::SystemNotification* notification =
125 CreateNotification(notification_id, GetIconId(type), GetTitleId(type)); 125 CreateNotification(notification_id, GetIconId(type), GetTitleId(type));
126 if (HasMoreInfoLink(type)) { 126 if (HasMoreInfoLink(type)) {
127 notification->Show(message, GetLinkText(), GetLinkCallback(), false, false); 127 notification->Show(message, GetLinkText(), GetLinkCallback(), false, false);
128 } else { 128 } else {
129 notification->Show(message, false, false); 129 notification->Show(message, false, false);
130 } 130 }
131 } 131 }
132 132
133 void FileBrowserNotifications::ShowNotificationDelayed(NotificationType type, 133 void FileBrowserNotifications::ShowNotificationDelayed(
134 const std::string& path, size_t delay_ms) { 134 NotificationType type, const std::string& path, base::TimeDelta delay) {
135 std::string notification_id; 135 std::string notification_id;
136 CreateNotificationId(type, path, &notification_id); 136 CreateNotificationId(type, path, &notification_id);
137 CreateNotification(notification_id, GetIconId(type), GetTitleId(type)); 137 CreateNotification(notification_id, GetIconId(type), GetTitleId(type));
138 138
139 PostDelayedShowNotificationTask(notification_id, type, 139 PostDelayedShowNotificationTask(notification_id, type,
140 l10n_util::GetStringUTF16(GetMessageId(type)), 140 l10n_util::GetStringUTF16(GetMessageId(type)),
141 delay_ms); 141 delay);
142 } 142 }
143 143
144 void FileBrowserNotifications::HideNotification(NotificationType type, 144 void FileBrowserNotifications::HideNotification(NotificationType type,
145 const std::string& path) { 145 const std::string& path) {
146 std::string notification_id; 146 std::string notification_id;
147 CreateNotificationId(type, path, &notification_id); 147 CreateNotificationId(type, path, &notification_id);
148 NotificationMap::iterator it = notifications_.find(notification_id); 148 NotificationMap::iterator it = notifications_.find(notification_id);
149 if (it != notifications_.end()) { 149 if (it != notifications_.end()) {
150 if (it->second->visible()) 150 if (it->second->visible())
151 it->second->Hide(); 151 it->second->Hide();
152 notifications_.erase(it); 152 notifications_.erase(it);
153 } 153 }
154 } 154 }
155 155
156 void FileBrowserNotifications::HideNotificationDelayed(NotificationType type, 156 void FileBrowserNotifications::HideNotificationDelayed(
157 const std::string& path, 157 NotificationType type, const std::string& path, base::TimeDelta delay) {
158 size_t delay_ms) { 158 PostDelayedHideNotificationTask(type, path, delay);
159 PostDelayedHideNotificationTask(type, path, delay_ms);
160 } 159 }
161 160
162 void FileBrowserNotifications::PostDelayedShowNotificationTask( 161 void FileBrowserNotifications::PostDelayedShowNotificationTask(
163 const std::string& notification_id, NotificationType type, 162 const std::string& notification_id, NotificationType type,
164 const string16& message, size_t delay_ms) { 163 const string16& message, base::TimeDelta delay) {
165 MessageLoop::current()->PostDelayedTask(FROM_HERE, 164 MessageLoop::current()->PostDelayedTask(FROM_HERE,
166 base::Bind(&ShowNotificationDelayedTask, notification_id, type, 165 base::Bind(&ShowNotificationDelayedTask, notification_id, type,
167 message, AsWeakPtr()), 166 message, AsWeakPtr()),
168 delay_ms); 167 delay);
169 } 168 }
170 169
171 // static 170 // static
172 void FileBrowserNotifications::ShowNotificationDelayedTask( 171 void FileBrowserNotifications::ShowNotificationDelayedTask(
173 const std::string& notification_id, NotificationType type, 172 const std::string& notification_id, NotificationType type,
174 const string16& message, 173 const string16& message,
175 base::WeakPtr<FileBrowserNotifications> self) { 174 base::WeakPtr<FileBrowserNotifications> self) {
176 if (!self) 175 if (!self)
177 return; 176 return;
178 177
179 NotificationMap::iterator it = self->notifications_.find(notification_id); 178 NotificationMap::iterator it = self->notifications_.find(notification_id);
180 if (it != self->notifications_.end()) { 179 if (it != self->notifications_.end()) {
181 if (self->HasMoreInfoLink(type)) { 180 if (self->HasMoreInfoLink(type)) {
182 it->second->Show(message, self->GetLinkText(), self->GetLinkCallback(), 181 it->second->Show(message, self->GetLinkText(), self->GetLinkCallback(),
183 false, false); 182 false, false);
184 } else { 183 } else {
185 it->second->Show(message, false, false); 184 it->second->Show(message, false, false);
186 } 185 }
187 } 186 }
188 } 187 }
189 188
190 void FileBrowserNotifications::PostDelayedHideNotificationTask( 189 void FileBrowserNotifications::PostDelayedHideNotificationTask(
191 NotificationType type, const std::string path, size_t delay_ms) { 190 NotificationType type, const std::string path, base::TimeDelta delay) {
192 MessageLoop::current()->PostDelayedTask(FROM_HERE, 191 MessageLoop::current()->PostDelayedTask(FROM_HERE,
193 base::Bind(&HideNotificationDelayedTask, type, path, AsWeakPtr()), 192 base::Bind(&HideNotificationDelayedTask, type, path, AsWeakPtr()),
194 delay_ms); 193 delay);
195 } 194 }
196 195
197 // static 196 // static
198 void FileBrowserNotifications::HideNotificationDelayedTask( 197 void FileBrowserNotifications::HideNotificationDelayedTask(
199 NotificationType type, const std::string& path, 198 NotificationType type, const std::string& path,
200 base::WeakPtr<FileBrowserNotifications> self) { 199 base::WeakPtr<FileBrowserNotifications> self) {
201 if (self) 200 if (self)
202 self->HideNotification(type, path); 201 self->HideNotification(type, path);
203 } 202 }
204 203
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 const string16& FileBrowserNotifications::GetLinkText() { 318 const string16& FileBrowserNotifications::GetLinkText() {
320 if (link_text_.empty()) 319 if (link_text_.empty())
321 link_text_ = l10n_util::GetStringUTF16(IDS_LEARN_MORE); 320 link_text_ = l10n_util::GetStringUTF16(IDS_LEARN_MORE);
322 return link_text_; 321 return link_text_;
323 } 322 }
324 323
325 chromeos::BalloonViewHost::MessageCallback 324 chromeos::BalloonViewHost::MessageCallback
326 FileBrowserNotifications::GetLinkCallback() { 325 FileBrowserNotifications::GetLinkCallback() {
327 return base::Bind(&FileBrowserNotifications::OnLinkClicked, AsWeakPtr()); 326 return base::Bind(&FileBrowserNotifications::OnLinkClicked, AsWeakPtr());
328 } 327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698