OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/speech/extension_api/tts_engine_extension_observer.h" | 5 #include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/profiler/scoped_profile.h" | |
10 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_system_factory.h" | 10 #include "chrome/browser/extensions/extension_system_factory.h" |
12 #include "chrome/browser/profiles/incognito_helpers.h" | 11 #include "chrome/browser/profiles/incognito_helpers.h" |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" | 13 #include "chrome/browser/speech/extension_api/tts_engine_extension_api.h" |
15 #include "chrome/browser/speech/tts_controller.h" | 14 #include "chrome/browser/speech/tts_controller.h" |
16 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 15 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
17 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 16 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
18 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
19 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 event_router->ExtensionHasEventListener(extension_id, | 107 event_router->ExtensionHasEventListener(extension_id, |
109 tts_engine_events::kOnStop)) { | 108 tts_engine_events::kOnStop)) { |
110 return true; | 109 return true; |
111 } | 110 } |
112 | 111 |
113 return false; | 112 return false; |
114 } | 113 } |
115 | 114 |
116 void TtsEngineExtensionObserver::OnListenerAdded( | 115 void TtsEngineExtensionObserver::OnListenerAdded( |
117 const extensions::EventListenerInfo& details) { | 116 const extensions::EventListenerInfo& details) { |
118 // TODO(vadimt): Remove ScopedProfile below once crbug.com/417106 is fixed. | |
119 tracked_objects::ScopedProfile tracking_profile( | |
120 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
121 "TtsEngineExtensionObserver::OnListenerAdded")); | |
122 | |
123 if (!IsLoadedTtsEngine(details.extension_id)) | 117 if (!IsLoadedTtsEngine(details.extension_id)) |
124 return; | 118 return; |
125 | 119 |
126 TtsController::GetInstance()->VoicesChanged(); | 120 TtsController::GetInstance()->VoicesChanged(); |
127 engine_extension_ids_.insert(details.extension_id); | 121 engine_extension_ids_.insert(details.extension_id); |
128 } | 122 } |
129 | 123 |
130 void TtsEngineExtensionObserver::OnExtensionUnloaded( | 124 void TtsEngineExtensionObserver::OnExtensionUnloaded( |
131 content::BrowserContext* browser_context, | 125 content::BrowserContext* browser_context, |
132 const extensions::Extension* extension, | 126 const extensions::Extension* extension, |
133 extensions::UnloadedExtensionInfo::Reason reason) { | 127 extensions::UnloadedExtensionInfo::Reason reason) { |
134 if (engine_extension_ids_.find(extension->id()) != | 128 if (engine_extension_ids_.find(extension->id()) != |
135 engine_extension_ids_.end()) { | 129 engine_extension_ids_.end()) { |
136 engine_extension_ids_.erase(extension->id()); | 130 engine_extension_ids_.erase(extension->id()); |
137 TtsController::GetInstance()->VoicesChanged(); | 131 TtsController::GetInstance()->VoicesChanged(); |
138 } | 132 } |
139 } | 133 } |
OLD | NEW |