OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell_download_manager_delegate.h" | 5 #include "content/shell/browser/shell_download_manager_delegate.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <commdlg.h> | 9 #include <commdlg.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/download_manager.h" | 20 #include "content/public/browser/download_manager.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "content/shell/browser/webkit_test_controller.h" | |
23 #include "content/shell/common/shell_switches.h" | 22 #include "content/shell/common/shell_switches.h" |
24 #include "net/base/filename_util.h" | 23 #include "net/base/filename_util.h" |
25 | 24 |
26 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
27 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
28 #include "ui/aura/window_tree_host.h" | 27 #include "ui/aura/window_tree_host.h" |
29 #endif | 28 #endif |
30 | 29 |
31 namespace content { | 30 namespace content { |
32 | 31 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 download->GetSuggestedFilename(), | 90 download->GetSuggestedFilename(), |
92 download->GetMimeType(), | 91 download->GetMimeType(), |
93 default_download_path_, | 92 default_download_path_, |
94 filename_determined_callback)); | 93 filename_determined_callback)); |
95 return true; | 94 return true; |
96 } | 95 } |
97 | 96 |
98 bool ShellDownloadManagerDelegate::ShouldOpenDownload( | 97 bool ShellDownloadManagerDelegate::ShouldOpenDownload( |
99 DownloadItem* item, | 98 DownloadItem* item, |
100 const DownloadOpenDelayedCallback& callback) { | 99 const DownloadOpenDelayedCallback& callback) { |
101 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree) && | |
102 WebKitTestController::Get()->IsMainWindow(item->GetWebContents()) && | |
103 item->GetMimeType() == "text/html") { | |
104 WebKitTestController::Get()->OpenURL( | |
105 net::FilePathToFileURL(item->GetFullPath())); | |
106 } | |
107 return true; | 100 return true; |
108 } | 101 } |
109 | 102 |
110 void ShellDownloadManagerDelegate::GetNextId( | 103 void ShellDownloadManagerDelegate::GetNextId( |
111 const DownloadIdCallback& callback) { | 104 const DownloadIdCallback& callback) { |
112 static uint32 next_id = DownloadItem::kInvalidId + 1; | 105 static uint32 next_id = DownloadItem::kInvalidId + 1; |
113 callback.Run(next_id++); | 106 callback.Run(next_id++); |
114 } | 107 } |
115 | 108 |
116 // static | 109 // static |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, result); | 186 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, result); |
194 } | 187 } |
195 | 188 |
196 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting( | 189 void ShellDownloadManagerDelegate::SetDownloadBehaviorForTesting( |
197 const base::FilePath& default_download_path) { | 190 const base::FilePath& default_download_path) { |
198 default_download_path_ = default_download_path; | 191 default_download_path_ = default_download_path; |
199 suppress_prompting_ = true; | 192 suppress_prompting_ = true; |
200 } | 193 } |
201 | 194 |
202 } // namespace content | 195 } // namespace content |
OLD | NEW |