OLD | NEW |
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/download/download_completion_observer_win.h" | 5 #include "chrome/browser/download/download_completion_observer_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 void DownloadCompletionObserver::ManagerGoingDown(DownloadManager* manager) { | 40 void DownloadCompletionObserver::ManagerGoingDown(DownloadManager* manager) { |
41 ClearDownloadItems(); | 41 ClearDownloadItems(); |
42 manager->RemoveObserver(this); | 42 manager->RemoveObserver(this); |
43 delete this; | 43 delete this; |
44 } | 44 } |
45 | 45 |
46 void DownloadCompletionObserver::OnDownloadUpdated(DownloadItem* download) { | 46 void DownloadCompletionObserver::OnDownloadUpdated(DownloadItem* download) { |
47 if (!base::win::IsMetroProcess()) | |
48 return; | |
49 | |
50 switch (download->GetState()) { | 47 switch (download->GetState()) { |
51 case DownloadItem::COMPLETE: { | 48 case DownloadItem::COMPLETE: { |
52 if (!download->GetOpenWhenComplete() && | 49 if (base::win::IsMetroProcess() && |
| 50 !download->GetOpenWhenComplete() && |
53 !download->ShouldOpenFileBasedOnExtension() && | 51 !download->ShouldOpenFileBasedOnExtension() && |
54 !download->IsTemporary() && | 52 !download->IsTemporary() && |
55 !download->GetAutoOpened()) { | 53 !download->GetAutoOpened()) { |
56 // In Windows 8 metro mode display a metro style notification which | 54 // In Windows 8 metro mode display a metro style notification which |
57 // informs the user that the download is complete. | 55 // informs the user that the download is complete. |
58 HMODULE metro = base::win::GetMetroModule(); | 56 HMODULE metro = base::win::GetMetroModule(); |
59 base::win::MetroNotification display_notification = | 57 base::win::MetroNotification display_notification = |
60 reinterpret_cast< base::win::MetroNotification>( | 58 reinterpret_cast< base::win::MetroNotification>( |
61 ::GetProcAddress(metro, "DisplayNotification")); | 59 ::GetProcAddress(metro, "DisplayNotification")); |
62 DCHECK(display_notification); | 60 DCHECK(display_notification); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 97 } |
100 } | 98 } |
101 | 99 |
102 void DownloadCompletionObserver::ClearDownloadItems() { | 100 void DownloadCompletionObserver::ClearDownloadItems() { |
103 for (std::set<DownloadItem*>::iterator it = download_items_.begin(); | 101 for (std::set<DownloadItem*>::iterator it = download_items_.begin(); |
104 it != download_items_.end(); ++it) { | 102 it != download_items_.end(); ++it) { |
105 (*it)->RemoveObserver(this); | 103 (*it)->RemoveObserver(this); |
106 } | 104 } |
107 download_items_.clear(); | 105 download_items_.clear(); |
108 } | 106 } |
OLD | NEW |