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

Side by Side Diff: chrome/renderer/extensions/extension_dispatcher.cc

Issue 10696176: Move UserScript and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/extension_dispatcher.h" 5 #include "chrome/renderer/extensions/extension_dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); 271 const CommandLine& command_line = *(CommandLine::ForCurrentProcess());
272 is_extension_process_ = 272 is_extension_process_ =
273 command_line.HasSwitch(switches::kExtensionProcess) || 273 command_line.HasSwitch(switches::kExtensionProcess) ||
274 command_line.HasSwitch(switches::kSingleProcess); 274 command_line.HasSwitch(switches::kSingleProcess);
275 275
276 if (is_extension_process_) { 276 if (is_extension_process_) {
277 RenderThread::Get()->SetIdleNotificationDelayInMs( 277 RenderThread::Get()->SetIdleNotificationDelayInMs(
278 kInitialExtensionIdleHandlerDelayMs); 278 kInitialExtensionIdleHandlerDelayMs);
279 } 279 }
280 280
281 user_script_slave_.reset(new UserScriptSlave(&extensions_)); 281 user_script_slave_.reset(new extensions::UserScriptSlave(&extensions_));
282 request_sender_.reset(new ExtensionRequestSender(this, &v8_context_set_)); 282 request_sender_.reset(new ExtensionRequestSender(this, &v8_context_set_));
283 PopulateSourceMap(); 283 PopulateSourceMap();
284 PopulateLazyBindingsMap(); 284 PopulateLazyBindingsMap();
285 } 285 }
286 286
287 ExtensionDispatcher::~ExtensionDispatcher() { 287 ExtensionDispatcher::~ExtensionDispatcher() {
288 } 288 }
289 289
290 bool ExtensionDispatcher::OnControlMessageReceived( 290 bool ExtensionDispatcher::OnControlMessageReceived(
291 const IPC::Message& message) { 291 const IPC::Message& message) {
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 // "invalid". This isn't interesting. 687 // "invalid". This isn't interesting.
688 if (extension_id != "invalid") { 688 if (extension_id != "invalid") {
689 LOG(ERROR) << "Extension \"" << extension_id << "\" not found"; 689 LOG(ERROR) << "Extension \"" << extension_id << "\" not found";
690 RenderThread::Get()->RecordUserMetrics("ExtensionNotFound_ED"); 690 RenderThread::Get()->RecordUserMetrics("ExtensionNotFound_ED");
691 } 691 }
692 692
693 extension_id = ""; 693 extension_id = "";
694 } 694 }
695 695
696 ExtensionURLInfo url_info(frame->document().securityOrigin(), 696 ExtensionURLInfo url_info(frame->document().securityOrigin(),
697 UserScriptSlave::GetDataSourceURLForFrame(frame)); 697 extensions::UserScriptSlave::GetDataSourceURLForFrame(frame));
698 698
699 Feature::Context context_type = 699 Feature::Context context_type =
700 ClassifyJavaScriptContext(extension_id, extension_group, url_info); 700 ClassifyJavaScriptContext(extension_id, extension_group, url_info);
701 701
702 ChromeV8Context* context = 702 ChromeV8Context* context =
703 new ChromeV8Context(v8_context, frame, extension, context_type); 703 new ChromeV8Context(v8_context, frame, extension, context_type);
704 v8_context_set_.Add(context); 704 v8_context_set_.Add(context);
705 705
706 scoped_ptr<ModuleSystem> module_system(new ModuleSystem(v8_context, 706 scoped_ptr<ModuleSystem> module_system(new ModuleSystem(v8_context,
707 &source_map_)); 707 &source_map_));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 } 786 }
787 787
788 std::string ExtensionDispatcher::GetExtensionID(const WebFrame* frame, 788 std::string ExtensionDispatcher::GetExtensionID(const WebFrame* frame,
789 int world_id) { 789 int world_id) {
790 if (world_id != 0) { 790 if (world_id != 0) {
791 // Isolated worlds (content script). 791 // Isolated worlds (content script).
792 return user_script_slave_->GetExtensionIdForIsolatedWorld(world_id); 792 return user_script_slave_->GetExtensionIdForIsolatedWorld(world_id);
793 } 793 }
794 794
795 // Extension pages (chrome-extension:// URLs). 795 // Extension pages (chrome-extension:// URLs).
796 GURL frame_url = UserScriptSlave::GetDataSourceURLForFrame(frame); 796 GURL frame_url = extensions::UserScriptSlave::GetDataSourceURLForFrame(frame);
797 return extensions_.GetExtensionOrAppIDByURL( 797 return extensions_.GetExtensionOrAppIDByURL(
798 ExtensionURLInfo(frame->document().securityOrigin(), frame_url)); 798 ExtensionURLInfo(frame->document().securityOrigin(), frame_url));
799 } 799 }
800 800
801 bool ExtensionDispatcher::IsWithinPlatformApp(const WebFrame* frame) { 801 bool ExtensionDispatcher::IsWithinPlatformApp(const WebFrame* frame) {
802 const Extension* extension = 802 const Extension* extension =
803 extensions_.GetByID(GetExtensionID(frame->top(), 0)); 803 extensions_.GetByID(GetExtensionID(frame->top(), 0));
804 return extension && extension->is_platform_app(); 804 return extension && extension->is_platform_app();
805 } 805 }
806 806
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 v8::Exception::Error(v8::String::New(error_msg.c_str()))); 1058 v8::Exception::Error(v8::String::New(error_msg.c_str())));
1059 return false; 1059 return false;
1060 } 1060 }
1061 1061
1062 // We should never end up with sandboxed contexts trying to invoke extension 1062 // We should never end up with sandboxed contexts trying to invoke extension
1063 // APIs, they don't get extension bindings injected. If we end up here it 1063 // APIs, they don't get extension bindings injected. If we end up here it
1064 // means that a sandboxed page somehow managed to invoke an API anyway, so 1064 // means that a sandboxed page somehow managed to invoke an API anyway, so
1065 // we should abort. 1065 // we should abort.
1066 WebKit::WebFrame* frame = context->web_frame(); 1066 WebKit::WebFrame* frame = context->web_frame();
1067 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1067 ExtensionURLInfo url_info(frame->document().securityOrigin(),
1068 UserScriptSlave::GetDataSourceURLForFrame(frame)); 1068 extensions::UserScriptSlave::GetDataSourceURLForFrame(frame));
1069 CHECK(!extensions_.IsSandboxedPage(url_info)); 1069 CHECK(!extensions_.IsSandboxedPage(url_info));
1070 1070
1071 return true; 1071 return true;
1072 } 1072 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698