OLD | NEW |
---|---|
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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/string16.h" | 14 #include "base/string16.h" |
14 #include "chrome/browser/extensions/crx_installer_error.h" | 15 #include "chrome/browser/extensions/crx_installer_error.h" |
15 #include "chrome/browser/extensions/image_loading_tracker.h" | 16 #include "chrome/browser/extensions/image_loading_tracker.h" |
16 #include "chrome/common/extensions/url_pattern.h" | 17 #include "chrome/common/extensions/url_pattern.h" |
17 #include "google_apis/gaia/oauth2_mint_token_flow.h" | 18 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
18 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
19 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
20 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 virtual void InstallUIProceed() = 0; | 151 virtual void InstallUIProceed() = 0; |
151 | 152 |
152 // We call this method to signal that the installation should stop, with | 153 // We call this method to signal that the installation should stop, with |
153 // |user_initiated| true if the installation was stopped by the user. | 154 // |user_initiated| true if the installation was stopped by the user. |
154 virtual void InstallUIAbort(bool user_initiated) = 0; | 155 virtual void InstallUIAbort(bool user_initiated) = 0; |
155 | 156 |
156 protected: | 157 protected: |
157 virtual ~Delegate() {} | 158 virtual ~Delegate() {} |
158 }; | 159 }; |
159 | 160 |
161 typedef base::Callback<void(gfx::NativeWindow, | |
162 content::PageNavigator*, | |
163 ExtensionInstallPrompt::Delegate*, | |
164 const ExtensionInstallPrompt::Prompt&)> | |
165 ShowDialogCallback; | |
Aaron Boodman
2012/10/11 20:28:50
Add documentation
| |
166 | |
160 // Creates a dummy extension from the |manifest|, replacing the name and | 167 // Creates a dummy extension from the |manifest|, replacing the name and |
161 // description with the localizations if provided. | 168 // description with the localizations if provided. |
162 static scoped_refptr<extensions::Extension> GetLocalizedExtensionForDisplay( | 169 static scoped_refptr<extensions::Extension> GetLocalizedExtensionForDisplay( |
163 const base::DictionaryValue* manifest, | 170 const base::DictionaryValue* manifest, |
164 int flags, // Extension::InitFromValueFlags | 171 int flags, // Extension::InitFromValueFlags |
165 const std::string& id, | 172 const std::string& id, |
166 const std::string& localized_name, | 173 const std::string& localized_name, |
167 const std::string& localized_description, | 174 const std::string& localized_description, |
168 std::string* error); | 175 std::string* error); |
169 | 176 |
(...skipping 19 matching lines...) Expand all Loading... | |
189 // This is called by the standalone installer to verify whether the install | 196 // This is called by the standalone installer to verify whether the install |
190 // from the webstore should proceed. | 197 // from the webstore should proceed. |
191 // | 198 // |
192 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 199 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
193 virtual void ConfirmStandaloneInstall(Delegate* delegate, | 200 virtual void ConfirmStandaloneInstall(Delegate* delegate, |
194 const extensions::Extension* extension, | 201 const extensions::Extension* extension, |
195 SkBitmap* icon, | 202 SkBitmap* icon, |
196 const Prompt& prompt); | 203 const Prompt& prompt); |
197 | 204 |
198 // This is called by the installer to verify whether the installation from | 205 // This is called by the installer to verify whether the installation from |
199 // the webstore should proceed. | 206 // the webstore should proceed. |show_dialog_callback| is optional and can be |
207 // NULL. | |
200 // | 208 // |
201 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 209 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
202 virtual void ConfirmWebstoreInstall(Delegate* delegate, | 210 virtual void ConfirmWebstoreInstall( |
203 const extensions::Extension* extension, | 211 Delegate* delegate, |
204 const SkBitmap* icon); | 212 const extensions::Extension* extension, |
213 const SkBitmap* icon, | |
214 const ShowDialogCallback& show_dialog_callback); | |
205 | 215 |
206 // This is called by the installer to verify whether the installation should | 216 // This is called by the installer to verify whether the installation should |
207 // proceed. This is declared virtual for testing. | 217 // proceed. This is declared virtual for testing. |show_dialog_callback| is |
218 // optional and can be NULL. | |
208 // | 219 // |
209 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 220 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
210 virtual void ConfirmInstall(Delegate* delegate, | 221 virtual void ConfirmInstall(Delegate* delegate, |
211 const extensions::Extension* extension); | 222 const extensions::Extension* extension, |
223 const ShowDialogCallback& show_dialog_callback); | |
212 | 224 |
213 // This is called by the app handler launcher to verify whether the app | 225 // This is called by the app handler launcher to verify whether the app |
214 // should be re-enabled. This is declared virtual for testing. | 226 // should be re-enabled. This is declared virtual for testing. |
215 // | 227 // |
216 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 228 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
217 virtual void ConfirmReEnable(Delegate* delegate, | 229 virtual void ConfirmReEnable(Delegate* delegate, |
218 const extensions::Extension* extension); | 230 const extensions::Extension* extension); |
219 | 231 |
220 // This is called by the extension permissions API to verify whether an | 232 // This is called by the extension permissions API to verify whether an |
221 // extension may be granted additional permissions. | 233 // extension may be granted additional permissions. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 Prompt prompt_; | 316 Prompt prompt_; |
305 | 317 |
306 // The type of prompt we are going to show. | 318 // The type of prompt we are going to show. |
307 PromptType prompt_type_; | 319 PromptType prompt_type_; |
308 | 320 |
309 scoped_ptr<OAuth2MintTokenFlow> token_flow_; | 321 scoped_ptr<OAuth2MintTokenFlow> token_flow_; |
310 | 322 |
311 // Keeps track of extension images being loaded on the File thread for the | 323 // Keeps track of extension images being loaded on the File thread for the |
312 // purpose of showing the install UI. | 324 // purpose of showing the install UI. |
313 ImageLoadingTracker tracker_; | 325 ImageLoadingTracker tracker_; |
326 | |
327 // Used to show the confirm dialog. | |
328 ShowDialogCallback show_dialog_callback_; | |
314 }; | 329 }; |
315 | 330 |
331 // Shows the default extension install dialog. | |
332 // The implementations of this function are platform-specific. | |
333 void ShowExtensionInstallDialogImpl( | |
334 gfx::NativeWindow parent, | |
335 content::PageNavigator* navigator, | |
336 ExtensionInstallPrompt::Delegate* delegate, | |
337 const ExtensionInstallPrompt::Prompt& prompt); | |
338 | |
316 namespace chrome { | 339 namespace chrome { |
317 | 340 |
318 // Creates an ExtensionInstallPrompt from |browser|. Caller assumes ownership. | 341 // Creates an ExtensionInstallPrompt from |browser|. Caller assumes ownership. |
319 // TODO(beng): remove this once various extensions types are weaned from | 342 // TODO(beng): remove this once various extensions types are weaned from |
320 // Browser. | 343 // Browser. |
321 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( | 344 ExtensionInstallPrompt* CreateExtensionInstallPromptWithBrowser( |
322 Browser* browser); | 345 Browser* browser); |
323 | 346 |
324 } // namespace chrome | 347 } // namespace chrome |
325 | 348 |
326 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 349 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
OLD | NEW |