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"; |
219 case ExtensionInstallPrompt::UNSET_PROMPT_TYPE: | 217 case ExtensionInstallPrompt::UNSET_PROMPT_TYPE: |
220 case ExtensionInstallPrompt::NUM_PROMPT_TYPES: | 218 case ExtensionInstallPrompt::NUM_PROMPT_TYPES: |
219 case ExtensionInstallPrompt::LAUNCH_PROMPT_UNUSED: | |
Devlin
2015/12/07 16:53:59
Could this one be a NOTREACHED? (Maybe put it on
benwells
2015/12/08 07:20:11
Done.
| |
221 break; | 220 break; |
222 } | 221 } |
223 return "OTHER"; | 222 return "OTHER"; |
224 } | 223 } |
225 | 224 |
226 ExtensionInstallPrompt::Prompt::Prompt(PromptType type) | 225 ExtensionInstallPrompt::Prompt::Prompt(PromptType type) |
227 : type_(type), | 226 : type_(type), |
228 is_showing_details_for_retained_files_(false), | 227 is_showing_details_for_retained_files_(false), |
229 is_showing_details_for_retained_devices_(false), | 228 is_showing_details_for_retained_devices_(false), |
230 extension_(NULL), | 229 extension_(NULL), |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
720 | 719 |
721 void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate, | 720 void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate, |
722 const Extension* extension) { | 721 const Extension* extension) { |
723 DCHECK(ui_loop_ == base::MessageLoop::current()); | 722 DCHECK(ui_loop_ == base::MessageLoop::current()); |
724 extension_ = extension; | 723 extension_ = extension; |
725 delegate_ = delegate; | 724 delegate_ = delegate; |
726 bool is_remote_install = | 725 bool is_remote_install = |
727 profile_ && | 726 profile_ && |
728 extensions::ExtensionPrefs::Get(profile_)->HasDisableReason( | 727 extensions::ExtensionPrefs::Get(profile_)->HasDisableReason( |
729 extension->id(), extensions::Extension::DISABLE_REMOTE_INSTALL); | 728 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; | 729 PromptType type = UNSET_PROMPT_TYPE; |
734 if (is_ephemeral) | 730 if (is_remote_install) |
735 type = LAUNCH_PROMPT; | |
736 else if (is_remote_install) | |
737 type = REMOTE_INSTALL_PROMPT; | 731 type = REMOTE_INSTALL_PROMPT; |
738 else | 732 else |
739 type = RE_ENABLE_PROMPT; | 733 type = RE_ENABLE_PROMPT; |
740 prompt_ = new Prompt(type); | 734 prompt_ = new Prompt(type); |
741 | 735 |
742 LoadImageIfNeeded(); | 736 LoadImageIfNeeded(); |
743 } | 737 } |
744 | 738 |
745 void ExtensionInstallPrompt::ConfirmExternalInstall( | 739 void ExtensionInstallPrompt::ConfirmExternalInstall( |
746 Delegate* delegate, | 740 Delegate* delegate, |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
893 WITHHELD_PERMISSIONS); | 887 WITHHELD_PERMISSIONS); |
894 } | 888 } |
895 } | 889 } |
896 | 890 |
897 switch (prompt_->type()) { | 891 switch (prompt_->type()) { |
898 case PERMISSIONS_PROMPT: | 892 case PERMISSIONS_PROMPT: |
899 case RE_ENABLE_PROMPT: | 893 case RE_ENABLE_PROMPT: |
900 case INLINE_INSTALL_PROMPT: | 894 case INLINE_INSTALL_PROMPT: |
901 case EXTERNAL_INSTALL_PROMPT: | 895 case EXTERNAL_INSTALL_PROMPT: |
902 case INSTALL_PROMPT: | 896 case INSTALL_PROMPT: |
903 case LAUNCH_PROMPT: | |
904 case POST_INSTALL_PERMISSIONS_PROMPT: | 897 case POST_INSTALL_PERMISSIONS_PROMPT: |
905 case REMOTE_INSTALL_PROMPT: | 898 case REMOTE_INSTALL_PROMPT: |
906 case REPAIR_PROMPT: | 899 case REPAIR_PROMPT: |
907 case DELEGATED_PERMISSIONS_PROMPT: { | 900 case DELEGATED_PERMISSIONS_PROMPT: { |
908 prompt_->set_extension(extension_); | 901 prompt_->set_extension(extension_); |
909 break; | 902 break; |
910 } | 903 } |
911 case BUNDLE_INSTALL_PROMPT: | 904 case BUNDLE_INSTALL_PROMPT: |
912 case DELEGATED_BUNDLE_PERMISSIONS_PROMPT: { | 905 case DELEGATED_BUNDLE_PERMISSIONS_PROMPT: { |
913 prompt_->set_bundle(bundle_); | 906 prompt_->set_bundle(bundle_); |
914 break; | 907 break; |
915 } | 908 } |
909 case LAUNCH_PROMPT_UNUSED: | |
910 NOTREACHED() << "Erroneous prompt type"; | |
911 return; | |
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 |