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

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: 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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids)); 1028 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids));
1028 } 1029 }
1029 1030
1030 void Dispatcher::OnUnloaded(const std::string& id) { 1031 void Dispatcher::OnUnloaded(const std::string& id) {
1031 extensions_.Remove(id); 1032 extensions_.Remove(id);
1032 active_extension_ids_.erase(id); 1033 active_extension_ids_.erase(id);
1033 1034
1034 // If the extension is later reloaded with a different set of permissions, 1035 // If the extension is later reloaded with a different set of permissions,
1035 // we'd like it to get a new isolated world ID, so that it can pick up the 1036 // we'd like it to get a new isolated world ID, so that it can pick up the
1036 // changed origin whitelist. 1037 // changed origin whitelist.
1037 ScriptInjection::RemoveIsolatedWorld(id); 1038 ScriptInjection::RemoveIsolatedWorld(HostID(HostID::EXTENSIONS, id));
1038 1039
1039 // Invalidate all of the contexts that were removed. 1040 // Invalidate all of the contexts that were removed.
1040 // TODO(kalman): add an invalidation observer interface to ScriptContext. 1041 // TODO(kalman): add an invalidation observer interface to ScriptContext.
1041 ScriptContextSet::ContextSet removed_contexts = 1042 ScriptContextSet::ContextSet removed_contexts =
1042 script_context_set_.OnExtensionUnloaded(id); 1043 script_context_set_.OnExtensionUnloaded(id);
1043 for (ScriptContextSet::ContextSet::iterator it = removed_contexts.begin(); 1044 for (ScriptContextSet::ContextSet::iterator it = removed_contexts.begin();
1044 it != removed_contexts.end(); 1045 it != removed_contexts.end();
1045 ++it) { 1046 ++it) {
1046 request_sender_->InvalidateSource(*it); 1047 request_sender_->InvalidateSource(*it);
1047 } 1048 }
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 return v8::Handle<v8::Object>(); 1542 return v8::Handle<v8::Object>();
1542 1543
1543 if (bind_name) 1544 if (bind_name)
1544 *bind_name = split.back(); 1545 *bind_name = split.back();
1545 1546
1546 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1547 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1547 : bind_object; 1548 : bind_object;
1548 } 1549 }
1549 1550
1550 } // namespace extensions 1551 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698