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/ui/webui/extensions/extension_settings_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" |
6 | 6 |
7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
8 #include "apps/app_restore_service.h" | 8 #include "apps/app_restore_service.h" |
9 #include "apps/saved_files_service.h" | 9 #include "apps/saved_files_service.h" |
10 #include "apps/shell_window.h" | 10 #include "apps/shell_window.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service, | 165 ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service, |
166 ManagementPolicy* policy) | 166 ManagementPolicy* policy) |
167 : extension_service_(service), | 167 : extension_service_(service), |
168 management_policy_(policy), | 168 management_policy_(policy), |
169 ignore_notifications_(false), | 169 ignore_notifications_(false), |
170 deleting_rvh_(NULL), | 170 deleting_rvh_(NULL), |
171 deleting_rwh_id_(-1), | 171 deleting_rwh_id_(-1), |
172 deleting_rph_id_(-1), | 172 deleting_rph_id_(-1), |
173 registered_for_notifications_(false), | 173 registered_for_notifications_(false), |
174 warning_service_observer_(this), | 174 warning_service_observer_(this), |
175 error_console_observer_(this) { | 175 error_console_observer_(this), |
| 176 should_do_verification_check_(false) { |
176 } | 177 } |
177 | 178 |
178 // static | 179 // static |
179 void ExtensionSettingsHandler::RegisterProfilePrefs( | 180 void ExtensionSettingsHandler::RegisterProfilePrefs( |
180 user_prefs::PrefRegistrySyncable* registry) { | 181 user_prefs::PrefRegistrySyncable* registry) { |
181 registry->RegisterBooleanPref( | 182 registry->RegisterBooleanPref( |
182 prefs::kExtensionsUIDeveloperMode, | 183 prefs::kExtensionsUIDeveloperMode, |
183 false, | 184 false, |
184 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 185 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
185 } | 186 } |
186 | 187 |
187 base::DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( | 188 base::DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue( |
188 const Extension* extension, | 189 const Extension* extension, |
189 const std::vector<ExtensionPage>& pages, | 190 const std::vector<ExtensionPage>& pages, |
190 const ExtensionWarningService* warning_service) { | 191 const ExtensionWarningService* warning_service) { |
191 base::DictionaryValue* extension_data = new base::DictionaryValue(); | 192 base::DictionaryValue* extension_data = new base::DictionaryValue(); |
192 bool enabled = extension_service_->IsExtensionEnabled(extension->id()); | 193 bool enabled = extension_service_->IsExtensionEnabled(extension->id()); |
193 GetExtensionBasicInfo(extension, enabled, extension_data); | 194 GetExtensionBasicInfo(extension, enabled, extension_data); |
194 | 195 |
195 ExtensionPrefs* prefs = extension_service_->extension_prefs(); | 196 ExtensionPrefs* prefs = extension_service_->extension_prefs(); |
196 int disable_reasons = prefs->GetDisableReasons(extension->id()); | 197 int disable_reasons = prefs->GetDisableReasons(extension->id()); |
197 | 198 |
198 bool suspicious_install = | 199 bool suspicious_install = |
199 (disable_reasons & Extension::DISABLE_NOT_VERIFIED) != 0; | 200 (disable_reasons & Extension::DISABLE_NOT_VERIFIED) != 0; |
200 extension_data->SetBoolean("suspiciousInstall", suspicious_install); | 201 extension_data->SetBoolean("suspiciousInstall", suspicious_install); |
| 202 if (suspicious_install) |
| 203 should_do_verification_check_ = true; |
201 | 204 |
202 bool managed_install = | 205 bool managed_install = |
203 !management_policy_->UserMayModifySettings(extension, NULL); | 206 !management_policy_->UserMayModifySettings(extension, NULL); |
204 extension_data->SetBoolean("managedInstall", managed_install); | 207 extension_data->SetBoolean("managedInstall", managed_install); |
205 | 208 |
206 // We should not get into a state where both are true. | 209 // We should not get into a state where both are true. |
207 DCHECK(managed_install == false || suspicious_install == false); | 210 DCHECK(managed_install == false || suspicious_install == false); |
208 | 211 |
209 GURL icon = | 212 GURL icon = |
210 ExtensionIconSource::GetIconURL(extension, | 213 ExtensionIconSource::GetIconURL(extension, |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsDevtool)); | 727 CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsDevtool)); |
725 | 728 |
726 bool load_unpacked_disabled = | 729 bool load_unpacked_disabled = |
727 extension_service_->extension_prefs()->ExtensionsBlacklistedByDefault(); | 730 extension_service_->extension_prefs()->ExtensionsBlacklistedByDefault(); |
728 results.SetBoolean("loadUnpackedDisabled", load_unpacked_disabled); | 731 results.SetBoolean("loadUnpackedDisabled", load_unpacked_disabled); |
729 | 732 |
730 web_ui()->CallJavascriptFunction( | 733 web_ui()->CallJavascriptFunction( |
731 "extensions.ExtensionSettings.returnExtensionsData", results); | 734 "extensions.ExtensionSettings.returnExtensionsData", results); |
732 | 735 |
733 MaybeRegisterForNotifications(); | 736 MaybeRegisterForNotifications(); |
| 737 if (should_do_verification_check_) { |
| 738 should_do_verification_check_ = false; |
| 739 extension_service_->VerifyAllExtensions(); |
| 740 } |
734 } | 741 } |
735 | 742 |
736 void ExtensionSettingsHandler::HandleToggleDeveloperMode( | 743 void ExtensionSettingsHandler::HandleToggleDeveloperMode( |
737 const base::ListValue* args) { | 744 const base::ListValue* args) { |
738 Profile* profile = Profile::FromWebUI(web_ui()); | 745 Profile* profile = Profile::FromWebUI(web_ui()); |
739 if (profile->IsManaged()) | 746 if (profile->IsManaged()) |
740 return; | 747 return; |
741 | 748 |
742 bool developer_mode = | 749 bool developer_mode = |
743 !profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); | 750 !profile->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode); |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 extension_service_->EnableExtension(extension_id); | 1234 extension_service_->EnableExtension(extension_id); |
1228 } else { | 1235 } else { |
1229 ExtensionErrorReporter::GetInstance()->ReportError( | 1236 ExtensionErrorReporter::GetInstance()->ReportError( |
1230 UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1237 UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
1231 true /* be noisy */); | 1238 true /* be noisy */); |
1232 } | 1239 } |
1233 requirements_checker_.reset(); | 1240 requirements_checker_.reset(); |
1234 } | 1241 } |
1235 | 1242 |
1236 } // namespace extensions | 1243 } // namespace extensions |
OLD | NEW |