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 #include "chrome/browser/extensions/extension_install_prompt.h" | 5 #include "chrome/browser/extensions/extension_install_prompt.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/signin/token_service_factory.h" | 22 #include "chrome/browser/signin/token_service_factory.h" |
23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
27 #include "chrome/common/extensions/extension_constants.h" | 27 #include "chrome/common/extensions/extension_constants.h" |
28 #include "chrome/common/extensions/extension_icon_set.h" | 28 #include "chrome/common/extensions/extension_icon_set.h" |
29 #include "chrome/common/extensions/extension_manifest_constants.h" | 29 #include "chrome/common/extensions/extension_manifest_constants.h" |
30 #include "chrome/common/extensions/extension_resource.h" | 30 #include "chrome/common/extensions/extension_resource.h" |
31 #include "chrome/common/extensions/feature_switch.h" | 31 #include "chrome/common/extensions/feature_switch.h" |
| 32 #include "chrome/common/extensions/manifest.h" |
32 #include "chrome/common/extensions/permissions/permission_set.h" | 33 #include "chrome/common/extensions/permissions/permission_set.h" |
33 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
35 #include "content/public/browser/web_contents_view.h" | 36 #include "content/public/browser/web_contents_view.h" |
36 #include "extensions/common/url_pattern.h" | 37 #include "extensions/common/url_pattern.h" |
37 #include "grit/chromium_strings.h" | 38 #include "grit/chromium_strings.h" |
38 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
39 #include "grit/theme_resources.h" | 40 #include "grit/theme_resources.h" |
40 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
41 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
42 #include "ui/gfx/image/image.h" | 43 #include "ui/gfx/image/image.h" |
43 | 44 |
44 using extensions::BundleInstaller; | 45 using extensions::BundleInstaller; |
45 using extensions::Extension; | 46 using extensions::Extension; |
| 47 using extensions::Manifest; |
46 using extensions::PermissionSet; | 48 using extensions::PermissionSet; |
47 | 49 |
48 namespace { | 50 namespace { |
49 | 51 |
50 static const int kTitleIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { | 52 static const int kTitleIds[ExtensionInstallPrompt::NUM_PROMPT_TYPES] = { |
51 0, // The regular install prompt depends on what's being installed. | 53 0, // The regular install prompt depends on what's being installed. |
52 IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE, | 54 IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE, |
53 IDS_EXTENSION_INSTALL_PROMPT_TITLE, | 55 IDS_EXTENSION_INSTALL_PROMPT_TITLE, |
54 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE, | 56 IDS_EXTENSION_RE_ENABLE_PROMPT_TITLE, |
55 IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE, | 57 IDS_EXTENSION_PERMISSIONS_PROMPT_TITLE, |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 localized_name); | 370 localized_name); |
369 } | 371 } |
370 if (!localized_description.empty()) { | 372 if (!localized_description.empty()) { |
371 localized_manifest->SetString(extension_manifest_keys::kDescription, | 373 localized_manifest->SetString(extension_manifest_keys::kDescription, |
372 localized_description); | 374 localized_description); |
373 } | 375 } |
374 } | 376 } |
375 | 377 |
376 return Extension::Create( | 378 return Extension::Create( |
377 FilePath(), | 379 FilePath(), |
378 Extension::INTERNAL, | 380 Manifest::INTERNAL, |
379 localized_manifest.get() ? *localized_manifest.get() : *manifest, | 381 localized_manifest.get() ? *localized_manifest.get() : *manifest, |
380 flags, | 382 flags, |
381 id, | 383 id, |
382 error); | 384 error); |
383 } | 385 } |
384 | 386 |
385 ExtensionInstallPrompt::ExtensionInstallPrompt( | 387 ExtensionInstallPrompt::ExtensionInstallPrompt( |
386 content::WebContents* contents) | 388 content::WebContents* contents) |
387 : record_oauth2_grant_(false), | 389 : record_oauth2_grant_(false), |
388 ui_loop_(MessageLoop::current()), | 390 ui_loop_(MessageLoop::current()), |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 } | 625 } |
624 | 626 |
625 void ExtensionInstallPrompt::OnMintTokenFailure( | 627 void ExtensionInstallPrompt::OnMintTokenFailure( |
626 const GoogleServiceAuthError& error) { | 628 const GoogleServiceAuthError& error) { |
627 ShowConfirmation(); | 629 ShowConfirmation(); |
628 } | 630 } |
629 | 631 |
630 void ExtensionInstallPrompt::ShowConfirmation() { | 632 void ExtensionInstallPrompt::ShowConfirmation() { |
631 if (permissions_ && | 633 if (permissions_ && |
632 (!extension_ || !extension_->ShouldSkipPermissionWarnings())) { | 634 (!extension_ || !extension_->ShouldSkipPermissionWarnings())) { |
633 Extension::Type extension_type = extension_ ? extension_->GetType() : | 635 Manifest::Type extension_type = extension_ ? |
634 Extension::TYPE_UNKNOWN; | 636 extension_->GetType() : Manifest::TYPE_UNKNOWN; |
635 prompt_.SetPermissions(permissions_->GetWarningMessages(extension_type)); | 637 prompt_.SetPermissions(permissions_->GetWarningMessages(extension_type)); |
636 } | 638 } |
637 | 639 |
638 switch (prompt_.type()) { | 640 switch (prompt_.type()) { |
639 case PERMISSIONS_PROMPT: | 641 case PERMISSIONS_PROMPT: |
640 case RE_ENABLE_PROMPT: | 642 case RE_ENABLE_PROMPT: |
641 case INLINE_INSTALL_PROMPT: | 643 case INLINE_INSTALL_PROMPT: |
642 case EXTERNAL_INSTALL_PROMPT: | 644 case EXTERNAL_INSTALL_PROMPT: |
643 case INSTALL_PROMPT: { | 645 case INSTALL_PROMPT: { |
644 prompt_.set_extension(extension_); | 646 prompt_.set_extension(extension_); |
(...skipping 10 matching lines...) Expand all Loading... |
655 } | 657 } |
656 | 658 |
657 if (AutoConfirmPrompt(delegate_)) | 659 if (AutoConfirmPrompt(delegate_)) |
658 return; | 660 return; |
659 | 661 |
660 if (show_dialog_callback_.is_null()) | 662 if (show_dialog_callback_.is_null()) |
661 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); | 663 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); |
662 else | 664 else |
663 show_dialog_callback_.Run(show_params_, delegate_, prompt_); | 665 show_dialog_callback_.Run(show_params_, delegate_, prompt_); |
664 } | 666 } |
OLD | NEW |