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

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: Latest-er master 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 } // namespace 64 } // namespace
65 65
66 // Tests can call this method to inject a mock ExtensionInstallPrompt 66 // Tests can call this method to inject a mock ExtensionInstallPrompt
67 // to be used to confirm permissions on a downloaded CRX. 67 // to be used to confirm permissions on a downloaded CRX.
68 void SetMockInstallPromptForTesting(ExtensionInstallPrompt* mock_prompt) { 68 void SetMockInstallPromptForTesting(ExtensionInstallPrompt* mock_prompt) {
69 mock_install_prompt_for_testing = mock_prompt; 69 mock_install_prompt_for_testing = mock_prompt;
70 } 70 }
71 71
72 scoped_refptr<CrxInstaller> OpenChromeExtension( 72 scoped_refptr<extensions::CrxInstaller> OpenChromeExtension(
73 Profile* profile, 73 Profile* profile,
74 const DownloadItem& download_item) { 74 const DownloadItem& download_item) {
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
76 76
77 ExtensionService* service = profile->GetExtensionService(); 77 ExtensionService* service = profile->GetExtensionService();
78 CHECK(service); 78 CHECK(service);
79 79
80 scoped_refptr<CrxInstaller> installer( 80 scoped_refptr<extensions::CrxInstaller> installer(
81 CrxInstaller::Create( 81 extensions::CrxInstaller::Create(
82 service, 82 service,
83 CreateExtensionInstallPrompt(profile), 83 CreateExtensionInstallPrompt(profile),
84 WebstoreInstaller::GetAssociatedApproval(download_item))); 84 WebstoreInstaller::GetAssociatedApproval(download_item)));
85 85
86 installer->set_delete_source(true); 86 installer->set_delete_source(true);
87 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD); 87 installer->set_install_cause(extension_misc::INSTALL_CAUSE_USER_DOWNLOAD);
88 88
89 if (OffStoreInstallAllowedByPrefs(profile, download_item)) { 89 if (OffStoreInstallAllowedByPrefs(profile, download_item)) {
90 installer->set_off_store_install_allow_reason( 90 installer->set_off_store_install_allow_reason(
91 CrxInstaller::OffStoreInstallAllowedBecausePref); 91 extensions::CrxInstaller::OffStoreInstallAllowedBecausePref);
92 } 92 }
93 93
94 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(), 94 if (extensions::UserScript::IsURLUserScript(download_item.GetURL(),
95 download_item.GetMimeType())) { 95 download_item.GetMimeType())) {
96 installer->InstallUserScript(download_item.GetFullPath(), 96 installer->InstallUserScript(download_item.GetFullPath(),
97 download_item.GetURL()); 97 download_item.GetURL());
98 } else { 98 } else {
99 bool is_gallery_download = 99 bool is_gallery_download =
100 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL; 100 WebstoreInstaller::GetAssociatedApproval(download_item) != NULL;
101 installer->set_original_mime_type(download_item.GetOriginalMimeType()); 101 installer->set_original_mime_type(download_item.GetOriginalMimeType());
(...skipping 17 matching lines...) Expand all
119 if (download_item.GetMimeType() == extensions::Extension::kMimeType || 119 if (download_item.GetMimeType() == extensions::Extension::kMimeType ||
120 extensions::UserScript::IsURLUserScript(download_item.GetURL(), 120 extensions::UserScript::IsURLUserScript(download_item.GetURL(),
121 download_item.GetMimeType())) { 121 download_item.GetMimeType())) {
122 return true; 122 return true;
123 } else { 123 } else {
124 return false; 124 return false;
125 } 125 }
126 } 126 }
127 127
128 } // namespace download_crx_util 128 } // namespace download_crx_util
OLDNEW
« no previous file with comments | « chrome/browser/download/download_crx_util.h ('k') | chrome/browser/download/download_crx_util_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698