| 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 "extensions/renderer/dispatcher.h" | 5 #include "extensions/renderer/dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 } // namespace | 175 } // namespace |
| 176 | 176 |
| 177 Dispatcher::Dispatcher(DispatcherDelegate* delegate) | 177 Dispatcher::Dispatcher(DispatcherDelegate* delegate) |
| 178 : delegate_(delegate), | 178 : delegate_(delegate), |
| 179 content_watcher_(new ContentWatcher()), | 179 content_watcher_(new ContentWatcher()), |
| 180 source_map_(&ResourceBundle::GetSharedInstance()), | 180 source_map_(&ResourceBundle::GetSharedInstance()), |
| 181 v8_schema_registry_(new V8SchemaRegistry), | 181 v8_schema_registry_(new V8SchemaRegistry), |
| 182 is_webkit_initialized_(false), | 182 is_webkit_initialized_(false), |
| 183 user_script_set_observer_(this) { | 183 user_script_set_manager_observer_(this) { |
| 184 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); | 184 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); |
| 185 is_extension_process_ = | 185 is_extension_process_ = |
| 186 command_line.HasSwitch(extensions::switches::kExtensionProcess) || | 186 command_line.HasSwitch(extensions::switches::kExtensionProcess) || |
| 187 command_line.HasSwitch(::switches::kSingleProcess); | 187 command_line.HasSwitch(::switches::kSingleProcess); |
| 188 | 188 |
| 189 if (is_extension_process_) { | 189 if (is_extension_process_) { |
| 190 RenderThread::Get()->SetIdleNotificationDelayInMs( | 190 RenderThread::Get()->SetIdleNotificationDelayInMs( |
| 191 kInitialExtensionIdleHandlerDelayMs); | 191 kInitialExtensionIdleHandlerDelayMs); |
| 192 } | 192 } |
| 193 | 193 |
| 194 RenderThread::Get()->RegisterExtension(SafeBuiltins::CreateV8Extension()); | 194 RenderThread::Get()->RegisterExtension(SafeBuiltins::CreateV8Extension()); |
| 195 | 195 |
| 196 user_script_set_.reset(new UserScriptSet(&extensions_)); | 196 user_script_set_manager_.reset(new UserScriptSetManager(&extensions_)); |
| 197 script_injection_manager_.reset( | 197 script_injection_manager_.reset( |
| 198 new ScriptInjectionManager(&extensions_, user_script_set_.get())); | 198 new ScriptInjectionManager(&extensions_, user_script_set_manager_.get())); |
| 199 user_script_set_observer_.Add(user_script_set_.get()); | 199 user_script_set_manager_observer_.Add(user_script_set_manager_.get()); |
| 200 request_sender_.reset(new RequestSender(this)); | 200 request_sender_.reset(new RequestSender(this)); |
| 201 PopulateSourceMap(); | 201 PopulateSourceMap(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 Dispatcher::~Dispatcher() { | 204 Dispatcher::~Dispatcher() { |
| 205 } | 205 } |
| 206 | 206 |
| 207 void Dispatcher::OnRenderViewCreated(content::RenderView* render_view) { | 207 void Dispatcher::OnRenderViewCreated(content::RenderView* render_view) { |
| 208 script_injection_manager_->OnRenderViewCreated(render_view); | 208 script_injection_manager_->OnRenderViewCreated(render_view); |
| 209 } | 209 } |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 } | 771 } |
| 772 | 772 |
| 773 void Dispatcher::OnUserScriptsUpdated( | 773 void Dispatcher::OnUserScriptsUpdated( |
| 774 const std::set<std::string>& changed_extensions, | 774 const std::set<std::string>& changed_extensions, |
| 775 const std::vector<UserScript*>& scripts) { | 775 const std::vector<UserScript*>& scripts) { |
| 776 UpdateActiveExtensions(); | 776 UpdateActiveExtensions(); |
| 777 } | 777 } |
| 778 | 778 |
| 779 void Dispatcher::UpdateActiveExtensions() { | 779 void Dispatcher::UpdateActiveExtensions() { |
| 780 std::set<std::string> active_extensions = active_extension_ids_; | 780 std::set<std::string> active_extensions = active_extension_ids_; |
| 781 user_script_set_->GetActiveExtensionIds(&active_extensions); | 781 user_script_set_manager_->GetAllActiveExtensionIds(&active_extensions); |
| 782 delegate_->OnActiveExtensionsUpdated(active_extensions); | 782 delegate_->OnActiveExtensionsUpdated(active_extensions); |
| 783 } | 783 } |
| 784 | 784 |
| 785 void Dispatcher::UpdateOriginPermissions(const Extension* extension) { | 785 void Dispatcher::UpdateOriginPermissions(const Extension* extension) { |
| 786 const URLPatternSet& hosts = | 786 const URLPatternSet& hosts = |
| 787 extension->permissions_data()->GetEffectiveHostPermissions(); | 787 extension->permissions_data()->GetEffectiveHostPermissions(); |
| 788 WebSecurityPolicy::resetOriginAccessWhitelists(); | 788 WebSecurityPolicy::resetOriginAccessWhitelists(); |
| 789 delegate_->InitOriginPermissions(extension, | 789 delegate_->InitOriginPermissions(extension, |
| 790 IsExtensionActive(extension->id())); | 790 IsExtensionActive(extension->id())); |
| 791 for (URLPatternSet::const_iterator iter = hosts.begin(); iter != hosts.end(); | 791 for (URLPatternSet::const_iterator iter = hosts.begin(); iter != hosts.end(); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 return v8::Handle<v8::Object>(); | 1208 return v8::Handle<v8::Object>(); |
| 1209 | 1209 |
| 1210 if (bind_name) | 1210 if (bind_name) |
| 1211 *bind_name = split.back(); | 1211 *bind_name = split.back(); |
| 1212 | 1212 |
| 1213 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) | 1213 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) |
| 1214 : bind_object; | 1214 : bind_object; |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 } // namespace extensions | 1217 } // namespace extensions |
| OLD | NEW |