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/extensions/api/downloads/downloads_api.h" | 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1238 downloads::AcceptDanger::Params::Create(*args_)); | 1238 downloads::AcceptDanger::Params::Create(*args_)); |
1239 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1239 EXTENSION_FUNCTION_VALIDATE(params.get()); |
1240 PromptOrWait(params->download_id, 10); | 1240 PromptOrWait(params->download_id, 10); |
1241 return true; | 1241 return true; |
1242 } | 1242 } |
1243 | 1243 |
1244 void DownloadsAcceptDangerFunction::PromptOrWait(int download_id, int retries) { | 1244 void DownloadsAcceptDangerFunction::PromptOrWait(int download_id, int retries) { |
1245 DownloadItem* download_item = | 1245 DownloadItem* download_item = |
1246 GetDownload(GetProfile(), include_incognito(), download_id); | 1246 GetDownload(GetProfile(), include_incognito(), download_id); |
1247 content::WebContents* web_contents = | 1247 content::WebContents* web_contents = |
1248 dispatcher()->delegate()->GetVisibleWebContents(); | 1248 dispatcher()->GetVisibleWebContents(); |
not at google - send to devlin
2015/06/10 18:37:49
I think this will fit on 1 line (and I would hope
Devlin
2015/06/10 20:59:20
Done.
| |
1249 if (InvalidId(download_item, &error_) || | 1249 if (InvalidId(download_item, &error_) || |
1250 Fault(download_item->GetState() != DownloadItem::IN_PROGRESS, | 1250 Fault(download_item->GetState() != DownloadItem::IN_PROGRESS, |
1251 errors::kNotInProgress, &error_) || | 1251 errors::kNotInProgress, &error_) || |
1252 Fault(!download_item->IsDangerous(), errors::kNotDangerous, &error_) || | 1252 Fault(!download_item->IsDangerous(), errors::kNotDangerous, &error_) || |
1253 Fault(!web_contents, errors::kInvisibleContext, &error_)) { | 1253 Fault(!web_contents, errors::kInvisibleContext, &error_)) { |
1254 SendResponse(error_.empty()); | 1254 SendResponse(error_.empty()); |
1255 return; | 1255 return; |
1256 } | 1256 } |
1257 bool visible = platform_util::IsVisible(web_contents->GetNativeView()); | 1257 bool visible = platform_util::IsVisible(web_contents->GetNativeView()); |
1258 if (!visible) { | 1258 if (!visible) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1366 | 1366 |
1367 DownloadsDragFunction::~DownloadsDragFunction() {} | 1367 DownloadsDragFunction::~DownloadsDragFunction() {} |
1368 | 1368 |
1369 bool DownloadsDragFunction::RunAsync() { | 1369 bool DownloadsDragFunction::RunAsync() { |
1370 scoped_ptr<downloads::Drag::Params> params( | 1370 scoped_ptr<downloads::Drag::Params> params( |
1371 downloads::Drag::Params::Create(*args_)); | 1371 downloads::Drag::Params::Create(*args_)); |
1372 EXTENSION_FUNCTION_VALIDATE(params.get()); | 1372 EXTENSION_FUNCTION_VALIDATE(params.get()); |
1373 DownloadItem* download_item = | 1373 DownloadItem* download_item = |
1374 GetDownload(GetProfile(), include_incognito(), params->download_id); | 1374 GetDownload(GetProfile(), include_incognito(), params->download_id); |
1375 content::WebContents* web_contents = | 1375 content::WebContents* web_contents = |
1376 dispatcher()->delegate()->GetVisibleWebContents(); | 1376 dispatcher()->GetVisibleWebContents(); |
1377 if (InvalidId(download_item, &error_) || | 1377 if (InvalidId(download_item, &error_) || |
1378 Fault(!web_contents, errors::kInvisibleContext, &error_)) | 1378 Fault(!web_contents, errors::kInvisibleContext, &error_)) |
1379 return false; | 1379 return false; |
1380 RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG); | 1380 RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG); |
1381 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( | 1381 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( |
1382 download_item->GetTargetFilePath(), IconLoader::NORMAL); | 1382 download_item->GetTargetFilePath(), IconLoader::NORMAL); |
1383 gfx::NativeView view = web_contents->GetNativeView(); | 1383 gfx::NativeView view = web_contents->GetNativeView(); |
1384 { | 1384 { |
1385 // Enable nested tasks during DnD, while |DragDownload()| blocks. | 1385 // Enable nested tasks during DnD, while |DragDownload()| blocks. |
1386 base::MessageLoop::ScopedNestableTaskAllower allow( | 1386 base::MessageLoop::ScopedNestableTaskAllower allow( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1475 Fault(download_item->GetTargetFilePath().empty(), | 1475 Fault(download_item->GetTargetFilePath().empty(), |
1476 errors::kEmptyFile, &error_)) | 1476 errors::kEmptyFile, &error_)) |
1477 return false; | 1477 return false; |
1478 // In-progress downloads return the intermediate filename for GetFullPath() | 1478 // In-progress downloads return the intermediate filename for GetFullPath() |
1479 // which doesn't have the final extension. Therefore a good file icon can't be | 1479 // which doesn't have the final extension. Therefore a good file icon can't be |
1480 // found, so use GetTargetFilePath() instead. | 1480 // found, so use GetTargetFilePath() instead. |
1481 DCHECK(icon_extractor_.get()); | 1481 DCHECK(icon_extractor_.get()); |
1482 DCHECK(icon_size == 16 || icon_size == 32); | 1482 DCHECK(icon_size == 16 || icon_size == 32); |
1483 float scale = 1.0; | 1483 float scale = 1.0; |
1484 content::WebContents* web_contents = | 1484 content::WebContents* web_contents = |
1485 dispatcher()->delegate()->GetVisibleWebContents(); | 1485 dispatcher()->GetVisibleWebContents(); |
1486 if (web_contents) { | 1486 if (web_contents) { |
1487 scale = ui::GetScaleFactorForNativeView( | 1487 scale = ui::GetScaleFactorForNativeView( |
1488 web_contents->GetRenderWidgetHostView()->GetNativeView()); | 1488 web_contents->GetRenderWidgetHostView()->GetNativeView()); |
1489 } | 1489 } |
1490 EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath( | 1490 EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath( |
1491 download_item->GetTargetFilePath(), | 1491 download_item->GetTargetFilePath(), |
1492 scale, | 1492 scale, |
1493 IconLoaderSizeFromPixelSize(icon_size), | 1493 IconLoaderSizeFromPixelSize(icon_size), |
1494 base::Bind(&DownloadsGetFileIconFunction::OnIconURLExtracted, this))); | 1494 base::Bind(&DownloadsGetFileIconFunction::OnIconURLExtracted, this))); |
1495 return true; | 1495 return true; |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1900 return; | 1900 return; |
1901 base::Time now(base::Time::Now()); | 1901 base::Time now(base::Time::Now()); |
1902 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); | 1902 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); |
1903 if (delta <= kFileExistenceRateLimitSeconds) | 1903 if (delta <= kFileExistenceRateLimitSeconds) |
1904 return; | 1904 return; |
1905 last_checked_removal_ = now; | 1905 last_checked_removal_ = now; |
1906 manager->CheckForHistoryFilesRemoval(); | 1906 manager->CheckForHistoryFilesRemoval(); |
1907 } | 1907 } |
1908 | 1908 |
1909 } // namespace extensions | 1909 } // namespace extensions |
OLD | NEW |