| 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/extension_event_router.h" | 5 #include "chrome/browser/extensions/extension_event_router.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/extensions/extension_devtools_manager.h" | 10 #include "chrome/browser/extensions/extension_devtools_manager.h" |
| 11 #include "chrome/browser/extensions/extension_host.h" | 11 #include "chrome/browser/extensions/extension_host.h" |
| 12 #include "chrome/browser/extensions/extension_process_manager.h" | 12 #include "chrome/browser/extensions/extension_process_manager.h" |
| 13 #include "chrome/browser/extensions/extension_processes_api.h" | 13 #include "chrome/browser/extensions/extension_processes_api.h" |
| 14 #include "chrome/browser/extensions/extension_processes_api_constants.h" | 14 #include "chrome/browser/extensions/extension_processes_api_constants.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_system.h" |
| 17 #include "chrome/browser/extensions/extension_system_factory.h" |
| 16 #include "chrome/browser/extensions/extension_tabs_module.h" | 18 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 17 #include "chrome/browser/extensions/api/webrequest/webrequest_api.h" | 19 #include "chrome/browser/extensions/api/webrequest/webrequest_api.h" |
| 18 #include "chrome/browser/extensions/process_map.h" | 20 #include "chrome/browser/extensions/process_map.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/chrome_view_type.h" | 24 #include "chrome/common/chrome_view_type.h" |
| 23 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/common/extensions/extension_messages.h" | 26 #include "chrome/common/extensions/extension_messages.h" |
| 25 #include "chrome/common/extensions/api/extension_api.h" | 27 #include "chrome/common/extensions/api/extension_api.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 ListValue args; | 95 ListValue args; |
| 94 args.Set(0, Value::CreateStringValue(event_name)); | 96 args.Set(0, Value::CreateStringValue(event_name)); |
| 95 args.Set(1, Value::CreateStringValue(event_args)); | 97 args.Set(1, Value::CreateStringValue(event_args)); |
| 96 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL, | 98 ipc_sender->Send(new ExtensionMsg_MessageInvoke(MSG_ROUTING_CONTROL, |
| 97 extension_id, kDispatchEvent, args, event_url, | 99 extension_id, kDispatchEvent, args, event_url, |
| 98 user_gesture == USER_GESTURE_ENABLED)); | 100 user_gesture == USER_GESTURE_ENABLED)); |
| 99 } | 101 } |
| 100 | 102 |
| 101 ExtensionEventRouter::ExtensionEventRouter(Profile* profile) | 103 ExtensionEventRouter::ExtensionEventRouter(Profile* profile) |
| 102 : profile_(profile), | 104 : profile_(profile), |
| 103 extension_devtools_manager_(profile->GetExtensionDevToolsManager()) { | 105 extension_devtools_manager_( |
| 106 ExtensionSystemFactory::GetForProfile(profile)->devtools_manager()) { |
| 104 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 107 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 105 content::NotificationService::AllSources()); | 108 content::NotificationService::AllSources()); |
| 106 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 109 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 107 content::NotificationService::AllSources()); | 110 content::NotificationService::AllSources()); |
| 108 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 111 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 109 content::Source<Profile>(profile_)); | 112 content::Source<Profile>(profile_)); |
| 110 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 113 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 111 content::Source<Profile>(profile_)); | 114 content::Source<Profile>(profile_)); |
| 112 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 115 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 113 content::Source<Profile>(profile_)); | 116 content::Source<Profile>(profile_)); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 extension->id(), kOnInstalledEvent, "[]", NULL, GURL()); | 523 extension->id(), kOnInstalledEvent, "[]", NULL, GURL()); |
| 521 break; | 524 break; |
| 522 } | 525 } |
| 523 | 526 |
| 524 // TODO(tessamac): if background page crashed/failed clear queue. | 527 // TODO(tessamac): if background page crashed/failed clear queue. |
| 525 default: | 528 default: |
| 526 NOTREACHED(); | 529 NOTREACHED(); |
| 527 return; | 530 return; |
| 528 } | 531 } |
| 529 } | 532 } |
| OLD | NEW |