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

Side by Side Diff: extensions/renderer/dispatcher.cc

Issue 404613006: Declarative content scripts: Renderer-side: per-extension shared memory regions (lazily loaded) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-add missing Disptacher::content_watcher_ initialization Created 6 years, 5 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
OLDNEW
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
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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 } 760 }
761 761
762 void Dispatcher::OnUserScriptsUpdated( 762 void Dispatcher::OnUserScriptsUpdated(
763 const std::set<std::string>& changed_extensions, 763 const std::set<std::string>& changed_extensions,
764 const std::vector<UserScript*>& scripts) { 764 const std::vector<UserScript*>& scripts) {
765 UpdateActiveExtensions(); 765 UpdateActiveExtensions();
766 } 766 }
767 767
768 void Dispatcher::UpdateActiveExtensions() { 768 void Dispatcher::UpdateActiveExtensions() {
769 std::set<std::string> active_extensions = active_extension_ids_; 769 std::set<std::string> active_extensions = active_extension_ids_;
770 user_script_set_->GetActiveExtensionIds(&active_extensions); 770 user_script_set_manager_->GetAllActiveExtensionIds(&active_extensions);
771 delegate_->OnActiveExtensionsUpdated(active_extensions); 771 delegate_->OnActiveExtensionsUpdated(active_extensions);
772 } 772 }
773 773
774 void Dispatcher::UpdateOriginPermissions(const Extension* extension) { 774 void Dispatcher::UpdateOriginPermissions(const Extension* extension) {
775 const URLPatternSet& hosts = 775 const URLPatternSet& hosts =
776 extension->permissions_data()->GetEffectiveHostPermissions(); 776 extension->permissions_data()->GetEffectiveHostPermissions();
777 WebSecurityPolicy::resetOriginAccessWhitelists(); 777 WebSecurityPolicy::resetOriginAccessWhitelists();
778 delegate_->InitOriginPermissions(extension, 778 delegate_->InitOriginPermissions(extension,
779 IsExtensionActive(extension->id())); 779 IsExtensionActive(extension->id()));
780 for (URLPatternSet::const_iterator iter = hosts.begin(); iter != hosts.end(); 780 for (URLPatternSet::const_iterator iter = hosts.begin(); iter != hosts.end();
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 return v8::Handle<v8::Object>(); 1197 return v8::Handle<v8::Object>();
1198 1198
1199 if (bind_name) 1199 if (bind_name)
1200 *bind_name = split.back(); 1200 *bind_name = split.back();
1201 1201
1202 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1202 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1203 : bind_object; 1203 : bind_object;
1204 } 1204 }
1205 1205
1206 } // namespace extensions 1206 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698