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