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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 1169223002: [Extensions] Clean up the handling of ExtensionHostMsg_Request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 6 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
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/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 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 scoped_ptr<downloads::AcceptDanger::Params> params( 1237 scoped_ptr<downloads::AcceptDanger::Params> params(
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 = dispatcher()->GetVisibleWebContents();
1248 dispatcher()->delegate()->GetVisibleWebContents();
1249 if (InvalidId(download_item, &error_) || 1248 if (InvalidId(download_item, &error_) ||
1250 Fault(download_item->GetState() != DownloadItem::IN_PROGRESS, 1249 Fault(download_item->GetState() != DownloadItem::IN_PROGRESS,
1251 errors::kNotInProgress, &error_) || 1250 errors::kNotInProgress, &error_) ||
1252 Fault(!download_item->IsDangerous(), errors::kNotDangerous, &error_) || 1251 Fault(!download_item->IsDangerous(), errors::kNotDangerous, &error_) ||
1253 Fault(!web_contents, errors::kInvisibleContext, &error_)) { 1252 Fault(!web_contents, errors::kInvisibleContext, &error_)) {
1254 SendResponse(error_.empty()); 1253 SendResponse(error_.empty());
1255 return; 1254 return;
1256 } 1255 }
1257 bool visible = platform_util::IsVisible(web_contents->GetNativeView()); 1256 bool visible = platform_util::IsVisible(web_contents->GetNativeView());
1258 if (!visible) { 1257 if (!visible) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 1365
1367 DownloadsDragFunction::~DownloadsDragFunction() {} 1366 DownloadsDragFunction::~DownloadsDragFunction() {}
1368 1367
1369 bool DownloadsDragFunction::RunAsync() { 1368 bool DownloadsDragFunction::RunAsync() {
1370 scoped_ptr<downloads::Drag::Params> params( 1369 scoped_ptr<downloads::Drag::Params> params(
1371 downloads::Drag::Params::Create(*args_)); 1370 downloads::Drag::Params::Create(*args_));
1372 EXTENSION_FUNCTION_VALIDATE(params.get()); 1371 EXTENSION_FUNCTION_VALIDATE(params.get());
1373 DownloadItem* download_item = 1372 DownloadItem* download_item =
1374 GetDownload(GetProfile(), include_incognito(), params->download_id); 1373 GetDownload(GetProfile(), include_incognito(), params->download_id);
1375 content::WebContents* web_contents = 1374 content::WebContents* web_contents =
1376 dispatcher()->delegate()->GetVisibleWebContents(); 1375 dispatcher()->GetVisibleWebContents();
1377 if (InvalidId(download_item, &error_) || 1376 if (InvalidId(download_item, &error_) ||
1378 Fault(!web_contents, errors::kInvisibleContext, &error_)) 1377 Fault(!web_contents, errors::kInvisibleContext, &error_))
1379 return false; 1378 return false;
1380 RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG); 1379 RecordApiFunctions(DOWNLOADS_FUNCTION_DRAG);
1381 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( 1380 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath(
1382 download_item->GetTargetFilePath(), IconLoader::NORMAL); 1381 download_item->GetTargetFilePath(), IconLoader::NORMAL);
1383 gfx::NativeView view = web_contents->GetNativeView(); 1382 gfx::NativeView view = web_contents->GetNativeView();
1384 { 1383 {
1385 // Enable nested tasks during DnD, while |DragDownload()| blocks. 1384 // Enable nested tasks during DnD, while |DragDownload()| blocks.
1386 base::MessageLoop::ScopedNestableTaskAllower allow( 1385 base::MessageLoop::ScopedNestableTaskAllower allow(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 Fault(download_item->GetTargetFilePath().empty(), 1474 Fault(download_item->GetTargetFilePath().empty(),
1476 errors::kEmptyFile, &error_)) 1475 errors::kEmptyFile, &error_))
1477 return false; 1476 return false;
1478 // In-progress downloads return the intermediate filename for GetFullPath() 1477 // 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 1478 // which doesn't have the final extension. Therefore a good file icon can't be
1480 // found, so use GetTargetFilePath() instead. 1479 // found, so use GetTargetFilePath() instead.
1481 DCHECK(icon_extractor_.get()); 1480 DCHECK(icon_extractor_.get());
1482 DCHECK(icon_size == 16 || icon_size == 32); 1481 DCHECK(icon_size == 16 || icon_size == 32);
1483 float scale = 1.0; 1482 float scale = 1.0;
1484 content::WebContents* web_contents = 1483 content::WebContents* web_contents =
1485 dispatcher()->delegate()->GetVisibleWebContents(); 1484 dispatcher()->GetVisibleWebContents();
1486 if (web_contents) { 1485 if (web_contents) {
1487 scale = ui::GetScaleFactorForNativeView( 1486 scale = ui::GetScaleFactorForNativeView(
1488 web_contents->GetRenderWidgetHostView()->GetNativeView()); 1487 web_contents->GetRenderWidgetHostView()->GetNativeView());
1489 } 1488 }
1490 EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath( 1489 EXTENSION_FUNCTION_VALIDATE(icon_extractor_->ExtractIconURLForPath(
1491 download_item->GetTargetFilePath(), 1490 download_item->GetTargetFilePath(),
1492 scale, 1491 scale,
1493 IconLoaderSizeFromPixelSize(icon_size), 1492 IconLoaderSizeFromPixelSize(icon_size),
1494 base::Bind(&DownloadsGetFileIconFunction::OnIconURLExtracted, this))); 1493 base::Bind(&DownloadsGetFileIconFunction::OnIconURLExtracted, this)));
1495 return true; 1494 return true;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 return; 1899 return;
1901 base::Time now(base::Time::Now()); 1900 base::Time now(base::Time::Now());
1902 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); 1901 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT();
1903 if (delta <= kFileExistenceRateLimitSeconds) 1902 if (delta <= kFileExistenceRateLimitSeconds)
1904 return; 1903 return;
1905 last_checked_removal_ = now; 1904 last_checked_removal_ = now;
1906 manager->CheckForHistoryFilesRemoval(); 1905 manager->CheckForHistoryFilesRemoval();
1907 } 1906 }
1908 1907
1909 } // namespace extensions 1908 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/chrome_extensions_api_client.cc ('k') | chrome/browser/extensions/api/tabs/ash_panel_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698