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

Side by Side Diff: chrome/browser/download/download_status_updater_win.cc

Issue 10827207: Mountain Lion: use the system download progress. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/download/download_status_updater.h"
6
7 #include <string>
8
9 #include "base/logging.h"
10 #include "base/stl_util.h"
11 #include "base/string_number_conversions.h"
12 #include "base/win/metro.h"
13 #include "googleurl/src/gurl.h"
14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h"
16
17 namespace {
18
19 const char kDownloadNotificationPrefix[] = "DownloadNotification";
20 int g_next_notification_id = 0;
21
22 } // namespace
23
24 void DownloadStatusUpdater::UpdateDownloadProgressForItemStarted(
25 content::DownloadItem* download) {
26 }
27
28 void DownloadStatusUpdater::UpdateDownloadProgressForItemProgressed(
29 content::DownloadItem* download) {
30 }
31
32 void DownloadStatusUpdater::UpdateDownloadProgressForItemCompleted(
33 content::DownloadItem* download) {
34 if (!base::win::IsMetroProcess())
35 return;
36
37 if (download->GetOpenWhenComplete() ||
38 download->ShouldOpenFileBasedOnExtension() ||
39 download->IsTemporary() ||
40 download->GetAutoOpened())
41 return;
42
43 // In Windows 8 metro mode display a metro style notification which
44 // informs the user that the download is complete.
45 HMODULE metro = base::win::GetMetroModule();
46 base::win::MetroNotification display_notification =
47 reinterpret_cast<base::win::MetroNotification>(
48 ::GetProcAddress(metro, "DisplayNotification"));
49 DCHECK(display_notification);
50 if (display_notification) {
51 string16 title = l10n_util::GetStringUTF16(
52 IDS_METRO_DOWNLOAD_COMPLETE_NOTIFICATION_TITLE);
53 string16 body = l10n_util::GetStringUTF16(
54 IDS_METRO_DOWNLOAD_COMPLETE_NOTIFICATION);
55
56 // Dummy notification id. Every metro style notification needs a
57 // unique notification id.
58 std::string notification_id = kDownloadNotificationPrefix;
59 notification_id += base::IntToString(g_next_notification_id++);
60
61 display_notification(download->GetURL().spec().c_str(),
62 "",
63 title.c_str(),
64 body.c_str(),
65 L"",
66 notification_id.c_str());
67 }
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698