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

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

Issue 10836161: Fix the browser test DownloadExtensionTest_FileIcon_Active crash which started occurring after my c… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698