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

Side by Side Diff: chrome/browser/extensions/crx_installer.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 #include "chrome/browser/extensions/crx_installer.h" 5 #include "chrome/browser/extensions/crx_installer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/public/browser/user_metrics.h" 45 #include "content/public/browser/user_metrics.h"
46 #include "grit/chromium_strings.h" 46 #include "grit/chromium_strings.h"
47 #include "grit/generated_resources.h" 47 #include "grit/generated_resources.h"
48 #include "grit/theme_resources.h" 48 #include "grit/theme_resources.h"
49 #include "third_party/skia/include/core/SkBitmap.h" 49 #include "third_party/skia/include/core/SkBitmap.h"
50 #include "ui/base/l10n/l10n_util.h" 50 #include "ui/base/l10n/l10n_util.h"
51 #include "ui/base/resource/resource_bundle.h" 51 #include "ui/base/resource/resource_bundle.h"
52 52
53 using content::BrowserThread; 53 using content::BrowserThread;
54 using content::UserMetricsAction; 54 using content::UserMetricsAction;
55 using extensions::Extension;
56 using extensions::PermissionsUpdater;
57 55
58 namespace { 56 namespace {
59 57
60 // Used in histograms; do not change order. 58 // Used in histograms; do not change order.
61 enum OffStoreInstallDecision { 59 enum OffStoreInstallDecision {
62 OnStoreInstall, 60 OnStoreInstall,
63 OffStoreInstallAllowed, 61 OffStoreInstallAllowed,
64 OffStoreInstallDisallowed, 62 OffStoreInstallDisallowed,
65 NumOffStoreInstallDecision 63 NumOffStoreInstallDecision
66 }; 64 };
67 65
68 } // namespace 66 } // namespace
69 67
68 namespace extensions {
not at google - send to devlin 2012/07/04 01:13:31 I think that usually the namespace would surround
69
70 // static 70 // static
71 scoped_refptr<CrxInstaller> CrxInstaller::Create( 71 scoped_refptr<CrxInstaller> CrxInstaller::Create(
72 ExtensionService* frontend, 72 ExtensionService* frontend,
73 ExtensionInstallPrompt* client) { 73 ExtensionInstallPrompt* client) {
74 return new CrxInstaller(frontend->AsWeakPtr(), client, NULL); 74 return new CrxInstaller(frontend->AsWeakPtr(), client, NULL);
75 } 75 }
76 76
77 // static 77 // static
78 scoped_refptr<CrxInstaller> CrxInstaller::Create( 78 scoped_refptr<CrxInstaller> CrxInstaller::Create(
79 ExtensionService* frontend, 79 ExtensionService* frontend,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 base::Bind(&extension_file_util::DeleteFile, source_file_, false)); 134 base::Bind(&extension_file_util::DeleteFile, source_file_, false));
135 } 135 }
136 // Make sure the UI is deleted on the ui thread. 136 // Make sure the UI is deleted on the ui thread.
137 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, client_); 137 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, client_);
138 client_ = NULL; 138 client_ = NULL;
139 } 139 }
140 140
141 void CrxInstaller::InstallCrx(const FilePath& source_file) { 141 void CrxInstaller::InstallCrx(const FilePath& source_file) {
142 source_file_ = source_file; 142 source_file_ = source_file;
143 143
144 scoped_refptr<extensions::SandboxedUnpacker> unpacker( 144 scoped_refptr<SandboxedUnpacker> unpacker(
145 new extensions::SandboxedUnpacker( 145 new SandboxedUnpacker(
146 source_file, 146 source_file,
147 content::ResourceDispatcherHost::Get() != NULL, 147 content::ResourceDispatcherHost::Get() != NULL,
148 install_source_, 148 install_source_,
149 creation_flags_, 149 creation_flags_,
150 this)); 150 this));
151 151
152 if (!BrowserThread::PostTask( 152 if (!BrowserThread::PostTask(
153 BrowserThread::FILE, FROM_HERE, 153 BrowserThread::FILE, FROM_HERE,
154 base::Bind( 154 base::Bind(&SandboxedUnpacker::Start, unpacker.get())))
155 &extensions::SandboxedUnpacker::Start, unpacker.get())))
156 NOTREACHED(); 155 NOTREACHED();
157 } 156 }
158 157
159 void CrxInstaller::InstallUserScript(const FilePath& source_file, 158 void CrxInstaller::InstallUserScript(const FilePath& source_file,
160 const GURL& download_url) { 159 const GURL& download_url) {
161 DCHECK(!download_url.is_empty()); 160 DCHECK(!download_url.is_empty());
162 161
163 source_file_ = source_file; 162 source_file_ = source_file;
164 download_url_ = download_url; 163 download_url_ = download_url;
165 164
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // SandboxedUnpacker sets extension->location. 239 // SandboxedUnpacker sets extension->location.
241 if (extension->is_theme() || Extension::IsExternalLocation(install_source_)) 240 if (extension->is_theme() || Extension::IsExternalLocation(install_source_))
242 return CrxInstallerError(); 241 return CrxInstallerError();
243 242
244 if (!extensions_enabled_) { 243 if (!extensions_enabled_) {
245 return CrxInstallerError( 244 return CrxInstallerError(
246 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_NOT_ENABLED)); 245 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_NOT_ENABLED));
247 } 246 }
248 247
249 if (install_cause_ == extension_misc::INSTALL_CAUSE_USER_DOWNLOAD) { 248 if (install_cause_ == extension_misc::INSTALL_CAUSE_USER_DOWNLOAD) {
250 if (extensions::switch_utils::IsEasyOffStoreInstallEnabled()) { 249 if (switch_utils::IsEasyOffStoreInstallEnabled()) {
251 const char* kHistogramName = "Extensions.OffStoreInstallDecisionEasy"; 250 const char* kHistogramName = "Extensions.OffStoreInstallDecisionEasy";
252 if (is_gallery_install()) { 251 if (is_gallery_install()) {
253 UMA_HISTOGRAM_ENUMERATION(kHistogramName, OnStoreInstall, 252 UMA_HISTOGRAM_ENUMERATION(kHistogramName, OnStoreInstall,
254 NumOffStoreInstallDecision); 253 NumOffStoreInstallDecision);
255 } else { 254 } else {
256 UMA_HISTOGRAM_ENUMERATION(kHistogramName, OffStoreInstallAllowed, 255 UMA_HISTOGRAM_ENUMERATION(kHistogramName, OffStoreInstallAllowed,
257 NumOffStoreInstallDecision); 256 NumOffStoreInstallDecision);
258 } 257 }
259 } else { 258 } else {
260 const char* kHistogramName = "Extensions.OffStoreInstallDecisionHard"; 259 const char* kHistogramName = "Extensions.OffStoreInstallDecisionHard";
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 // Some users (such as the download shelf) need to know when a 616 // Some users (such as the download shelf) need to know when a
618 // CRXInstaller is done. Listening for the EXTENSION_* events 617 // CRXInstaller is done. Listening for the EXTENSION_* events
619 // is problematic because they don't know anything about the 618 // is problematic because they don't know anything about the
620 // extension before it is unpacked, so they cannot filter based 619 // extension before it is unpacked, so they cannot filter based
621 // on the extension. 620 // on the extension.
622 content::NotificationService::current()->Notify( 621 content::NotificationService::current()->Notify(
623 chrome::NOTIFICATION_CRX_INSTALLER_DONE, 622 chrome::NOTIFICATION_CRX_INSTALLER_DONE,
624 content::Source<CrxInstaller>(this), 623 content::Source<CrxInstaller>(this),
625 content::Details<const Extension>(extension)); 624 content::Details<const Extension>(extension));
626 } 625 }
626
627 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/crx_installer.h ('k') | chrome/browser/extensions/crx_installer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698