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

Side by Side Diff: chrome/browser/extensions/crx_installer.h

Issue 8417012: Refactor loading out of ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: finally Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 30 matching lines...) Expand all
41 // working with it, eg: 41 // working with it, eg:
42 // 42 //
43 // scoped_refptr<CrxInstaller> installer(new CrxInstaller(...)); 43 // scoped_refptr<CrxInstaller> installer(new CrxInstaller(...));
44 // installer->set_foo(); 44 // installer->set_foo();
45 // installer->set_bar(); 45 // installer->set_bar();
46 // installer->InstallCrx(...); 46 // installer->InstallCrx(...);
47 class CrxInstaller 47 class CrxInstaller
48 : public SandboxedExtensionUnpackerClient, 48 : public SandboxedExtensionUnpackerClient,
49 public ExtensionInstallUI::Delegate { 49 public ExtensionInstallUI::Delegate {
50 public: 50 public:
51 // Extensions will be installed into frontend->install_directory(),
52 // then registered with |frontend|. Any install UI will be displayed
53 // using |client|. Pass NULL for |client| for silent install.
54 static scoped_refptr<CrxInstaller> Create(
55 ExtensionService* frontend,
56 ExtensionInstallUI* client);
57
51 // This is pretty lame, but given the difficulty of connecting a particular 58 // This is pretty lame, but given the difficulty of connecting a particular
52 // ExtensionFunction to a resulting download in the download manager, it's 59 // ExtensionFunction to a resulting download in the download manager, it's
53 // currently necessary. This is the |id| of an extension to be installed 60 // currently necessary. This is the |id| of an extension to be installed
54 // *by the web store only* which should not get the permissions install 61 // *by the web store only* which should not get the permissions install
55 // prompt. This should only be called on the UI thread. 62 // prompt. This should only be called on the UI thread.
56 // crbug.com/54916 63 // crbug.com/54916
57 // TODO(asargent): This should be removed now that SetWhitelistEntry exists 64 // TODO(asargent): This should be removed now that SetWhitelistEntry exists
58 // http://crbug.com/100584 65 // http://crbug.com/100584
59 static void SetWhitelistedInstallId(const std::string& id); 66 static void SetWhitelistedInstallId(const std::string& id);
60 67
(...skipping 24 matching lines...) Expand all
85 // the return value and is responsible for deleting it. 92 // the return value and is responsible for deleting it.
86 static WhitelistEntry* RemoveWhitelistEntry(const std::string& id); 93 static WhitelistEntry* RemoveWhitelistEntry(const std::string& id);
87 94
88 // Returns whether |id| is whitelisted - only call this on the UI thread. 95 // Returns whether |id| is whitelisted - only call this on the UI thread.
89 static bool IsIdWhitelisted(const std::string& id); 96 static bool IsIdWhitelisted(const std::string& id);
90 97
91 // Returns whether |id| was found and removed (was whitelisted). This should 98 // Returns whether |id| was found and removed (was whitelisted). This should
92 // only be called on the UI thread. 99 // only be called on the UI thread.
93 static bool ClearWhitelistedInstallId(const std::string& id); 100 static bool ClearWhitelistedInstallId(const std::string& id);
94 101
95 // Constructor. Extensions will be installed into
96 // frontend_weak->install_directory() then registered with
97 // |frontend_weak|. Any install UI will be displayed using
98 // |client|. Pass NULL for |client| for silent install.
99 CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak,
100 ExtensionInstallUI* client);
101
102 // Install the crx in |source_file|. 102 // Install the crx in |source_file|.
103 void InstallCrx(const FilePath& source_file); 103 void InstallCrx(const FilePath& source_file);
104 104
105 // Convert the specified user script into an extension and install it. 105 // Convert the specified user script into an extension and install it.
106 void InstallUserScript(const FilePath& source_file, 106 void InstallUserScript(const FilePath& source_file,
107 const GURL& download_url); 107 const GURL& download_url);
108 108
109 // Convert the specified web app into an extension and install it. 109 // Convert the specified web app into an extension and install it.
110 void InstallWebApp(const WebApplicationInfo& web_app); 110 void InstallWebApp(const WebApplicationInfo& web_app);
111 111
(...skipping 22 matching lines...) Expand all
134 bool delete_source() const { return delete_source_; } 134 bool delete_source() const { return delete_source_; }
135 void set_delete_source(bool val) { delete_source_ = val; } 135 void set_delete_source(bool val) { delete_source_ = val; }
136 136
137 bool allow_silent_install() const { return allow_silent_install_; } 137 bool allow_silent_install() const { return allow_silent_install_; }
138 void set_allow_silent_install(bool val) { allow_silent_install_ = val; } 138 void set_allow_silent_install(bool val) { allow_silent_install_ = val; }
139 139
140 bool is_gallery_install() const { 140 bool is_gallery_install() const {
141 return (creation_flags_ & Extension::FROM_WEBSTORE) > 0; 141 return (creation_flags_ & Extension::FROM_WEBSTORE) > 0;
142 } 142 }
143 void set_is_gallery_install(bool val) { 143 void set_is_gallery_install(bool val) {
144 if (val) creation_flags_ |= Extension::FROM_WEBSTORE; 144 if (val)
145 else creation_flags_ &= ~Extension::FROM_WEBSTORE; 145 creation_flags_ |= Extension::FROM_WEBSTORE;
146 else
147 creation_flags_ &= ~Extension::FROM_WEBSTORE;
146 } 148 }
147 149
148 // The original download URL should be set when the WebstoreInstaller is 150 // The original download URL should be set when the WebstoreInstaller is
149 // tracking the installation. The WebstoreInstaller uses this URL to match 151 // tracking the installation. The WebstoreInstaller uses this URL to match
150 // failure notifications to the extension. 152 // failure notifications to the extension.
151 const GURL& original_download_url() const { return original_download_url_; } 153 const GURL& original_download_url() const { return original_download_url_; }
152 void set_original_download_url(const GURL& url) { 154 void set_original_download_url(const GURL& url) {
153 original_download_url_ = url; 155 original_download_url_ = url;
154 } 156 }
155 157
(...skipping 18 matching lines...) Expand all
174 176
175 void set_page_index(int page_index) { 177 void set_page_index(int page_index) {
176 page_index_ = page_index; 178 page_index_ = page_index;
177 } 179 }
178 180
179 Profile* profile() { return profile_; } 181 Profile* profile() { return profile_; }
180 182
181 private: 183 private:
182 friend class ExtensionUpdaterTest; 184 friend class ExtensionUpdaterTest;
183 185
186 CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak,
187 ExtensionInstallUI* client);
184 virtual ~CrxInstaller(); 188 virtual ~CrxInstaller();
185 189
186 // Converts the source user script to an extension. 190 // Converts the source user script to an extension.
187 void ConvertUserScriptOnFileThread(); 191 void ConvertUserScriptOnFileThread();
188 192
189 // Converts the source web app to an extension. 193 // Converts the source web app to an extension.
190 void ConvertWebAppOnFileThread(const WebApplicationInfo& web_app); 194 void ConvertWebAppOnFileThread(const WebApplicationInfo& web_app);
191 195
192 // Called after OnUnpackSuccess as a last check to see whether the install 196 // Called after OnUnpackSuccess as a last check to see whether the install
193 // should complete. 197 // should complete.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 extension_misc::CrxInstallCause install_cause_; 322 extension_misc::CrxInstallCause install_cause_;
319 323
320 // Creation flags to use for the extension. These flags will be used 324 // Creation flags to use for the extension. These flags will be used
321 // when calling Extenion::Create() by the crx installer. 325 // when calling Extenion::Create() by the crx installer.
322 int creation_flags_; 326 int creation_flags_;
323 327
324 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); 328 DISALLOW_COPY_AND_ASSIGN(CrxInstaller);
325 }; 329 };
326 330
327 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ 331 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/component_loader.cc ('k') | chrome/browser/extensions/crx_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698