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

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

Issue 226023003: Create CrxInstaller directly in WebstoreInstaller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android compilation fix (again). Created 6 years, 8 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/download/chrome_download_manager_delegate.h" 5 #include "chrome/browser/download/chrome_download_manager_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 17 matching lines...) Expand all
28 #include "chrome/browser/download/download_item_model.h" 28 #include "chrome/browser/download/download_item_model.h"
29 #include "chrome/browser/download/download_path_reservation_tracker.h" 29 #include "chrome/browser/download/download_path_reservation_tracker.h"
30 #include "chrome/browser/download/download_prefs.h" 30 #include "chrome/browser/download/download_prefs.h"
31 #include "chrome/browser/download/download_service.h" 31 #include "chrome/browser/download/download_service.h"
32 #include "chrome/browser/download/download_service_factory.h" 32 #include "chrome/browser/download/download_service_factory.h"
33 #include "chrome/browser/download/download_stats.h" 33 #include "chrome/browser/download/download_stats.h"
34 #include "chrome/browser/download/download_target_determiner.h" 34 #include "chrome/browser/download/download_target_determiner.h"
35 #include "chrome/browser/download/save_package_file_picker.h" 35 #include "chrome/browser/download/save_package_file_picker.h"
36 #include "chrome/browser/extensions/api/downloads/downloads_api.h" 36 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
37 #include "chrome/browser/extensions/crx_installer.h" 37 #include "chrome/browser/extensions/crx_installer.h"
38 #include "chrome/browser/extensions/webstore_installer.h"
38 #include "chrome/browser/platform_util.h" 39 #include "chrome/browser/platform_util.h"
39 #include "chrome/browser/profiles/profile.h" 40 #include "chrome/browser/profiles/profile.h"
40 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 41 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
41 #include "chrome/browser/ui/browser.h" 42 #include "chrome/browser/ui/browser.h"
42 #include "chrome/browser/ui/browser_finder.h" 43 #include "chrome/browser/ui/browser_finder.h"
43 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 44 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
44 #include "chrome/common/chrome_constants.h" 45 #include "chrome/common/chrome_constants.h"
45 #include "chrome/common/pref_names.h" 46 #include "chrome/common/pref_names.h"
46 #include "components/user_prefs/pref_registry_syncable.h" 47 #include "components/user_prefs/pref_registry_syncable.h"
47 #include "content/public/browser/download_item.h" 48 #include "content/public/browser/download_item.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 bool ChromeDownloadManagerDelegate::ShouldCompleteDownload( 363 bool ChromeDownloadManagerDelegate::ShouldCompleteDownload(
363 DownloadItem* item, 364 DownloadItem* item,
364 const base::Closure& user_complete_callback) { 365 const base::Closure& user_complete_callback) {
365 return IsDownloadReadyForCompletion(item, base::Bind( 366 return IsDownloadReadyForCompletion(item, base::Bind(
366 &ChromeDownloadManagerDelegate::ShouldCompleteDownloadInternal, 367 &ChromeDownloadManagerDelegate::ShouldCompleteDownloadInternal,
367 weak_ptr_factory_.GetWeakPtr(), item->GetId(), user_complete_callback)); 368 weak_ptr_factory_.GetWeakPtr(), item->GetId(), user_complete_callback));
368 } 369 }
369 370
370 bool ChromeDownloadManagerDelegate::ShouldOpenDownload( 371 bool ChromeDownloadManagerDelegate::ShouldOpenDownload(
371 DownloadItem* item, const content::DownloadOpenDelayedCallback& callback) { 372 DownloadItem* item, const content::DownloadOpenDelayedCallback& callback) {
372 if (download_crx_util::IsExtensionDownload(*item)) { 373 if (download_crx_util::IsExtensionDownload(*item) &&
374 !extensions::WebstoreInstaller::GetAssociatedApproval(*item)) {
373 scoped_refptr<extensions::CrxInstaller> crx_installer = 375 scoped_refptr<extensions::CrxInstaller> crx_installer =
374 download_crx_util::OpenChromeExtension(profile_, *item); 376 download_crx_util::OpenChromeExtension(profile_, *item);
375 377
376 // CRX_INSTALLER_DONE will fire when the install completes. At that 378 // CRX_INSTALLER_DONE will fire when the install completes. At that
377 // time, Observe() will call the passed callback. 379 // time, Observe() will call the passed callback.
378 registrar_.Add( 380 registrar_.Add(
379 this, 381 this,
380 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 382 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
381 content::Source<extensions::CrxInstaller>(crx_installer.get())); 383 content::Source<extensions::CrxInstaller>(crx_installer.get()));
382 384
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 DownloadItem* item = download_manager_->GetDownload(download_id); 706 DownloadItem* item = download_manager_->GetDownload(download_id);
705 if (!target_info->target_path.empty() && item && 707 if (!target_info->target_path.empty() && item &&
706 IsOpenInBrowserPreferreredForFile(target_info->target_path) && 708 IsOpenInBrowserPreferreredForFile(target_info->target_path) &&
707 target_info->is_filetype_handled_safely) 709 target_info->is_filetype_handled_safely)
708 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true); 710 DownloadItemModel(item).SetShouldPreferOpeningInBrowser(true);
709 callback.Run(target_info->target_path, 711 callback.Run(target_info->target_path,
710 target_info->target_disposition, 712 target_info->target_disposition,
711 target_info->danger_type, 713 target_info->danger_type,
712 target_info->intermediate_path); 714 target_info->intermediate_path);
713 } 715 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/ephemeral_app_browsertest.cc ('k') | chrome/browser/download/download_crx_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698