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

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: Remove Host::IsEmpty() and move ExtensionConsumer to extensions/renderer. 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 return is_active; 227 return is_active;
228 } 228 }
229 229
230 const Extension* Dispatcher::GetExtensionFromFrameAndWorld( 230 const Extension* Dispatcher::GetExtensionFromFrameAndWorld(
231 const WebFrame* frame, 231 const WebFrame* frame,
232 int world_id, 232 int world_id,
233 bool use_effective_url) { 233 bool use_effective_url) {
234 std::string extension_id; 234 std::string extension_id;
235 if (world_id != 0) { 235 if (world_id != 0) {
236 // Isolated worlds (content script). 236 // Isolated worlds (content script).
237 extension_id = ScriptInjection::GetExtensionIdForIsolatedWorld(world_id); 237 extension_id =
238 ScriptInjection::GetHostIdForIsolatedWorld(world_id).id();
238 } else if (!frame->document().securityOrigin().isUnique()) { 239 } else if (!frame->document().securityOrigin().isUnique()) {
239 // TODO(kalman): Delete the above check. 240 // TODO(kalman): Delete the above check.
240 241
241 // Extension pages (chrome-extension:// URLs). 242 // Extension pages (chrome-extension:// URLs).
242 GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame); 243 GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame);
243 frame_url = ScriptContext::GetEffectiveDocumentURL( 244 frame_url = ScriptContext::GetEffectiveDocumentURL(
244 frame, frame_url, use_effective_url); 245 frame, frame_url, use_effective_url);
245 extension_id = extensions_.GetExtensionOrAppIDByURL(frame_url); 246 extension_id = extensions_.GetExtensionOrAppIDByURL(frame_url);
246 } 247 }
247 248
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids)); 1020 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids));
1020 } 1021 }
1021 1022
1022 void Dispatcher::OnUnloaded(const std::string& id) { 1023 void Dispatcher::OnUnloaded(const std::string& id) {
1023 extensions_.Remove(id); 1024 extensions_.Remove(id);
1024 active_extension_ids_.erase(id); 1025 active_extension_ids_.erase(id);
1025 1026
1026 // If the extension is later reloaded with a different set of permissions, 1027 // If the extension is later reloaded with a different set of permissions,
1027 // we'd like it to get a new isolated world ID, so that it can pick up the 1028 // we'd like it to get a new isolated world ID, so that it can pick up the
1028 // changed origin whitelist. 1029 // changed origin whitelist.
1029 ScriptInjection::RemoveIsolatedWorld(id); 1030 ScriptInjection::RemoveIsolatedWorld(HostID(HostID::EXTENSIONS, id));
1030 1031
1031 // Invalidate all of the contexts that were removed. 1032 // Invalidate all of the contexts that were removed.
1032 // TODO(kalman): add an invalidation observer interface to ScriptContext. 1033 // TODO(kalman): add an invalidation observer interface to ScriptContext.
1033 ScriptContextSet::ContextSet removed_contexts = 1034 ScriptContextSet::ContextSet removed_contexts =
1034 script_context_set_.OnExtensionUnloaded(id); 1035 script_context_set_.OnExtensionUnloaded(id);
1035 for (ScriptContextSet::ContextSet::iterator it = removed_contexts.begin(); 1036 for (ScriptContextSet::ContextSet::iterator it = removed_contexts.begin();
1036 it != removed_contexts.end(); 1037 it != removed_contexts.end();
1037 ++it) { 1038 ++it) {
1038 request_sender_->InvalidateSource(*it); 1039 request_sender_->InvalidateSource(*it);
1039 } 1040 }
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 return v8::Handle<v8::Object>(); 1479 return v8::Handle<v8::Object>();
1479 1480
1480 if (bind_name) 1481 if (bind_name)
1481 *bind_name = split.back(); 1482 *bind_name = split.back();
1482 1483
1483 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) 1484 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context))
1484 : bind_object; 1485 : bind_object;
1485 } 1486 }
1486 1487
1487 } // namespace extensions 1488 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698