| 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/app_window.h" | 9 #include "apps/app_window.h" |
| 10 #include "apps/app_window_registry.h" | 10 #include "apps/app_window_registry.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/extensions/devtools_util.h" | 32 #include "chrome/browser/extensions/devtools_util.h" |
| 33 #include "chrome/browser/extensions/error_console/error_console.h" | 33 #include "chrome/browser/extensions/error_console/error_console.h" |
| 34 #include "chrome/browser/extensions/extension_action_manager.h" | 34 #include "chrome/browser/extensions/extension_action_manager.h" |
| 35 #include "chrome/browser/extensions/extension_disabled_ui.h" | 35 #include "chrome/browser/extensions/extension_disabled_ui.h" |
| 36 #include "chrome/browser/extensions/extension_error_reporter.h" | 36 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 37 #include "chrome/browser/extensions/extension_service.h" | 37 #include "chrome/browser/extensions/extension_service.h" |
| 38 #include "chrome/browser/extensions/extension_tab_util.h" | 38 #include "chrome/browser/extensions/extension_tab_util.h" |
| 39 #include "chrome/browser/extensions/extension_util.h" | 39 #include "chrome/browser/extensions/extension_util.h" |
| 40 #include "chrome/browser/extensions/extension_warning_set.h" | 40 #include "chrome/browser/extensions/extension_warning_set.h" |
| 41 #include "chrome/browser/extensions/install_verifier.h" | 41 #include "chrome/browser/extensions/install_verifier.h" |
| 42 #include "chrome/browser/extensions/unpacked_installer.h" | |
| 43 #include "chrome/browser/extensions/updater/extension_updater.h" | 42 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 44 #include "chrome/browser/google/google_util.h" | 43 #include "chrome/browser/google/google_util.h" |
| 45 #include "chrome/browser/managed_mode/managed_user_service.h" | 44 #include "chrome/browser/managed_mode/managed_user_service.h" |
| 46 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 45 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
| 47 #include "chrome/browser/profiles/profile.h" | 46 #include "chrome/browser/profiles/profile.h" |
| 48 #include "chrome/browser/tab_contents/background_contents.h" | 47 #include "chrome/browser/tab_contents/background_contents.h" |
| 49 #include "chrome/browser/ui/browser_finder.h" | 48 #include "chrome/browser/ui/browser_finder.h" |
| 50 #include "chrome/browser/ui/chrome_select_file_policy.h" | |
| 51 #include "chrome/browser/ui/extensions/application_launch.h" | 49 #include "chrome/browser/ui/extensions/application_launch.h" |
| 52 #include "chrome/browser/ui/webui/extensions/extension_basic_info.h" | 50 #include "chrome/browser/ui/webui/extensions/extension_basic_info.h" |
| 53 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 51 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 54 #include "chrome/common/chrome_switches.h" | 52 #include "chrome/common/chrome_switches.h" |
| 55 #include "chrome/common/chrome_version_info.h" | 53 #include "chrome/common/chrome_version_info.h" |
| 56 #include "chrome/common/extensions/extension_constants.h" | 54 #include "chrome/common/extensions/extension_constants.h" |
| 57 #include "chrome/common/extensions/features/feature_channel.h" | 55 #include "chrome/common/extensions/features/feature_channel.h" |
| 58 #include "chrome/common/extensions/manifest_url_handler.h" | 56 #include "chrome/common/extensions/manifest_url_handler.h" |
| 59 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
| 60 #include "chrome/common/url_constants.h" | 58 #include "chrome/common/url_constants.h" |
| 61 #include "components/user_prefs/pref_registry_syncable.h" | 59 #include "components/user_prefs/pref_registry_syncable.h" |
| 62 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
| 63 #include "content/public/browser/notification_source.h" | 61 #include "content/public/browser/notification_source.h" |
| 64 #include "content/public/browser/notification_types.h" | 62 #include "content/public/browser/notification_types.h" |
| 65 #include "content/public/browser/render_process_host.h" | 63 #include "content/public/browser/render_process_host.h" |
| 66 #include "content/public/browser/render_view_host.h" | 64 #include "content/public/browser/render_view_host.h" |
| 67 #include "content/public/browser/site_instance.h" | 65 #include "content/public/browser/site_instance.h" |
| 68 #include "content/public/browser/user_metrics.h" | |
| 69 #include "content/public/browser/web_contents.h" | 66 #include "content/public/browser/web_contents.h" |
| 70 #include "content/public/browser/web_contents_view.h" | |
| 71 #include "content/public/browser/web_ui.h" | 67 #include "content/public/browser/web_ui.h" |
| 72 #include "content/public/browser/web_ui_data_source.h" | 68 #include "content/public/browser/web_ui_data_source.h" |
| 73 #include "extensions/browser/blacklist_state.h" | 69 #include "extensions/browser/blacklist_state.h" |
| 74 #include "extensions/browser/extension_error.h" | 70 #include "extensions/browser/extension_error.h" |
| 75 #include "extensions/browser/extension_host.h" | 71 #include "extensions/browser/extension_host.h" |
| 76 #include "extensions/browser/extension_registry.h" | 72 #include "extensions/browser/extension_registry.h" |
| 77 #include "extensions/browser/extension_system.h" | 73 #include "extensions/browser/extension_system.h" |
| 78 #include "extensions/browser/lazy_background_task_queue.h" | 74 #include "extensions/browser/lazy_background_task_queue.h" |
| 79 #include "extensions/browser/management_policy.h" | 75 #include "extensions/browser/management_policy.h" |
| 80 #include "extensions/browser/pref_names.h" | 76 #include "extensions/browser/pref_names.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 deleting_rwh_id_(-1), | 159 deleting_rwh_id_(-1), |
| 164 deleting_rph_id_(-1), | 160 deleting_rph_id_(-1), |
| 165 registered_for_notifications_(false), | 161 registered_for_notifications_(false), |
| 166 warning_service_observer_(this), | 162 warning_service_observer_(this), |
| 167 error_console_observer_(this), | 163 error_console_observer_(this), |
| 168 extension_prefs_observer_(this), | 164 extension_prefs_observer_(this), |
| 169 should_do_verification_check_(false) { | 165 should_do_verification_check_(false) { |
| 170 } | 166 } |
| 171 | 167 |
| 172 ExtensionSettingsHandler::~ExtensionSettingsHandler() { | 168 ExtensionSettingsHandler::~ExtensionSettingsHandler() { |
| 173 // There may be pending file dialogs, we need to tell them that we've gone | |
| 174 // away so they don't try and call back to us. | |
| 175 if (load_extension_dialog_.get()) | |
| 176 load_extension_dialog_->ListenerDestroyed(); | |
| 177 } | 169 } |
| 178 | 170 |
| 179 ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service, | 171 ExtensionSettingsHandler::ExtensionSettingsHandler(ExtensionService* service, |
| 180 ManagementPolicy* policy) | 172 ManagementPolicy* policy) |
| 181 : extension_service_(service), | 173 : extension_service_(service), |
| 182 management_policy_(policy), | 174 management_policy_(policy), |
| 183 ignore_notifications_(false), | 175 ignore_notifications_(false), |
| 184 deleting_rvh_(NULL), | 176 deleting_rvh_(NULL), |
| 185 deleting_rwh_id_(-1), | 177 deleting_rwh_id_(-1), |
| 186 deleting_rph_id_(-1), | 178 deleting_rph_id_(-1), |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 AsWeakPtr())); | 568 AsWeakPtr())); |
| 577 web_ui()->RegisterMessageCallback("extensionSettingsPermissions", | 569 web_ui()->RegisterMessageCallback("extensionSettingsPermissions", |
| 578 base::Bind(&ExtensionSettingsHandler::HandlePermissionsMessage, | 570 base::Bind(&ExtensionSettingsHandler::HandlePermissionsMessage, |
| 579 AsWeakPtr())); | 571 AsWeakPtr())); |
| 580 web_ui()->RegisterMessageCallback("extensionSettingsShowButton", | 572 web_ui()->RegisterMessageCallback("extensionSettingsShowButton", |
| 581 base::Bind(&ExtensionSettingsHandler::HandleShowButtonMessage, | 573 base::Bind(&ExtensionSettingsHandler::HandleShowButtonMessage, |
| 582 AsWeakPtr())); | 574 AsWeakPtr())); |
| 583 web_ui()->RegisterMessageCallback("extensionSettingsAutoupdate", | 575 web_ui()->RegisterMessageCallback("extensionSettingsAutoupdate", |
| 584 base::Bind(&ExtensionSettingsHandler::HandleAutoUpdateMessage, | 576 base::Bind(&ExtensionSettingsHandler::HandleAutoUpdateMessage, |
| 585 AsWeakPtr())); | 577 AsWeakPtr())); |
| 586 web_ui()->RegisterMessageCallback("extensionSettingsLoadUnpackedExtension", | |
| 587 base::Bind(&ExtensionSettingsHandler::HandleLoadUnpackedExtensionMessage, | |
| 588 AsWeakPtr())); | |
| 589 web_ui()->RegisterMessageCallback("extensionSettingsDismissADTPromo", | 578 web_ui()->RegisterMessageCallback("extensionSettingsDismissADTPromo", |
| 590 base::Bind(&ExtensionSettingsHandler::HandleDismissADTPromoMessage, | 579 base::Bind(&ExtensionSettingsHandler::HandleDismissADTPromoMessage, |
| 591 AsWeakPtr())); | 580 AsWeakPtr())); |
| 592 } | 581 } |
| 593 | 582 |
| 594 void ExtensionSettingsHandler::LoadUnpackedExtension( | |
| 595 const base::FilePath& path) { | |
| 596 UnpackedInstaller::Create(extension_service_)->Load(path); | |
| 597 } | |
| 598 | |
| 599 int ExtensionSettingsHandler::IndexOfLoadingPath(const base::FilePath& path) { | |
| 600 for (size_t i = 0; i < loading_extension_directories_.size(); ++i) { | |
| 601 if (path == loading_extension_directories_[i]) | |
| 602 return i; | |
| 603 } | |
| 604 return -1; | |
| 605 } | |
| 606 | |
| 607 void ExtensionSettingsHandler::AddLoadingPath(const base::FilePath& path) { | |
| 608 DCHECK(IndexOfLoadingPath(path) == -1); | |
| 609 | |
| 610 if (loading_extension_directories_.empty()) { | |
| 611 Profile* profile = Profile::FromWebUI(web_ui()); | |
| 612 registrar_.Add(this, | |
| 613 chrome::NOTIFICATION_EXTENSION_LOAD_RETRY, | |
| 614 content::Source<Profile>(profile)); | |
| 615 } | |
| 616 loading_extension_directories_.push_back(path); | |
| 617 } | |
| 618 | |
| 619 void ExtensionSettingsHandler::RemoveLoadingPath(const base::FilePath& path) { | |
| 620 int index = IndexOfLoadingPath(path); | |
| 621 DCHECK(index != -1); | |
| 622 | |
| 623 loading_extension_directories_.erase(loading_extension_directories_.begin() + | |
| 624 index); | |
| 625 if (loading_extension_directories_.empty()) { | |
| 626 Profile* profile = Profile::FromWebUI(web_ui()); | |
| 627 registrar_.Remove(this, | |
| 628 chrome::NOTIFICATION_EXTENSION_LOAD_RETRY, | |
| 629 content::Source<Profile>(profile)); | |
| 630 } | |
| 631 } | |
| 632 | |
| 633 void ExtensionSettingsHandler::FileSelected(const base::FilePath& path, | |
| 634 int index, | |
| 635 void* params) { | |
| 636 last_unpacked_directory_ = base::FilePath(path); | |
| 637 AddLoadingPath(last_unpacked_directory_); | |
| 638 LoadUnpackedExtension(path); | |
| 639 } | |
| 640 | |
| 641 void ExtensionSettingsHandler::MultiFilesSelected( | |
| 642 const std::vector<base::FilePath>& files, void* params) { | |
| 643 NOTREACHED(); | |
| 644 } | |
| 645 | |
| 646 void ExtensionSettingsHandler::FileSelectionCanceled(void* params) { | |
| 647 } | |
| 648 | |
| 649 void ExtensionSettingsHandler::OnErrorAdded(const ExtensionError* error) { | 583 void ExtensionSettingsHandler::OnErrorAdded(const ExtensionError* error) { |
| 650 MaybeUpdateAfterNotification(); | 584 MaybeUpdateAfterNotification(); |
| 651 } | 585 } |
| 652 | 586 |
| 653 void ExtensionSettingsHandler::Observe( | 587 void ExtensionSettingsHandler::Observe( |
| 654 int type, | 588 int type, |
| 655 const content::NotificationSource& source, | 589 const content::NotificationSource& source, |
| 656 const content::NotificationDetails& details) { | 590 const content::NotificationDetails& details) { |
| 657 Profile* profile = Profile::FromWebUI(web_ui()); | 591 Profile* profile = Profile::FromWebUI(web_ui()); |
| 658 Profile* source_profile = NULL; | 592 Profile* source_profile = NULL; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 678 MaybeUpdateAfterNotification(); | 612 MaybeUpdateAfterNotification(); |
| 679 break; | 613 break; |
| 680 case content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { | 614 case content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { |
| 681 content::RenderWidgetHost* rwh = | 615 content::RenderWidgetHost* rwh = |
| 682 content::Source<content::RenderWidgetHost>(source).ptr(); | 616 content::Source<content::RenderWidgetHost>(source).ptr(); |
| 683 deleting_rwh_id_ = rwh->GetRoutingID(); | 617 deleting_rwh_id_ = rwh->GetRoutingID(); |
| 684 deleting_rph_id_ = rwh->GetProcess()->GetID(); | 618 deleting_rph_id_ = rwh->GetProcess()->GetID(); |
| 685 MaybeUpdateAfterNotification(); | 619 MaybeUpdateAfterNotification(); |
| 686 break; | 620 break; |
| 687 } | 621 } |
| 688 case chrome::NOTIFICATION_EXTENSION_LOAD_RETRY: { | 622 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: |
| 689 std::pair<bool, const base::FilePath&>* retry_and_path = | |
| 690 content::Details<std::pair<bool, const base::FilePath&> >(details) | |
| 691 .ptr(); | |
| 692 HandleLoadRetryMessage(retry_and_path->first, retry_and_path->second); | |
| 693 break; | |
| 694 } | |
| 695 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { | |
| 696 const base::FilePath& path = | |
| 697 content::Details<const Extension>(details).ptr()->path(); | |
| 698 if (IndexOfLoadingPath(path) != -1) | |
| 699 RemoveLoadingPath(path); | |
| 700 // Fall through. | |
| 701 } | |
| 702 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: | 623 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: |
| 703 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: | 624 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: |
| 704 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: | 625 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
| 705 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: | 626 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: |
| 706 MaybeUpdateAfterNotification(); | 627 MaybeUpdateAfterNotification(); |
| 707 break; | 628 break; |
| 708 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: | 629 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: |
| 709 // This notification is sent when the extension host destruction begins, | 630 // This notification is sent when the extension host destruction begins, |
| 710 // not when it finishes. We use PostTask to delay the update until after | 631 // not when it finishes. We use PostTask to delay the update until after |
| 711 // the destruction finishes. | 632 // the destruction finishes. |
| 712 base::MessageLoop::current()->PostTask( | 633 base::MessageLoop::current()->PostTask( |
| 713 FROM_HERE, | 634 FROM_HERE, |
| 714 base::Bind(&ExtensionSettingsHandler::MaybeUpdateAfterNotification, | 635 base::Bind(&ExtensionSettingsHandler::MaybeUpdateAfterNotification, |
| 715 AsWeakPtr())); | 636 AsWeakPtr())); |
| 716 break; | 637 break; |
| 717 default: | 638 default: |
| 718 NOTREACHED(); | 639 NOTREACHED(); |
| 719 } | 640 } |
| 720 } | 641 } |
| 721 | 642 |
| 722 void ExtensionSettingsHandler::OnExtensionDisableReasonsChanged( | 643 void ExtensionSettingsHandler::OnExtensionDisableReasonsChanged( |
| 723 const std::string& extension_id, | 644 const std::string& extension_id, int disable_reasons) { |
| 724 int disable_reasons) { | |
| 725 MaybeUpdateAfterNotification(); | 645 MaybeUpdateAfterNotification(); |
| 726 } | 646 } |
| 727 | 647 |
| 728 void ExtensionSettingsHandler::ExtensionUninstallAccepted() { | 648 void ExtensionSettingsHandler::ExtensionUninstallAccepted() { |
| 729 DCHECK(!extension_id_prompting_.empty()); | 649 DCHECK(!extension_id_prompting_.empty()); |
| 730 | 650 |
| 731 bool was_terminated = false; | 651 bool was_terminated = false; |
| 732 | 652 |
| 733 // The extension can be uninstalled in another window while the UI was | 653 // The extension can be uninstalled in another window while the UI was |
| 734 // showing. Do nothing in that case. | 654 // showing. Do nothing in that case. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 const ExtensionSet* extensions = extension_service_->extensions(); | 703 const ExtensionSet* extensions = extension_service_->extensions(); |
| 784 std::vector<const Extension*> unpacked_extensions; | 704 std::vector<const Extension*> unpacked_extensions; |
| 785 for (ExtensionSet::const_iterator extension = extensions->begin(); | 705 for (ExtensionSet::const_iterator extension = extensions->begin(); |
| 786 extension != extensions->end(); ++extension) { | 706 extension != extensions->end(); ++extension) { |
| 787 if (Manifest::IsUnpackedLocation((*extension)->location())) | 707 if (Manifest::IsUnpackedLocation((*extension)->location())) |
| 788 unpacked_extensions.push_back(extension->get()); | 708 unpacked_extensions.push_back(extension->get()); |
| 789 } | 709 } |
| 790 | 710 |
| 791 for (std::vector<const Extension*>::iterator iter = | 711 for (std::vector<const Extension*>::iterator iter = |
| 792 unpacked_extensions.begin(); iter != unpacked_extensions.end(); ++iter) { | 712 unpacked_extensions.begin(); iter != unpacked_extensions.end(); ++iter) { |
| 793 AddLoadingPath((*iter)->path()); | |
| 794 extension_service_->ReloadExtension((*iter)->id()); | 713 extension_service_->ReloadExtension((*iter)->id()); |
| 795 } | 714 } |
| 796 } | 715 } |
| 797 | 716 |
| 798 void ExtensionSettingsHandler::HandleRequestExtensionsData( | 717 void ExtensionSettingsHandler::HandleRequestExtensionsData( |
| 799 const base::ListValue* args) { | 718 const base::ListValue* args) { |
| 800 base::DictionaryValue results; | 719 base::DictionaryValue results; |
| 801 | 720 |
| 802 Profile* profile = Profile::FromWebUI(web_ui()); | 721 Profile* profile = Profile::FromWebUI(web_ui()); |
| 803 | 722 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 extension_service_->GetExtensionById(extension_id, false); | 856 extension_service_->GetExtensionById(extension_id, false); |
| 938 OpenApplication(AppLaunchParams(extension_service_->profile(), extension, | 857 OpenApplication(AppLaunchParams(extension_service_->profile(), extension, |
| 939 extensions::LAUNCH_CONTAINER_WINDOW, | 858 extensions::LAUNCH_CONTAINER_WINDOW, |
| 940 NEW_WINDOW)); | 859 NEW_WINDOW)); |
| 941 } | 860 } |
| 942 | 861 |
| 943 void ExtensionSettingsHandler::HandleReloadMessage( | 862 void ExtensionSettingsHandler::HandleReloadMessage( |
| 944 const base::ListValue* args) { | 863 const base::ListValue* args) { |
| 945 std::string extension_id = base::UTF16ToUTF8(ExtractStringValue(args)); | 864 std::string extension_id = base::UTF16ToUTF8(ExtractStringValue(args)); |
| 946 CHECK(!extension_id.empty()); | 865 CHECK(!extension_id.empty()); |
| 947 const Extension* extension = | |
| 948 extension_service_->GetInstalledExtension(extension_id); | |
| 949 if (extension) | |
| 950 AddLoadingPath(extension->path()); | |
| 951 extension_service_->ReloadExtension(extension_id); | 866 extension_service_->ReloadExtension(extension_id); |
| 952 } | 867 } |
| 953 | 868 |
| 954 void ExtensionSettingsHandler::HandleEnableMessage( | 869 void ExtensionSettingsHandler::HandleEnableMessage( |
| 955 const base::ListValue* args) { | 870 const base::ListValue* args) { |
| 956 CHECK_EQ(2U, args->GetSize()); | 871 CHECK_EQ(2U, args->GetSize()); |
| 957 std::string extension_id, enable_str; | 872 std::string extension_id, enable_str; |
| 958 CHECK(args->GetString(0, &extension_id)); | 873 CHECK(args->GetString(0, &extension_id)); |
| 959 CHECK(args->GetString(1, &enable_str)); | 874 CHECK(args->GetString(1, &enable_str)); |
| 960 | 875 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 void ExtensionSettingsHandler::HandleAutoUpdateMessage( | 1049 void ExtensionSettingsHandler::HandleAutoUpdateMessage( |
| 1135 const base::ListValue* args) { | 1050 const base::ListValue* args) { |
| 1136 ExtensionUpdater* updater = extension_service_->updater(); | 1051 ExtensionUpdater* updater = extension_service_->updater(); |
| 1137 if (updater) { | 1052 if (updater) { |
| 1138 ExtensionUpdater::CheckParams params; | 1053 ExtensionUpdater::CheckParams params; |
| 1139 params.install_immediately = true; | 1054 params.install_immediately = true; |
| 1140 updater->CheckNow(params); | 1055 updater->CheckNow(params); |
| 1141 } | 1056 } |
| 1142 } | 1057 } |
| 1143 | 1058 |
| 1144 void ExtensionSettingsHandler::HandleLoadUnpackedExtensionMessage( | |
| 1145 const base::ListValue* args) { | |
| 1146 DCHECK(args->empty()); | |
| 1147 | |
| 1148 base::string16 select_title = | |
| 1149 l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY); | |
| 1150 | |
| 1151 const int kFileTypeIndex = 0; // No file type information to index. | |
| 1152 const ui::SelectFileDialog::Type kSelectType = | |
| 1153 ui::SelectFileDialog::SELECT_FOLDER; | |
| 1154 load_extension_dialog_ = ui::SelectFileDialog::Create( | |
| 1155 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); | |
| 1156 load_extension_dialog_->SelectFile( | |
| 1157 kSelectType, | |
| 1158 select_title, | |
| 1159 last_unpacked_directory_, | |
| 1160 NULL, | |
| 1161 kFileTypeIndex, | |
| 1162 base::FilePath::StringType(), | |
| 1163 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), | |
| 1164 NULL); | |
| 1165 | |
| 1166 content::RecordComputedAction("Options_LoadUnpackedExtension"); | |
| 1167 } | |
| 1168 | |
| 1169 void ExtensionSettingsHandler::HandleDismissADTPromoMessage( | 1059 void ExtensionSettingsHandler::HandleDismissADTPromoMessage( |
| 1170 const base::ListValue* args) { | 1060 const base::ListValue* args) { |
| 1171 DCHECK(args->empty()); | 1061 DCHECK(args->empty()); |
| 1172 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | 1062 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
| 1173 prefs::kExtensionsUIDismissedADTPromo, true); | 1063 prefs::kExtensionsUIDismissedADTPromo, true); |
| 1174 } | 1064 } |
| 1175 | 1065 |
| 1176 void ExtensionSettingsHandler::ShowAlert(const std::string& message) { | 1066 void ExtensionSettingsHandler::ShowAlert(const std::string& message) { |
| 1177 base::ListValue arguments; | 1067 base::ListValue arguments; |
| 1178 arguments.Append(base::Value::CreateStringValue(message)); | 1068 arguments.Append(base::Value::CreateStringValue(message)); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 } | 1269 } |
| 1380 | 1270 |
| 1381 void ExtensionSettingsHandler::OnRequirementsChecked( | 1271 void ExtensionSettingsHandler::OnRequirementsChecked( |
| 1382 std::string extension_id, | 1272 std::string extension_id, |
| 1383 std::vector<std::string> requirement_errors) { | 1273 std::vector<std::string> requirement_errors) { |
| 1384 if (requirement_errors.empty()) { | 1274 if (requirement_errors.empty()) { |
| 1385 extension_service_->EnableExtension(extension_id); | 1275 extension_service_->EnableExtension(extension_id); |
| 1386 } else { | 1276 } else { |
| 1387 ExtensionErrorReporter::GetInstance()->ReportError( | 1277 ExtensionErrorReporter::GetInstance()->ReportError( |
| 1388 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1278 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
| 1389 true, // Be noisy. | 1279 true); // Be noisy. |
| 1390 NULL); // Caller expects no response. | |
| 1391 } | 1280 } |
| 1392 requirements_checker_.reset(); | 1281 requirements_checker_.reset(); |
| 1393 } | 1282 } |
| 1394 | 1283 |
| 1395 void ExtensionSettingsHandler::HandleLoadRetryMessage( | |
| 1396 bool retry, | |
| 1397 const base::FilePath& path) { | |
| 1398 if (IndexOfLoadingPath(path) == -1) | |
| 1399 return; // Not an extension we're tracking. | |
| 1400 if (retry) | |
| 1401 LoadUnpackedExtension(path); | |
| 1402 else | |
| 1403 RemoveLoadingPath(path); | |
| 1404 } | |
| 1405 | |
| 1406 } // namespace extensions | 1284 } // namespace extensions |
| OLD | NEW |