| 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 "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 case ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT: | 199 case ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT: |
| 200 return "BUNDLE_INSTALL_PROMPT"; | 200 return "BUNDLE_INSTALL_PROMPT"; |
| 201 case ExtensionInstallPrompt::RE_ENABLE_PROMPT: | 201 case ExtensionInstallPrompt::RE_ENABLE_PROMPT: |
| 202 return "RE_ENABLE_PROMPT"; | 202 return "RE_ENABLE_PROMPT"; |
| 203 case ExtensionInstallPrompt::PERMISSIONS_PROMPT: | 203 case ExtensionInstallPrompt::PERMISSIONS_PROMPT: |
| 204 return "PERMISSIONS_PROMPT"; | 204 return "PERMISSIONS_PROMPT"; |
| 205 case ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT: | 205 case ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT: |
| 206 return "EXTERNAL_INSTALL_PROMPT"; | 206 return "EXTERNAL_INSTALL_PROMPT"; |
| 207 case ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT: | 207 case ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT: |
| 208 return "POST_INSTALL_PERMISSIONS_PROMPT"; | 208 return "POST_INSTALL_PERMISSIONS_PROMPT"; |
| 209 case ExtensionInstallPrompt::LAUNCH_PROMPT: | |
| 210 return "LAUNCH_PROMPT"; | |
| 211 case ExtensionInstallPrompt::REMOTE_INSTALL_PROMPT: | 209 case ExtensionInstallPrompt::REMOTE_INSTALL_PROMPT: |
| 212 return "REMOTE_INSTALL_PROMPT"; | 210 return "REMOTE_INSTALL_PROMPT"; |
| 213 case ExtensionInstallPrompt::REPAIR_PROMPT: | 211 case ExtensionInstallPrompt::REPAIR_PROMPT: |
| 214 return "REPAIR_PROMPT"; | 212 return "REPAIR_PROMPT"; |
| 215 case ExtensionInstallPrompt::DELEGATED_PERMISSIONS_PROMPT: | 213 case ExtensionInstallPrompt::DELEGATED_PERMISSIONS_PROMPT: |
| 216 return "DELEGATED_PERMISSIONS_PROMPT"; | 214 return "DELEGATED_PERMISSIONS_PROMPT"; |
| 217 case ExtensionInstallPrompt::DELEGATED_BUNDLE_PERMISSIONS_PROMPT: | 215 case ExtensionInstallPrompt::DELEGATED_BUNDLE_PERMISSIONS_PROMPT: |
| 218 return "DELEGATED_BUNDLE_PERMISSIONS_PROMPT"; | 216 return "DELEGATED_BUNDLE_PERMISSIONS_PROMPT"; |
| 217 case ExtensionInstallPrompt::LAUNCH_PROMPT_DEPRECATED: |
| 218 NOTREACHED(); |
| 219 // fall through: |
| 219 case ExtensionInstallPrompt::UNSET_PROMPT_TYPE: | 220 case ExtensionInstallPrompt::UNSET_PROMPT_TYPE: |
| 220 case ExtensionInstallPrompt::NUM_PROMPT_TYPES: | 221 case ExtensionInstallPrompt::NUM_PROMPT_TYPES: |
| 221 break; | 222 break; |
| 222 } | 223 } |
| 223 return "OTHER"; | 224 return "OTHER"; |
| 224 } | 225 } |
| 225 | 226 |
| 226 ExtensionInstallPrompt::Prompt::Prompt(PromptType type) | 227 ExtensionInstallPrompt::Prompt::Prompt(PromptType type) |
| 227 : type_(type), | 228 : type_(type), |
| 228 is_showing_details_for_retained_files_(false), | 229 is_showing_details_for_retained_files_(false), |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 | 721 |
| 721 void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate, | 722 void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate, |
| 722 const Extension* extension) { | 723 const Extension* extension) { |
| 723 DCHECK(ui_loop_ == base::MessageLoop::current()); | 724 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 724 extension_ = extension; | 725 extension_ = extension; |
| 725 delegate_ = delegate; | 726 delegate_ = delegate; |
| 726 bool is_remote_install = | 727 bool is_remote_install = |
| 727 profile_ && | 728 profile_ && |
| 728 extensions::ExtensionPrefs::Get(profile_)->HasDisableReason( | 729 extensions::ExtensionPrefs::Get(profile_)->HasDisableReason( |
| 729 extension->id(), extensions::Extension::DISABLE_REMOTE_INSTALL); | 730 extension->id(), extensions::Extension::DISABLE_REMOTE_INSTALL); |
| 730 bool is_ephemeral = | |
| 731 extensions::util::IsEphemeralApp(extension->id(), profile_); | |
| 732 | |
| 733 PromptType type = UNSET_PROMPT_TYPE; | 731 PromptType type = UNSET_PROMPT_TYPE; |
| 734 if (is_ephemeral) | 732 if (is_remote_install) |
| 735 type = LAUNCH_PROMPT; | |
| 736 else if (is_remote_install) | |
| 737 type = REMOTE_INSTALL_PROMPT; | 733 type = REMOTE_INSTALL_PROMPT; |
| 738 else | 734 else |
| 739 type = RE_ENABLE_PROMPT; | 735 type = RE_ENABLE_PROMPT; |
| 740 prompt_ = new Prompt(type); | 736 prompt_ = new Prompt(type); |
| 741 | 737 |
| 742 LoadImageIfNeeded(); | 738 LoadImageIfNeeded(); |
| 743 } | 739 } |
| 744 | 740 |
| 745 void ExtensionInstallPrompt::ConfirmExternalInstall( | 741 void ExtensionInstallPrompt::ConfirmExternalInstall( |
| 746 Delegate* delegate, | 742 Delegate* delegate, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 WITHHELD_PERMISSIONS); | 889 WITHHELD_PERMISSIONS); |
| 894 } | 890 } |
| 895 } | 891 } |
| 896 | 892 |
| 897 switch (prompt_->type()) { | 893 switch (prompt_->type()) { |
| 898 case PERMISSIONS_PROMPT: | 894 case PERMISSIONS_PROMPT: |
| 899 case RE_ENABLE_PROMPT: | 895 case RE_ENABLE_PROMPT: |
| 900 case INLINE_INSTALL_PROMPT: | 896 case INLINE_INSTALL_PROMPT: |
| 901 case EXTERNAL_INSTALL_PROMPT: | 897 case EXTERNAL_INSTALL_PROMPT: |
| 902 case INSTALL_PROMPT: | 898 case INSTALL_PROMPT: |
| 903 case LAUNCH_PROMPT: | |
| 904 case POST_INSTALL_PERMISSIONS_PROMPT: | 899 case POST_INSTALL_PERMISSIONS_PROMPT: |
| 905 case REMOTE_INSTALL_PROMPT: | 900 case REMOTE_INSTALL_PROMPT: |
| 906 case REPAIR_PROMPT: | 901 case REPAIR_PROMPT: |
| 907 case DELEGATED_PERMISSIONS_PROMPT: { | 902 case DELEGATED_PERMISSIONS_PROMPT: { |
| 908 prompt_->set_extension(extension_); | 903 prompt_->set_extension(extension_); |
| 909 break; | 904 break; |
| 910 } | 905 } |
| 911 case BUNDLE_INSTALL_PROMPT: | 906 case BUNDLE_INSTALL_PROMPT: |
| 912 case DELEGATED_BUNDLE_PERMISSIONS_PROMPT: { | 907 case DELEGATED_BUNDLE_PERMISSIONS_PROMPT: { |
| 913 prompt_->set_bundle(bundle_); | 908 prompt_->set_bundle(bundle_); |
| 914 break; | 909 break; |
| 915 } | 910 } |
| 911 case LAUNCH_PROMPT_DEPRECATED: |
| 916 default: | 912 default: |
| 917 NOTREACHED() << "Unknown message"; | 913 NOTREACHED() << "Unknown message"; |
| 918 return; | 914 return; |
| 919 } | 915 } |
| 920 prompt_->set_delegated_username(delegated_username_); | 916 prompt_->set_delegated_username(delegated_username_); |
| 921 prompt_->set_icon(gfx::Image::CreateFrom1xBitmap(icon_)); | 917 prompt_->set_icon(gfx::Image::CreateFrom1xBitmap(icon_)); |
| 922 | 918 |
| 923 g_last_prompt_type_for_tests = prompt_->type(); | 919 g_last_prompt_type_for_tests = prompt_->type(); |
| 924 | 920 |
| 925 if (AutoConfirmPrompt(delegate_)) | 921 if (AutoConfirmPrompt(delegate_)) |
| 926 return; | 922 return; |
| 927 | 923 |
| 928 if (show_params_->WasParentDestroyed()) { | 924 if (show_params_->WasParentDestroyed()) { |
| 929 delegate_->InstallUIAbort(false); | 925 delegate_->InstallUIAbort(false); |
| 930 return; | 926 return; |
| 931 } | 927 } |
| 932 | 928 |
| 933 if (show_dialog_callback_.is_null()) | 929 if (show_dialog_callback_.is_null()) |
| 934 GetDefaultShowDialogCallback().Run(show_params_.get(), delegate_, prompt_); | 930 GetDefaultShowDialogCallback().Run(show_params_.get(), delegate_, prompt_); |
| 935 else | 931 else |
| 936 show_dialog_callback_.Run(show_params_.get(), delegate_, prompt_); | 932 show_dialog_callback_.Run(show_params_.get(), delegate_, prompt_); |
| 937 } | 933 } |
| OLD | NEW |