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/api/developer_private/developer_private_api. h" | 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/guid.h" | 12 #include "base/guid.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/task_scheduler/post_task.h" | 19 #include "base/task_scheduler/post_task.h" |
20 #include "chrome/browser/devtools/devtools_window.h" | 20 #include "chrome/browser/devtools/devtools_window.h" |
21 #include "chrome/browser/extensions/api/developer_private/developer_private_mang le.h" | 21 #include "chrome/browser/extensions/api/developer_private/developer_private_mang le.h" |
22 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" | 22 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" |
23 #include "chrome/browser/extensions/api/developer_private/extension_info_generat or.h" | 23 #include "chrome/browser/extensions/api/developer_private/extension_info_generat or.h" |
24 #include "chrome/browser/extensions/api/developer_private/show_permissions_dialo g_helper.h" | 24 #include "chrome/browser/extensions/api/developer_private/show_permissions_dialo g_helper.h" |
25 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 25 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
Dan Beam
2017/05/30 23:31:43
still used?
Devlin
2017/05/31 18:04:53
Good catch, removed.
| |
26 #include "chrome/browser/extensions/devtools_util.h" | 26 #include "chrome/browser/extensions/devtools_util.h" |
27 #include "chrome/browser/extensions/extension_commands_global_registry.h" | 27 #include "chrome/browser/extensions/extension_commands_global_registry.h" |
28 #include "chrome/browser/extensions/extension_service.h" | 28 #include "chrome/browser/extensions/extension_service.h" |
29 #include "chrome/browser/extensions/extension_tab_util.h" | 29 #include "chrome/browser/extensions/extension_tab_util.h" |
30 #include "chrome/browser/extensions/extension_ui_util.h" | 30 #include "chrome/browser/extensions/extension_ui_util.h" |
31 #include "chrome/browser/extensions/extension_util.h" | 31 #include "chrome/browser/extensions/extension_util.h" |
32 #include "chrome/browser/extensions/install_verifier.h" | 32 #include "chrome/browser/extensions/install_verifier.h" |
33 #include "chrome/browser/extensions/path_util.h" | 33 #include "chrome/browser/extensions/path_util.h" |
34 #include "chrome/browser/extensions/scripting_permissions_modifier.h" | 34 #include "chrome/browser/extensions/scripting_permissions_modifier.h" |
35 #include "chrome/browser/extensions/shared_module_service.h" | 35 #include "chrome/browser/extensions/shared_module_service.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 DeveloperPrivateAPI::DeveloperPrivateAPI(content::BrowserContext* context) | 236 DeveloperPrivateAPI::DeveloperPrivateAPI(content::BrowserContext* context) |
237 : profile_(Profile::FromBrowserContext(context)), weak_factory_(this) { | 237 : profile_(Profile::FromBrowserContext(context)), weak_factory_(this) { |
238 RegisterNotifications(); | 238 RegisterNotifications(); |
239 } | 239 } |
240 | 240 |
241 DeveloperPrivateEventRouter::DeveloperPrivateEventRouter(Profile* profile) | 241 DeveloperPrivateEventRouter::DeveloperPrivateEventRouter(Profile* profile) |
242 : extension_registry_observer_(this), | 242 : extension_registry_observer_(this), |
243 error_console_observer_(this), | 243 error_console_observer_(this), |
244 process_manager_observer_(this), | 244 process_manager_observer_(this), |
245 app_window_registry_observer_(this), | 245 app_window_registry_observer_(this), |
246 extension_action_api_observer_(this), | 246 extension_action_api_observer_(this), |
Dan Beam
2017/05/30 23:31:43
and this
Devlin
2017/05/31 18:04:53
Done.
| |
247 warning_service_observer_(this), | 247 warning_service_observer_(this), |
248 extension_prefs_observer_(this), | 248 extension_prefs_observer_(this), |
249 extension_management_observer_(this), | 249 extension_management_observer_(this), |
250 command_service_observer_(this), | 250 command_service_observer_(this), |
251 profile_(profile), | 251 profile_(profile), |
252 event_router_(EventRouter::Get(profile_)), | 252 event_router_(EventRouter::Get(profile_)), |
253 weak_factory_(this) { | 253 weak_factory_(this) { |
254 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); | 254 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); |
255 error_console_observer_.Add(ErrorConsole::Get(profile)); | 255 error_console_observer_.Add(ErrorConsole::Get(profile)); |
256 process_manager_observer_.Add(ProcessManager::Get(profile)); | 256 process_manager_observer_.Add(ProcessManager::Get(profile)); |
257 app_window_registry_observer_.Add(AppWindowRegistry::Get(profile)); | 257 app_window_registry_observer_.Add(AppWindowRegistry::Get(profile)); |
258 extension_action_api_observer_.Add(ExtensionActionAPI::Get(profile)); | 258 extension_action_api_observer_.Add(ExtensionActionAPI::Get(profile)); |
Dan Beam
2017/05/30 23:31:43
and this
Devlin
2017/05/31 18:04:53
Done.
| |
259 warning_service_observer_.Add(WarningService::Get(profile)); | 259 warning_service_observer_.Add(WarningService::Get(profile)); |
260 extension_prefs_observer_.Add(ExtensionPrefs::Get(profile)); | 260 extension_prefs_observer_.Add(ExtensionPrefs::Get(profile)); |
261 extension_management_observer_.Add( | 261 extension_management_observer_.Add( |
262 ExtensionManagementFactory::GetForBrowserContext(profile)); | 262 ExtensionManagementFactory::GetForBrowserContext(profile)); |
263 command_service_observer_.Add(CommandService::Get(profile)); | 263 command_service_observer_.Add(CommandService::Get(profile)); |
264 pref_change_registrar_.Init(profile->GetPrefs()); | 264 pref_change_registrar_.Init(profile->GetPrefs()); |
265 // The unretained is safe, since the PrefChangeRegistrar unregisters the | 265 // The unretained is safe, since the PrefChangeRegistrar unregisters the |
266 // callback on destruction. | 266 // callback on destruction. |
267 pref_change_registrar_.Add( | 267 pref_change_registrar_.Add( |
268 prefs::kExtensionsUIDeveloperMode, | 268 prefs::kExtensionsUIDeveloperMode, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 extension_id); | 364 extension_id); |
365 } | 365 } |
366 | 366 |
367 void DeveloperPrivateEventRouter::OnExtensionCommandRemoved( | 367 void DeveloperPrivateEventRouter::OnExtensionCommandRemoved( |
368 const std::string& extension_id, | 368 const std::string& extension_id, |
369 const Command& removed_command) { | 369 const Command& removed_command) { |
370 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, | 370 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, |
371 extension_id); | 371 extension_id); |
372 } | 372 } |
373 | 373 |
374 void DeveloperPrivateEventRouter::OnExtensionActionVisibilityChanged( | 374 void DeveloperPrivateEventRouter::OnExtensionActionVisibilityChanged( |
Dan Beam
2017/05/30 23:31:43
and this
Devlin
2017/05/31 18:04:53
Done.
| |
375 const std::string& extension_id, | 375 const std::string& extension_id, |
376 bool is_now_visible) { | 376 bool is_now_visible) { |
377 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); | 377 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); |
378 } | 378 } |
379 | 379 |
380 void DeveloperPrivateEventRouter::OnExtensionDisableReasonsChanged( | 380 void DeveloperPrivateEventRouter::OnExtensionDisableReasonsChanged( |
381 const std::string& extension_id, int disable_reasons) { | 381 const std::string& extension_id, int disable_reasons) { |
382 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); | 382 BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED, extension_id); |
383 } | 383 } |
384 | 384 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 if (update.run_on_all_urls) { | 714 if (update.run_on_all_urls) { |
715 ScriptingPermissionsModifier modifier(browser_context(), extension); | 715 ScriptingPermissionsModifier modifier(browser_context(), extension); |
716 if (!modifier.CanAffectExtension( | 716 if (!modifier.CanAffectExtension( |
717 extension->permissions_data()->active_permissions()) && | 717 extension->permissions_data()->active_permissions()) && |
718 !modifier.HasAffectedExtension()) { | 718 !modifier.HasAffectedExtension()) { |
719 return RespondNow( | 719 return RespondNow( |
720 Error("Cannot modify all urls of extension: " + extension->id())); | 720 Error("Cannot modify all urls of extension: " + extension->id())); |
721 } | 721 } |
722 modifier.SetAllowedOnAllUrls(*update.run_on_all_urls); | 722 modifier.SetAllowedOnAllUrls(*update.run_on_all_urls); |
723 } | 723 } |
724 if (update.show_action_button) { | |
725 ExtensionActionAPI::Get(browser_context())->SetBrowserActionVisibility( | |
726 extension->id(), | |
727 *update.show_action_button); | |
728 } | |
729 | 724 |
730 return RespondNow(NoArguments()); | 725 return RespondNow(NoArguments()); |
731 } | 726 } |
732 | 727 |
733 DeveloperPrivateReloadFunction::~DeveloperPrivateReloadFunction() {} | 728 DeveloperPrivateReloadFunction::~DeveloperPrivateReloadFunction() {} |
734 | 729 |
735 ExtensionFunction::ResponseAction DeveloperPrivateReloadFunction::Run() { | 730 ExtensionFunction::ResponseAction DeveloperPrivateReloadFunction::Run() { |
736 std::unique_ptr<Reload::Params> params(Reload::Params::Create(*args_)); | 731 std::unique_ptr<Reload::Params> params(Reload::Params::Create(*args_)); |
737 EXTENSION_FUNCTION_VALIDATE(params.get()); | 732 EXTENSION_FUNCTION_VALIDATE(params.get()); |
738 | 733 |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1576 update.extension_id, update.command_name, *update.keybinding); | 1571 update.extension_id, update.command_name, *update.keybinding); |
1577 } | 1572 } |
1578 | 1573 |
1579 return RespondNow(NoArguments()); | 1574 return RespondNow(NoArguments()); |
1580 } | 1575 } |
1581 | 1576 |
1582 | 1577 |
1583 } // namespace api | 1578 } // namespace api |
1584 | 1579 |
1585 } // namespace extensions | 1580 } // namespace extensions |
OLD | NEW |