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

Side by Side Diff: chrome/browser/ui/views/ash/balloon_view_ash.cc

Issue 11651002: Updated multiple item notification view to match latest mockups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 (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/ui/views/ash/balloon_view_ash.h" 5 #include "chrome/browser/ui/views/ash/balloon_view_ash.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/web_notification/web_notification_tray.h" 8 #include "ash/system/web_notification/web_notification_tray.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/favicon/favicon_util.h" 13 #include "chrome/browser/favicon/favicon_util.h"
14 #include "chrome/browser/notifications/balloon_collection.h" 14 #include "chrome/browser/notifications/balloon_collection.h"
15 #include "chrome/browser/notifications/notification.h" 15 #include "chrome/browser/notifications/notification.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
18 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/site_instance.h" 19 #include "content/public/browser/site_instance.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_delegate.h" 21 #include "content/public/browser/web_contents_delegate.h"
22 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
23 #include "ipc/ipc_message.h" 23 #include "ipc/ipc_message.h"
24 #include "ipc/ipc_message_macros.h" 24 #include "ipc/ipc_message_macros.h"
25 #include "ui/gfx/image/image_skia.h" 25 #include "ui/gfx/image/image_skia.h"
26 #include "ui/message_center/message_center.h" 26 #include "ui/message_center/message_center.h"
27 #include "ui/message_center/message_center_constants.h"
27 #include "webkit/glue/image_resource_fetcher.h" 28 #include "webkit/glue/image_resource_fetcher.h"
28 29
29 namespace { 30 namespace {
30 31
31 typedef base::Callback<void(const std::string&, const gfx::ImageSkia&)> Setter; 32 typedef base::Callback<void(const std::string&, const gfx::ImageSkia&)> Setter;
32 33
33 const int kPrimaryIconImageSize = 64;
34 const int kSecondaryIconImageSize = 15;
35
36 // Static. 34 // Static.
37 message_center::MessageCenter* GetMessageCenter() { 35 message_center::MessageCenter* GetMessageCenter() {
38 return ash::Shell::GetInstance()->GetWebNotificationTray()->message_center(); 36 return ash::Shell::GetInstance()->GetWebNotificationTray()->message_center();
39 } 37 }
40 38
41 // Static. 39 // Static.
42 std::string GetExtensionId(Balloon* balloon) { 40 std::string GetExtensionId(Balloon* balloon) {
43 const ExtensionURLInfo url(balloon->notification().origin_url()); 41 const ExtensionURLInfo url(balloon->notification().origin_url());
44 const ExtensionService* service = balloon->profile()->GetExtensionService(); 42 const ExtensionService* service = balloon->profile()->GetExtensionService();
45 const extensions::Extension* extension = 43 const extensions::Extension* extension =
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 message_center::MessageCenter* center = GetMessageCenter(); 185 message_center::MessageCenter* center = GetMessageCenter();
188 186
189 // Cancel any previous downloads. 187 // Cancel any previous downloads.
190 downloads_.clear(); 188 downloads_.clear();
191 189
192 // Set the notification's primary icon, or set up a download for it. 190 // Set the notification's primary icon, or set up a download for it.
193 if (!notification.icon().isNull()) { 191 if (!notification.icon().isNull()) {
194 center->SetNotificationPrimaryIcon(notification_id_, notification.icon()); 192 center->SetNotificationPrimaryIcon(notification_id_, notification.icon());
195 } else if (!notification.icon_url().is_empty()) { 193 } else if (!notification.icon_url().is_empty()) {
196 GetImageDownload(notification.icon_url()).AddCallback( 194 GetImageDownload(notification.icon_url()).AddCallback(
197 kPrimaryIconImageSize, 195 message_center::kNotificationIconWidth,
198 base::Bind( 196 base::Bind(
199 &message_center::MessageCenter::SetNotificationPrimaryIcon, 197 &message_center::MessageCenter::SetNotificationPrimaryIcon,
200 base::Unretained(center))); 198 base::Unretained(center)));
201 } 199 }
202 200
203 // Set up a download for the notification's secondary icon if appropriate.
204 const base::DictionaryValue* optional_fields = notification.optional_fields();
205 if (optional_fields &&
206 optional_fields->HasKey(ui::notifications::kSecondIconUrlKey)) {
207 string16 url;
208 optional_fields->GetString(ui::notifications::kSecondIconUrlKey, &url);
209 if (!url.empty()) {
210 GetImageDownload(GURL(url)).AddCallback(
211 kSecondaryIconImageSize,
212 base::Bind(
213 &message_center::MessageCenter::SetNotificationSecondaryIcon,
214 base::Unretained(center)));
215 }
216 }
217
218 // Start the downloads. 201 // Start the downloads.
219 for (ImageDownloads::const_iterator i = downloads_.begin(); 202 for (ImageDownloads::const_iterator i = downloads_.begin();
220 i != downloads_.end(); 203 i != downloads_.end();
221 ++i) { 204 ++i) {
222 i->second->Start(notification); 205 i->second->Start(notification);
223 } 206 }
224 } 207 }
225 208
226 BalloonViewAsh::ImageDownload& BalloonViewAsh::GetImageDownload( 209 BalloonViewAsh::ImageDownload& BalloonViewAsh::GetImageDownload(
227 const GURL& url) { 210 const GURL& url) {
228 if (!downloads_.count(url)) 211 if (!downloads_.count(url))
229 downloads_[url].reset(new ImageDownload(url)); 212 downloads_[url].reset(new ImageDownload(url));
230 return *downloads_[url]; 213 return *downloads_[url];
231 } 214 }
OLDNEW
« no previous file with comments | « no previous file | ui/message_center/message_center.gyp » ('j') | ui/message_center/message_view_multiple.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698