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

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: fix 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->GetState() != content::DownloadItem::COMPLETE)
38 return;
39
40 if (download->GetOpenWhenComplete() ||
41 download->ShouldOpenFileBasedOnExtension() ||
42 download->IsTemporary() ||
43 download->GetAutoOpened())
44 return;
45
46 // In Windows 8 metro mode display a metro style notification which
47 // informs the user that the download is complete.
48 HMODULE metro = base::win::GetMetroModule();
49 base::win::MetroNotification display_notification =
50 reinterpret_cast<base::win::MetroNotification>(
51 ::GetProcAddress(metro, "DisplayNotification"));
52 DCHECK(display_notification);
53 if (display_notification) {
54 string16 title = l10n_util::GetStringUTF16(
55 IDS_METRO_DOWNLOAD_COMPLETE_NOTIFICATION_TITLE);
56 string16 body = l10n_util::GetStringUTF16(
57 IDS_METRO_DOWNLOAD_COMPLETE_NOTIFICATION);
58
59 // Dummy notification id. Every metro style notification needs a
60 // unique notification id.
61 std::string notification_id = kDownloadNotificationPrefix;
62 notification_id += base::IntToString(g_next_notification_id++);
63
64 display_notification(download->GetURL().spec().c_str(),
65 "",
66 title.c_str(),
67 body.c_str(),
68 L"",
69 notification_id.c_str());
70 }
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698