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

Side by Side Diff: chrome/browser/chromeos/file_manager/desktop_notifications.cc

Issue 105193002: Replace string16 with base::string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/chromeos/file_manager/desktop_notifications.h" 5 #include "chrome/browser/chromeos/file_manager/desktop_notifications.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 }; 84 };
85 85
86 int GetIconId(DesktopNotifications::NotificationType type) { 86 int GetIconId(DesktopNotifications::NotificationType type) {
87 DCHECK_GE(type, 0); 87 DCHECK_GE(type, 0);
88 DCHECK_LT(static_cast<size_t>(type), arraysize(kNotificationTypes)); 88 DCHECK_LT(static_cast<size_t>(type), arraysize(kNotificationTypes));
89 DCHECK(kNotificationTypes[type].type == type); 89 DCHECK(kNotificationTypes[type].type == type);
90 90
91 return kNotificationTypes[type].icon_id; 91 return kNotificationTypes[type].icon_id;
92 } 92 }
93 93
94 string16 GetTitle(DesktopNotifications::NotificationType type) { 94 base::string16 GetTitle(DesktopNotifications::NotificationType type) {
95 DCHECK_GE(type, 0); 95 DCHECK_GE(type, 0);
96 DCHECK_LT(static_cast<size_t>(type), arraysize(kNotificationTypes)); 96 DCHECK_LT(static_cast<size_t>(type), arraysize(kNotificationTypes));
97 DCHECK(kNotificationTypes[type].type == type); 97 DCHECK(kNotificationTypes[type].type == type);
98 98
99 int id = kNotificationTypes[type].title_id; 99 int id = kNotificationTypes[type].title_id;
100 if (id < 0) 100 if (id < 0)
101 return string16(); 101 return base::string16();
102 return l10n_util::GetStringUTF16(id); 102 return l10n_util::GetStringUTF16(id);
103 } 103 }
104 104
105 string16 GetMessage(DesktopNotifications::NotificationType type) { 105 base::string16 GetMessage(DesktopNotifications::NotificationType type) {
106 DCHECK_GE(type, 0); 106 DCHECK_GE(type, 0);
107 DCHECK_LT(static_cast<size_t>(type), arraysize(kNotificationTypes)); 107 DCHECK_LT(static_cast<size_t>(type), arraysize(kNotificationTypes));
108 DCHECK(kNotificationTypes[type].type == type); 108 DCHECK(kNotificationTypes[type].type == type);
109 109
110 int id = kNotificationTypes[type].message_id; 110 int id = kNotificationTypes[type].message_id;
111 if (id < 0) 111 if (id < 0)
112 return string16(); 112 return base::string16();
113 return l10n_util::GetStringUTF16(id); 113 return l10n_util::GetStringUTF16(id);
114 } 114 }
115 115
116 std::string GetNotificationId(DesktopNotifications::NotificationType type, 116 std::string GetNotificationId(DesktopNotifications::NotificationType type,
117 const std::string& path) { 117 const std::string& path) {
118 DCHECK_GE(type, 0); 118 DCHECK_GE(type, 0);
119 DCHECK_LT(static_cast<size_t>(type), arraysize(kNotificationTypes)); 119 DCHECK_LT(static_cast<size_t>(type), arraysize(kNotificationTypes));
120 DCHECK(kNotificationTypes[type].type == type); 120 DCHECK(kNotificationTypes[type].type == type);
121 121
122 std::string id_prefix(kNotificationTypes[type].notification_id_prefix); 122 std::string id_prefix(kNotificationTypes[type].notification_id_prefix);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 base::WeakPtr<DesktopNotifications> host_; 155 base::WeakPtr<DesktopNotifications> host_;
156 std::string id_; 156 std::string id_;
157 157
158 DISALLOW_COPY_AND_ASSIGN(Delegate); 158 DISALLOW_COPY_AND_ASSIGN(Delegate);
159 }; 159 };
160 160
161 NotificationMessage(DesktopNotifications* host, 161 NotificationMessage(DesktopNotifications* host,
162 Profile* profile, 162 Profile* profile,
163 NotificationType type, 163 NotificationType type,
164 const std::string& notification_id, 164 const std::string& notification_id,
165 const string16& message) 165 const base::string16& message)
166 : message_(message) { 166 : message_(message) {
167 const gfx::Image& icon = 167 const gfx::Image& icon =
168 ResourceBundle::GetSharedInstance().GetNativeImageNamed( 168 ResourceBundle::GetSharedInstance().GetNativeImageNamed(
169 GetIconId(type)); 169 GetIconId(type));
170 // TODO(mukai): refactor here to invoke NotificationUIManager directly. 170 // TODO(mukai): refactor here to invoke NotificationUIManager directly.
171 const string16 replace_id = UTF8ToUTF16(notification_id); 171 const base::string16 replace_id = UTF8ToUTF16(notification_id);
172 DesktopNotificationService::AddIconNotification( 172 DesktopNotificationService::AddIconNotification(
173 util::GetFileManagerBaseUrl(), GetTitle(type), 173 util::GetFileManagerBaseUrl(), GetTitle(type),
174 message, icon, replace_id, 174 message, icon, replace_id,
175 new Delegate(host->AsWeakPtr(), notification_id), profile); 175 new Delegate(host->AsWeakPtr(), notification_id), profile);
176 } 176 }
177 177
178 ~NotificationMessage() {} 178 ~NotificationMessage() {}
179 179
180 // Used in test. 180 // Used in test.
181 string16 message() { return message_; } 181 base::string16 message() { return message_; }
182 182
183 private: 183 private:
184 string16 message_; 184 base::string16 message_;
185 185
186 DISALLOW_COPY_AND_ASSIGN(NotificationMessage); 186 DISALLOW_COPY_AND_ASSIGN(NotificationMessage);
187 }; 187 };
188 188
189 struct DesktopNotifications::MountRequestsInfo { 189 struct DesktopNotifications::MountRequestsInfo {
190 bool mount_success_exists; 190 bool mount_success_exists;
191 bool fail_message_finalized; 191 bool fail_message_finalized;
192 bool fail_notification_shown; 192 bool fail_notification_shown;
193 bool non_parent_device_failed; 193 bool non_parent_device_failed;
194 bool device_notification_hidden; 194 bool device_notification_hidden;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 379
380 string16 DesktopNotifications::GetNotificationMessageForTest( 380 string16 DesktopNotifications::GetNotificationMessageForTest(
381 const std::string& id) const { 381 const std::string& id) const {
382 NotificationMap::const_iterator it = notification_map_.find(id); 382 NotificationMap::const_iterator it = notification_map_.find(id);
383 if (it == notification_map_.end()) 383 if (it == notification_map_.end())
384 return string16(); 384 return string16();
385 return it->second->message(); 385 return it->second->message();
386 } 386 }
387 387
388 } // namespace file_manager 388 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698