Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_settings_handler.cc

Issue 25366003: Moved some functions off ExtensionService into a new file extension_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows compile Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 19 matching lines...) Expand all
30 #include "chrome/browser/extensions/crx_installer.h" 30 #include "chrome/browser/extensions/crx_installer.h"
31 #include "chrome/browser/extensions/devtools_util.h" 31 #include "chrome/browser/extensions/devtools_util.h"
32 #include "chrome/browser/extensions/error_console/error_console.h" 32 #include "chrome/browser/extensions/error_console/error_console.h"
33 #include "chrome/browser/extensions/extension_action_manager.h" 33 #include "chrome/browser/extensions/extension_action_manager.h"
34 #include "chrome/browser/extensions/extension_disabled_ui.h" 34 #include "chrome/browser/extensions/extension_disabled_ui.h"
35 #include "chrome/browser/extensions/extension_error_reporter.h" 35 #include "chrome/browser/extensions/extension_error_reporter.h"
36 #include "chrome/browser/extensions/extension_host.h" 36 #include "chrome/browser/extensions/extension_host.h"
37 #include "chrome/browser/extensions/extension_service.h" 37 #include "chrome/browser/extensions/extension_service.h"
38 #include "chrome/browser/extensions/extension_system.h" 38 #include "chrome/browser/extensions/extension_system.h"
39 #include "chrome/browser/extensions/extension_tab_util.h" 39 #include "chrome/browser/extensions/extension_tab_util.h"
40 #include "chrome/browser/extensions/extension_util.h"
40 #include "chrome/browser/extensions/extension_warning_set.h" 41 #include "chrome/browser/extensions/extension_warning_set.h"
41 #include "chrome/browser/extensions/lazy_background_task_queue.h" 42 #include "chrome/browser/extensions/lazy_background_task_queue.h"
42 #include "chrome/browser/extensions/management_policy.h" 43 #include "chrome/browser/extensions/management_policy.h"
43 #include "chrome/browser/extensions/unpacked_installer.h" 44 #include "chrome/browser/extensions/unpacked_installer.h"
44 #include "chrome/browser/extensions/updater/extension_updater.h" 45 #include "chrome/browser/extensions/updater/extension_updater.h"
45 #include "chrome/browser/google/google_util.h" 46 #include "chrome/browser/google/google_util.h"
46 #include "chrome/browser/managed_mode/managed_user_service.h" 47 #include "chrome/browser/managed_mode/managed_user_service.h"
47 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 48 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
48 #include "chrome/browser/profiles/profile.h" 49 #include "chrome/browser/profiles/profile.h"
49 #include "chrome/browser/tab_contents/background_contents.h" 50 #include "chrome/browser/tab_contents/background_contents.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 ExtensionIconSet::MATCH_BIGGER, 203 ExtensionIconSet::MATCH_BIGGER,
203 !enabled, NULL); 204 !enabled, NULL);
204 if (Manifest::IsUnpackedLocation(extension->location())) 205 if (Manifest::IsUnpackedLocation(extension->location()))
205 extension_data->SetString("path", extension->path().value()); 206 extension_data->SetString("path", extension->path().value());
206 extension_data->SetString("icon", icon.spec()); 207 extension_data->SetString("icon", icon.spec());
207 extension_data->SetBoolean("isUnpacked", 208 extension_data->SetBoolean("isUnpacked",
208 Manifest::IsUnpackedLocation(extension->location())); 209 Manifest::IsUnpackedLocation(extension->location()));
209 extension_data->SetBoolean("terminated", 210 extension_data->SetBoolean("terminated",
210 extension_service_->terminated_extensions()->Contains(extension->id())); 211 extension_service_->terminated_extensions()->Contains(extension->id()));
211 extension_data->SetBoolean("enabledIncognito", 212 extension_data->SetBoolean("enabledIncognito",
212 extension_service_->IsIncognitoEnabled(extension->id())); 213 extension_util::IsIncognitoEnabled(extension->id(), extension_service_));
213 extension_data->SetBoolean("incognitoCanBeToggled", 214 extension_data->SetBoolean("incognitoCanBeToggled",
214 extension->can_be_incognito_enabled() && 215 extension->can_be_incognito_enabled() &&
215 !extension->force_incognito_enabled()); 216 !extension->force_incognito_enabled());
216 extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access()); 217 extension_data->SetBoolean("wantsFileAccess", extension->wants_file_access());
217 extension_data->SetBoolean("allowFileAccess", 218 extension_data->SetBoolean("allowFileAccess",
218 extension_service_->AllowFileAccess(extension)); 219 extension_util::AllowFileAccess(extension, extension_service_));
219 extension_data->SetBoolean("allow_reload", 220 extension_data->SetBoolean("allow_reload",
220 Manifest::IsUnpackedLocation(extension->location())); 221 Manifest::IsUnpackedLocation(extension->location()));
221 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app()); 222 extension_data->SetBoolean("is_hosted_app", extension->is_hosted_app());
222 extension_data->SetBoolean("is_platform_app", extension->is_platform_app()); 223 extension_data->SetBoolean("is_platform_app", extension->is_platform_app());
223 extension_data->SetBoolean("homepageProvided", 224 extension_data->SetBoolean("homepageProvided",
224 ManifestURL::GetHomepageURL(extension).is_valid()); 225 ManifestURL::GetHomepageURL(extension).is_valid());
225 226
226 string16 location_text; 227 string16 location_text;
227 if (Manifest::IsPolicyLocation(extension->location())) { 228 if (Manifest::IsPolicyLocation(extension->location())) {
228 location_text = l10n_util::GetStringUTF16( 229 location_text = l10n_util::GetStringUTF16(
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 // text to stay until the user has left the page. 855 // text to stay until the user has left the page.
855 // 856 //
856 // TODO(aa): This creates crappiness in some cases. For example, in a main 857 // TODO(aa): This creates crappiness in some cases. For example, in a main
857 // window, when toggling this, the browser action will flicker because it gets 858 // window, when toggling this, the browser action will flicker because it gets
858 // unloaded, then reloaded. It would be better to have a dedicated 859 // unloaded, then reloaded. It would be better to have a dedicated
859 // notification for this case. 860 // notification for this case.
860 // 861 //
861 // Bug: http://crbug.com/41384 862 // Bug: http://crbug.com/41384
862 base::AutoReset<bool> auto_reset_ignore_notifications( 863 base::AutoReset<bool> auto_reset_ignore_notifications(
863 &ignore_notifications_, true); 864 &ignore_notifications_, true);
864 extension_service_->SetIsIncognitoEnabled(extension->id(), 865 extension_util::SetIsIncognitoEnabled(extension->id(),
865 enable_str == "true"); 866 extension_service_,
867 enable_str == "true");
866 } 868 }
867 869
868 void ExtensionSettingsHandler::HandleAllowFileAccessMessage( 870 void ExtensionSettingsHandler::HandleAllowFileAccessMessage(
869 const base::ListValue* args) { 871 const base::ListValue* args) {
870 CHECK_EQ(2U, args->GetSize()); 872 CHECK_EQ(2U, args->GetSize());
871 std::string extension_id, allow_str; 873 std::string extension_id, allow_str;
872 CHECK(args->GetString(0, &extension_id)); 874 CHECK(args->GetString(0, &extension_id));
873 CHECK(args->GetString(1, &allow_str)); 875 CHECK(args->GetString(1, &allow_str));
874 const Extension* extension = 876 const Extension* extension =
875 extension_service_->GetInstalledExtension(extension_id); 877 extension_service_->GetInstalledExtension(extension_id);
876 if (!extension) 878 if (!extension)
877 return; 879 return;
878 880
879 if (!management_policy_->UserMayModifySettings(extension, NULL)) { 881 if (!management_policy_->UserMayModifySettings(extension, NULL)) {
880 LOG(ERROR) << "Attempt to change allow file access of an extension that is " 882 LOG(ERROR) << "Attempt to change allow file access of an extension that is "
881 << "non-usermanagable was made. Extension id : " 883 << "non-usermanagable was made. Extension id : "
882 << extension->id(); 884 << extension->id();
883 return; 885 return;
884 } 886 }
885 887
886 extension_service_->SetAllowFileAccess(extension, allow_str == "true"); 888 extension_util::SetAllowFileAccess(
889 extension, extension_service_, allow_str == "true");
887 } 890 }
888 891
889 void ExtensionSettingsHandler::HandleUninstallMessage( 892 void ExtensionSettingsHandler::HandleUninstallMessage(
890 const base::ListValue* args) { 893 const base::ListValue* args) {
891 CHECK_EQ(1U, args->GetSize()); 894 CHECK_EQ(1U, args->GetSize());
892 std::string extension_id; 895 std::string extension_id;
893 CHECK(args->GetString(0, &extension_id)); 896 CHECK(args->GetString(0, &extension_id));
894 const Extension* extension = 897 const Extension* extension =
895 extension_service_->GetInstalledExtension(extension_id); 898 extension_service_->GetInstalledExtension(extension_id);
896 if (!extension) 899 if (!extension)
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 extension_service_->EnableExtension(extension_id); 1201 extension_service_->EnableExtension(extension_id);
1199 } else { 1202 } else {
1200 ExtensionErrorReporter::GetInstance()->ReportError( 1203 ExtensionErrorReporter::GetInstance()->ReportError(
1201 UTF8ToUTF16(JoinString(requirement_errors, ' ')), 1204 UTF8ToUTF16(JoinString(requirement_errors, ' ')),
1202 true /* be noisy */); 1205 true /* be noisy */);
1203 } 1206 }
1204 requirements_checker_.reset(); 1207 requirements_checker_.reset();
1205 } 1208 }
1206 1209
1207 } // namespace extensions 1210 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698