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

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

Issue 10683003: Moved CrxInstaller and CrxInstallerError into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 // 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_prompt.h" 9 #include "chrome/browser/extensions/extension_install_prompt.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 } // namespace 63 } // namespace
64 64
65 // Tests can call this method to inject a mock ExtensionInstallPrompt 65 // Tests can call this method to inject a mock ExtensionInstallPrompt
66 // to be used to confirm permissions on a downloaded CRX. 66 // to be used to confirm permissions on a downloaded CRX.
67 void SetMockInstallPromptForTesting(ExtensionInstallPrompt* mock_prompt) { 67 void SetMockInstallPromptForTesting(ExtensionInstallPrompt* mock_prompt) {
68 mock_install_prompt_for_testing = mock_prompt; 68 mock_install_prompt_for_testing = mock_prompt;
69 } 69 }
70 70
71 scoped_refptr<CrxInstaller> OpenChromeExtension( 71 scoped_refptr<extensions::CrxInstaller> OpenChromeExtension(
72 Profile* profile, 72 Profile* profile,
73 const DownloadItem& download_item) { 73 const DownloadItem& download_item) {
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
75 75
76 ExtensionService* service = profile->GetExtensionService(); 76 ExtensionService* service = profile->GetExtensionService();
77 CHECK(service); 77 CHECK(service);
78 78
79 scoped_refptr<CrxInstaller> installer( 79 scoped_refptr<extensions::CrxInstaller> installer(
80 CrxInstaller::Create( 80 extensions::CrxInstaller::Create(
81 service, 81 service,
82 CreateExtensionInstallPrompt(profile), 82 CreateExtensionInstallPrompt(profile),
83 WebstoreInstaller::GetAssociatedApproval(download_item))); 83 WebstoreInstaller::GetAssociatedApproval(download_item)));
84 84
85 installer->set_delete_source(true); 85 installer->set_delete_source(true);
86 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); 86 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD);
87 87
88 if (OffStoreInstallAllowedByPrefs(profile, download_item)) { 88 if (OffStoreInstallAllowedByPrefs(profile, download_item)) {
89 installer->set_off_store_install_allow_reason( 89 installer->set_off_store_install_allow_reason(
90 CrxInstaller::OffStoreInstallAllowedBecausePref); 90 extensions::CrxInstaller::OffStoreInstallAllowedBecausePref);
91 } 91 }
92 92
93 if (UserScript::IsURLUserScript(download_item.GetURL(), 93 if (UserScript::IsURLUserScript(download_item.GetURL(),
94 download_item.GetMimeType())) { 94 download_item.GetMimeType())) {
95 installer->InstallUserScript(download_item.GetFullPath(), 95 installer->InstallUserScript(download_item.GetFullPath(),
96 download_item.GetURL()); 96 download_item.GetURL());
97 } else { 97 } else {
98 bool is_gallery_download = 98 bool is_gallery_download =
99 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL; 99 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL;
100 installer->set_original_mime_type(download_item.GetOriginalMimeType()); 100 installer->set_original_mime_type(download_item.GetOriginalMimeType());
(...skipping 17 matching lines...) Expand all
118 if (download_item.GetMimeType() == extensions::Extension::kMimeType || 118 if (download_item.GetMimeType() == extensions::Extension::kMimeType ||
119 UserScript::IsURLUserScript(download_item.GetURL(), 119 UserScript::IsURLUserScript(download_item.GetURL(),
120 download_item.GetMimeType())) { 120 download_item.GetMimeType())) {
121 return true; 121 return true;
122 } else { 122 } else {
123 return false; 123 return false;
124 } 124 }
125 } 125 }
126 126
127 } // namespace download_crx_util 127 } // namespace download_crx_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698