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/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
18 #include "chrome/browser/extensions/extension_install_prompt_experiment.h" | 18 #include "chrome/browser/extensions/extension_install_prompt_experiment.h" |
19 #include "extensions/common/url_pattern.h" | 19 #include "extensions/common/url_pattern.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
21 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
22 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
23 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
24 | 24 |
| 25 class ExtensionInstallPromptShowParams; |
25 class Profile; | 26 class Profile; |
26 | 27 |
27 namespace base { | 28 namespace base { |
28 class DictionaryValue; | 29 class DictionaryValue; |
29 class MessageLoop; | 30 class MessageLoop; |
30 } // namespace base | 31 } // namespace base |
31 | 32 |
32 namespace content { | 33 namespace content { |
33 class WebContents; | 34 class WebContents; |
34 } | 35 } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 virtual void InstallUIProceed() = 0; | 273 virtual void InstallUIProceed() = 0; |
273 | 274 |
274 // We call this method to signal that the installation should stop, with | 275 // We call this method to signal that the installation should stop, with |
275 // |user_initiated| true if the installation was stopped by the user. | 276 // |user_initiated| true if the installation was stopped by the user. |
276 virtual void InstallUIAbort(bool user_initiated) = 0; | 277 virtual void InstallUIAbort(bool user_initiated) = 0; |
277 | 278 |
278 protected: | 279 protected: |
279 virtual ~Delegate() {} | 280 virtual ~Delegate() {} |
280 }; | 281 }; |
281 | 282 |
282 // Parameters to show a prompt dialog. Two sets of the | 283 typedef base::Callback<void(ExtensionInstallPromptShowParams*, |
283 // parameters are supported: either use a parent WebContents or use a | |
284 // parent NativeWindow + a Profile. | |
285 struct ShowParams { | |
286 explicit ShowParams(content::WebContents* contents); | |
287 ShowParams(Profile* profile, gfx::NativeWindow window); | |
288 | |
289 Profile* profile; | |
290 | |
291 // Parent web contents of the install UI dialog. This can be NULL. | |
292 content::WebContents* parent_web_contents; | |
293 | |
294 // NativeWindow parent. | |
295 gfx::NativeWindow parent_window; | |
296 }; | |
297 | |
298 typedef base::Callback<void(const ExtensionInstallPrompt::ShowParams&, | |
299 ExtensionInstallPrompt::Delegate*, | 284 ExtensionInstallPrompt::Delegate*, |
300 scoped_refptr<ExtensionInstallPrompt::Prompt>)> | 285 scoped_refptr<ExtensionInstallPrompt::Prompt>)> |
301 ShowDialogCallback; | 286 ShowDialogCallback; |
302 | 287 |
303 // Callback to show the default extension install dialog. | 288 // Callback to show the default extension install dialog. |
304 // The implementations of this function are platform-specific. | 289 // The implementations of this function are platform-specific. |
305 static ShowDialogCallback GetDefaultShowDialogCallback(); | 290 static ShowDialogCallback GetDefaultShowDialogCallback(); |
306 | 291 |
307 // Creates a dummy extension from the |manifest|, replacing the name and | 292 // Creates a dummy extension from the |manifest|, replacing the name and |
308 // description with the localizations if provided. | 293 // description with the localizations if provided. |
(...skipping 12 matching lines...) Expand all Loading... |
321 // active browser window (or a new browser window if there are no browser | 306 // active browser window (or a new browser window if there are no browser |
322 // windows) is used if a new tab needs to be opened. | 307 // windows) is used if a new tab needs to be opened. |
323 ExtensionInstallPrompt(Profile* profile, gfx::NativeWindow native_window); | 308 ExtensionInstallPrompt(Profile* profile, gfx::NativeWindow native_window); |
324 | 309 |
325 virtual ~ExtensionInstallPrompt(); | 310 virtual ~ExtensionInstallPrompt(); |
326 | 311 |
327 extensions::ExtensionInstallUI* install_ui() const { | 312 extensions::ExtensionInstallUI* install_ui() const { |
328 return install_ui_.get(); | 313 return install_ui_.get(); |
329 } | 314 } |
330 | 315 |
331 content::WebContents* parent_web_contents() const { | |
332 return show_params_.parent_web_contents; | |
333 } | |
334 | |
335 // This is called by the bundle installer to verify whether the bundle | 316 // This is called by the bundle installer to verify whether the bundle |
336 // should be installed. | 317 // should be installed. |
337 // | 318 // |
338 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. | 319 // We *MUST* eventually call either Proceed() or Abort() on |delegate|. |
339 virtual void ConfirmBundleInstall( | 320 virtual void ConfirmBundleInstall( |
340 extensions::BundleInstaller* bundle, | 321 extensions::BundleInstaller* bundle, |
341 const extensions::PermissionSet* permissions); | 322 const extensions::PermissionSet* permissions); |
342 | 323 |
343 // This is called by the standalone installer to verify whether the install | 324 // This is called by the standalone installer to verify whether the install |
344 // from the webstore should proceed. | 325 // from the webstore should proceed. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 const extensions::BundleInstaller* bundle_; | 436 const extensions::BundleInstaller* bundle_; |
456 | 437 |
457 // A custom set of permissions to show in the install prompt instead of the | 438 // A custom set of permissions to show in the install prompt instead of the |
458 // extension's active permissions. | 439 // extension's active permissions. |
459 scoped_refptr<const extensions::PermissionSet> custom_permissions_; | 440 scoped_refptr<const extensions::PermissionSet> custom_permissions_; |
460 | 441 |
461 // The object responsible for doing the UI specific actions. | 442 // The object responsible for doing the UI specific actions. |
462 scoped_ptr<extensions::ExtensionInstallUI> install_ui_; | 443 scoped_ptr<extensions::ExtensionInstallUI> install_ui_; |
463 | 444 |
464 // Parameters to show the confirmation UI. | 445 // Parameters to show the confirmation UI. |
465 ShowParams show_params_; | 446 scoped_ptr<ExtensionInstallPromptShowParams> show_params_; |
466 | 447 |
467 // The delegate we will call Proceed/Abort on after confirmation UI. | 448 // The delegate we will call Proceed/Abort on after confirmation UI. |
468 Delegate* delegate_; | 449 Delegate* delegate_; |
469 | 450 |
470 // A pre-filled prompt. | 451 // A pre-filled prompt. |
471 scoped_refptr<Prompt> prompt_; | 452 scoped_refptr<Prompt> prompt_; |
472 | 453 |
473 // Used to show the confirm dialog. | 454 // Used to show the confirm dialog. |
474 ShowDialogCallback show_dialog_callback_; | 455 ShowDialogCallback show_dialog_callback_; |
475 }; | 456 }; |
476 | 457 |
477 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ | 458 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_ |
OLD | NEW |