| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/browser/extensions/updater/extension_updater.h" | 33 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 34 #include "chrome/browser/google/google_util.h" | 34 #include "chrome/browser/google/google_util.h" |
| 35 #include "chrome/browser/prefs/pref_registry_syncable.h" | 35 #include "chrome/browser/prefs/pref_registry_syncable.h" |
| 36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 37 #include "chrome/browser/tab_contents/background_contents.h" | 37 #include "chrome/browser/tab_contents/background_contents.h" |
| 38 #include "chrome/browser/ui/browser_finder.h" | 38 #include "chrome/browser/ui/browser_finder.h" |
| 39 #include "chrome/browser/ui/chrome_select_file_policy.h" | 39 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 40 #include "chrome/browser/ui/extensions/application_launch.h" | 40 #include "chrome/browser/ui/extensions/application_launch.h" |
| 41 #include "chrome/browser/ui/extensions/shell_window.h" | 41 #include "chrome/browser/ui/extensions/shell_window.h" |
| 42 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 42 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 43 #include "chrome/browser/ui/webui/managed_user_passphrase_dialog.h" |
| 43 #include "chrome/browser/view_type_utils.h" | 44 #include "chrome/browser/view_type_utils.h" |
| 44 #include "chrome/common/chrome_notification_types.h" | 45 #include "chrome/common/chrome_notification_types.h" |
| 45 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
| 46 #include "chrome/common/extensions/extension.h" | 47 #include "chrome/common/extensions/extension.h" |
| 47 #include "chrome/common/extensions/extension_constants.h" | 48 #include "chrome/common/extensions/extension_constants.h" |
| 48 #include "chrome/common/extensions/extension_icon_set.h" | 49 #include "chrome/common/extensions/extension_icon_set.h" |
| 49 #include "chrome/common/extensions/extension_set.h" | 50 #include "chrome/common/extensions/extension_set.h" |
| 50 #include "chrome/common/extensions/feature_switch.h" | 51 #include "chrome/common/extensions/feature_switch.h" |
| 51 #include "chrome/common/extensions/manifest_url_handler.h" | 52 #include "chrome/common/extensions/manifest_url_handler.h" |
| 52 #include "chrome/common/pref_names.h" | 53 #include "chrome/common/pref_names.h" |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 if ((*extension)->location() == Manifest::LOAD) | 538 if ((*extension)->location() == Manifest::LOAD) |
| 538 unpacked_extensions.push_back(*extension); | 539 unpacked_extensions.push_back(*extension); |
| 539 } | 540 } |
| 540 | 541 |
| 541 for (std::vector<const Extension*>::iterator iter = | 542 for (std::vector<const Extension*>::iterator iter = |
| 542 unpacked_extensions.begin(); iter != unpacked_extensions.end(); ++iter) { | 543 unpacked_extensions.begin(); iter != unpacked_extensions.end(); ++iter) { |
| 543 extension_service_->ReloadExtension((*iter)->id()); | 544 extension_service_->ReloadExtension((*iter)->id()); |
| 544 } | 545 } |
| 545 } | 546 } |
| 546 | 547 |
| 548 void ExtensionSettingsHandler::PassphraseDialogCallback(bool success) { |
| 549 if (success) |
| 550 HandleRequestExtensionsData(NULL); |
| 551 } |
| 552 |
| 547 void ExtensionSettingsHandler::ManagedUserSetElevated(const ListValue* args) { | 553 void ExtensionSettingsHandler::ManagedUserSetElevated(const ListValue* args) { |
| 548 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( | 554 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( |
| 549 Profile::FromWebUI(web_ui())); | 555 Profile::FromWebUI(web_ui())); |
| 550 bool elevated; | 556 bool elevated; |
| 551 CHECK(args->GetBoolean(0, &elevated)); | 557 CHECK(args->GetBoolean(0, &elevated)); |
| 552 // TODO(akuegel): Show the managed user passphrase dialog for authentication | 558 if (!service->IsElevated() && elevated) { |
| 553 // if elevated should be set to true. | 559 new ManagedUserPassphraseDialog( |
| 560 web_ui()->GetWebContents(), |
| 561 base::Bind(&ExtensionSettingsHandler::PassphraseDialogCallback, |
| 562 base::Unretained(this))); |
| 563 return; |
| 564 } |
| 554 service->SetElevated(elevated); | 565 service->SetElevated(elevated); |
| 555 HandleRequestExtensionsData(NULL); | 566 HandleRequestExtensionsData(NULL); |
| 556 } | 567 } |
| 557 | 568 |
| 558 void ExtensionSettingsHandler::HandleRequestExtensionsData( | 569 void ExtensionSettingsHandler::HandleRequestExtensionsData( |
| 559 const ListValue* args) { | 570 const ListValue* args) { |
| 560 DictionaryValue results; | 571 DictionaryValue results; |
| 561 | 572 |
| 562 Profile* profile = Profile::FromWebUI(web_ui()); | 573 Profile* profile = Profile::FromWebUI(web_ui()); |
| 563 | 574 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 std::vector<std::string> requirement_errors) { | 1067 std::vector<std::string> requirement_errors) { |
| 1057 if (requirement_errors.empty()) { | 1068 if (requirement_errors.empty()) { |
| 1058 extension_service_->EnableExtension(extension_id); | 1069 extension_service_->EnableExtension(extension_id); |
| 1059 } else { | 1070 } else { |
| 1060 ExtensionErrorReporter::GetInstance()->ReportError( | 1071 ExtensionErrorReporter::GetInstance()->ReportError( |
| 1061 UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1072 UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
| 1062 true /* be noisy */); | 1073 true /* be noisy */); |
| 1063 } | 1074 } |
| 1064 requirements_checker_.reset(); | 1075 requirements_checker_.reset(); |
| 1065 } | 1076 } |
| OLD | NEW |