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

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

Issue 885493007: Refactoring: de-couple Extensions from "script injection System" [render side] : 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Devlin's comments. Created 5 years, 10 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return is_active; 228 return is_active;
229 } 229 }
230 230
231 const Extension* Dispatcher::GetExtensionFromFrameAndWorld( 231 const Extension* Dispatcher::GetExtensionFromFrameAndWorld(
232 const WebFrame* frame, 232 const WebFrame* frame,
233 int world_id, 233 int world_id,
234 bool use_effective_url) { 234 bool use_effective_url) {
235 std::string extension_id; 235 std::string extension_id;
236 if (world_id != 0) { 236 if (world_id != 0) {
237 // Isolated worlds (content script). 237 // Isolated worlds (content script).
238 extension_id = ScriptInjection::GetExtensionIdForIsolatedWorld(world_id); 238 extension_id =
239 ScriptInjection::GetHostIdForIsolatedWorld(world_id).id();
239 } else if (!frame->document().securityOrigin().isUnique()) { 240 } else if (!frame->document().securityOrigin().isUnique()) {
240 // TODO(kalman): Delete the above check. 241 // TODO(kalman): Delete the above check.
241 242
242 // Extension pages (chrome-extension:// URLs). 243 // Extension pages (chrome-extension:// URLs).
243 GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame); 244 GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame);
244 frame_url = ScriptContext::GetEffectiveDocumentURL( 245 frame_url = ScriptContext::GetEffectiveDocumentURL(
245 frame, frame_url, use_effective_url); 246 frame, frame_url, use_effective_url);
246 extension_id = extensions_.GetExtensionOrAppIDByURL(frame_url); 247 extension_id = extensions_.GetExtensionOrAppIDByURL(frame_url);
247 } 248 }
248 249
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids)); 1025 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids));
1025 } 1026 }
1026 1027
1027 void Dispatcher::OnUnloaded(const std::string& id) { 1028 void Dispatcher::OnUnloaded(const std::string& id) {
1028 extensions_.Remove(id); 1029 extensions_.Remove(id);
1029 active_extension_ids_.erase(id); 1030 active_extension_ids_.erase(id);
1030 1031
1031 // If the extension is later reloaded with a different set of permissions, 1032 // If the extension is later reloaded with a different set of permissions,
1032 // we'd like it to get a new isolated world ID, so that it can pick up the 1033 // we'd like it to get a new isolated world ID, so that it can pick up the
1033 // changed origin whitelist. 1034 // changed origin whitelist.
1034 ScriptInjection::RemoveIsolatedWorld(id); 1035 ScriptInjection::RemoveIsolatedWorld(HostID(HostID::EXTENSIONS, id));
1035 1036
1036 // Invalidate all of the contexts that were removed. 1037 // Invalidate all of the contexts that were removed.
1037 // TODO(kalman): add an invalidation observer interface to ScriptContext. 1038 // TODO(kalman): add an invalidation observer interface to ScriptContext.
1038 ScriptContextSet::ContextSet removed_contexts = 1039 ScriptContextSet::ContextSet removed_contexts =
1039 script_context_set_.OnExtensionUnloaded(id); 1040 script_context_set_.OnExtensionUnloaded(id);
1040 for (ScriptContextSet::ContextSet::iterator it = removed_contexts.begin(); 1041 for (ScriptContextSet::ContextSet::iterator it = removed_contexts.begin();
1041 it != removed_contexts.end(); 1042 it != removed_contexts.end();
1042 ++it) { 1043 ++it) {
1043 request_sender_->InvalidateSource(*it); 1044 request_sender_->InvalidateSource(*it);
1044 } 1045 }
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 return v8::Handle<v8::Object>(); 1539 return v8::Handle<v8::Object>();
1539 1540
1540 if (bind_name) 1541 if (bind_name)
1541 *bind_name = split.back(); 1542 *bind_name = split.back();
1542 1543
1543 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1544 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1544 : bind_object; 1545 : bind_object;
1545 } 1546 }
1546 1547
1547 } // namespace extensions 1548 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698