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

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

Issue 10266015: Add the --disable-off-store-extension-install switch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 8 years, 7 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
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 // Download code which handles CRX files (extensions, themes, apps, ...). 5 // Download code which handles CRX files (extensions, themes, apps, ...).
6 6
7 #include "chrome/browser/download/download_util.h" 7 #include "chrome/browser/download/download_util.h"
8 #include "chrome/browser/extensions/crx_installer.h" 8 #include "chrome/browser/extensions/crx_installer.h"
9 #include "chrome/browser/extensions/extension_install_ui.h" 9 #include "chrome/browser/extensions/extension_install_ui.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/webstore_installer.h" 11 #include "chrome/browser/extensions/webstore_installer.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/extensions/switch_utils.h"
14 #include "content/public/browser/download_item.h" 15 #include "content/public/browser/download_item.h"
15 #include "content/public/browser/notification_service.h" 16 #include "content/public/browser/notification_service.h"
16 17
17 using content::BrowserThread; 18 using content::BrowserThread;
18 using content::DownloadItem; 19 using content::DownloadItem;
19 20
20 namespace download_crx_util { 21 namespace download_crx_util {
21 22
22 namespace { 23 namespace {
23 24
(...skipping 19 matching lines...) Expand all
43 } 44 }
44 45
45 } // namespace 46 } // namespace
46 47
47 // Tests can call this method to inject a mock ExtensionInstallUI 48 // Tests can call this method to inject a mock ExtensionInstallUI
48 // to be used to confirm permissions on a downloaded CRX. 49 // to be used to confirm permissions on a downloaded CRX.
49 void SetMockInstallUIForTesting(ExtensionInstallUI* mock_ui) { 50 void SetMockInstallUIForTesting(ExtensionInstallUI* mock_ui) {
50 mock_install_ui_for_testing = mock_ui; 51 mock_install_ui_for_testing = mock_ui;
51 } 52 }
52 53
54 bool ShouldOpenExtensionDownload(const DownloadItem& download_item) {
55 if (extensions::switch_utils::IsOffStoreInstallEnabled() &&
benjhayden 2012/04/30 19:26:12 Can you just return this condition directly?
benjhayden 2012/04/30 19:26:12 Do you anticipate needing to call IsOffStoreInstal
Aaron Boodman 2012/04/30 20:23:41 I think it reads more clearly to use a traditional
Aaron Boodman 2012/04/30 20:23:41 Yes.
56 WebstoreInstaller::GetAssociatedApproval(download_item)) {
57 return true;
58 } else {
59 return false;
60 }
61 }
62
53 scoped_refptr<CrxInstaller> OpenChromeExtension( 63 scoped_refptr<CrxInstaller> OpenChromeExtension(
54 Profile* profile, 64 Profile* profile,
55 const DownloadItem& download_item) { 65 const DownloadItem& download_item) {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
57 67
58 ExtensionService* service = profile->GetExtensionService(); 68 ExtensionService* service = profile->GetExtensionService();
59 CHECK(service); 69 CHECK(service);
60 70
61 scoped_refptr<CrxInstaller> installer( 71 scoped_refptr<CrxInstaller> installer(
62 CrxInstaller::Create( 72 CrxInstaller::Create(
(...skipping 17 matching lines...) Expand all
80 installer->set_original_download_url(download_item.GetOriginalUrl()); 90 installer->set_original_download_url(download_item.GetOriginalUrl());
81 installer->set_allow_silent_install(is_gallery_download); 91 installer->set_allow_silent_install(is_gallery_download);
82 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); 92 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD);
83 installer->InstallCrx(download_item.GetFullPath()); 93 installer->InstallCrx(download_item.GetFullPath());
84 } 94 }
85 95
86 return installer; 96 return installer;
87 } 97 }
88 98
89 } // namespace download_crx_util 99 } // namespace download_crx_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698