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

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: Latest master for cq 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); 270 const CommandLine& command_line = *(CommandLine::ForCurrentProcess());
271 is_extension_process_ = 271 is_extension_process_ =
272 command_line.HasSwitch(switches::kExtensionProcess) || 272 command_line.HasSwitch(switches::kExtensionProcess) ||
273 command_line.HasSwitch(switches::kSingleProcess); 273 command_line.HasSwitch(switches::kSingleProcess);
274 274
275 if (is_extension_process_) { 275 if (is_extension_process_) {
276 RenderThread::Get()->SetIdleNotificationDelayInMs( 276 RenderThread::Get()->SetIdleNotificationDelayInMs(
277 kInitialExtensionIdleHandlerDelayMs); 277 kInitialExtensionIdleHandlerDelayMs);
278 } 278 }
279 279
280 user_script_slave_.reset(new UserScriptSlave(&extensions_)); 280 user_script_slave_.reset(new extensions::UserScriptSlave(&extensions_));
281 request_sender_.reset(new ExtensionRequestSender(this, &v8_context_set_)); 281 request_sender_.reset(new ExtensionRequestSender(this, &v8_context_set_));
282 PopulateSourceMap(); 282 PopulateSourceMap();
283 PopulateLazyBindingsMap(); 283 PopulateLazyBindingsMap();
284 } 284 }
285 285
286 ExtensionDispatcher::~ExtensionDispatcher() { 286 ExtensionDispatcher::~ExtensionDispatcher() {
287 } 287 }
288 288
289 bool ExtensionDispatcher::OnControlMessageReceived( 289 bool ExtensionDispatcher::OnControlMessageReceived(
290 const IPC::Message& message) { 290 const IPC::Message& message) {
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 // "invalid". This isn't interesting. 686 // "invalid". This isn't interesting.
687 if (extension_id != "invalid") { 687 if (extension_id != "invalid") {
688 LOG(ERROR) << "Extension \"" << extension_id << "\" not found"; 688 LOG(ERROR) << "Extension \"" << extension_id << "\" not found";
689 RenderThread::Get()->RecordUserMetrics("ExtensionNotFound_ED"); 689 RenderThread::Get()->RecordUserMetrics("ExtensionNotFound_ED");
690 } 690 }
691 691
692 extension_id = ""; 692 extension_id = "";
693 } 693 }
694 694
695 ExtensionURLInfo url_info(frame->document().securityOrigin(), 695 ExtensionURLInfo url_info(frame->document().securityOrigin(),
696 UserScriptSlave::GetDataSourceURLForFrame(frame)); 696 extensions::UserScriptSlave::GetDataSourceURLForFrame(frame));
697 697
698 Feature::Context context_type = 698 Feature::Context context_type =
699 ClassifyJavaScriptContext(extension_id, extension_group, url_info); 699 ClassifyJavaScriptContext(extension_id, extension_group, url_info);
700 700
701 ChromeV8Context* context = 701 ChromeV8Context* context =
702 new ChromeV8Context(v8_context, frame, extension, context_type); 702 new ChromeV8Context(v8_context, frame, extension, context_type);
703 v8_context_set_.Add(context); 703 v8_context_set_.Add(context);
704 704
705 scoped_ptr<ModuleSystem> module_system(new ModuleSystem(v8_context, 705 scoped_ptr<ModuleSystem> module_system(new ModuleSystem(v8_context,
706 &source_map_)); 706 &source_map_));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 785 }
786 786
787 std::string ExtensionDispatcher::GetExtensionID(const WebFrame* frame, 787 std::string ExtensionDispatcher::GetExtensionID(const WebFrame* frame,
788 int world_id) { 788 int world_id) {
789 if (world_id != 0) { 789 if (world_id != 0) {
790 // Isolated worlds (content script). 790 // Isolated worlds (content script).
791 return user_script_slave_->GetExtensionIdForIsolatedWorld(world_id); 791 return user_script_slave_->GetExtensionIdForIsolatedWorld(world_id);
792 } 792 }
793 793
794 // Extension pages (chrome-extension:// URLs). 794 // Extension pages (chrome-extension:// URLs).
795 GURL frame_url = UserScriptSlave::GetDataSourceURLForFrame(frame); 795 GURL frame_url = extensions::UserScriptSlave::GetDataSourceURLForFrame(frame);
796 return extensions_.GetExtensionOrAppIDByURL( 796 return extensions_.GetExtensionOrAppIDByURL(
797 ExtensionURLInfo(frame->document().securityOrigin(), frame_url)); 797 ExtensionURLInfo(frame->document().securityOrigin(), frame_url));
798 } 798 }
799 799
800 bool ExtensionDispatcher::IsWithinPlatformApp(const WebFrame* frame) { 800 bool ExtensionDispatcher::IsWithinPlatformApp(const WebFrame* frame) {
801 const Extension* extension = 801 const Extension* extension =
802 extensions_.GetByID(GetExtensionID(frame->top(), 0)); 802 extensions_.GetByID(GetExtensionID(frame->top(), 0));
803 return extension && extension->is_platform_app(); 803 return extension && extension->is_platform_app();
804 } 804 }
805 805
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 v8::Exception::Error(v8::String::New(error_msg.c_str()))); 1057 v8::Exception::Error(v8::String::New(error_msg.c_str())));
1058 return false; 1058 return false;
1059 } 1059 }
1060 1060
1061 // We should never end up with sandboxed contexts trying to invoke extension 1061 // We should never end up with sandboxed contexts trying to invoke extension
1062 // APIs, they don't get extension bindings injected. If we end up here it 1062 // APIs, they don't get extension bindings injected. If we end up here it
1063 // means that a sandboxed page somehow managed to invoke an API anyway, so 1063 // means that a sandboxed page somehow managed to invoke an API anyway, so
1064 // we should abort. 1064 // we should abort.
1065 WebKit::WebFrame* frame = context->web_frame(); 1065 WebKit::WebFrame* frame = context->web_frame();
1066 ExtensionURLInfo url_info(frame->document().securityOrigin(), 1066 ExtensionURLInfo url_info(frame->document().securityOrigin(),
1067 UserScriptSlave::GetDataSourceURLForFrame(frame)); 1067 extensions::UserScriptSlave::GetDataSourceURLForFrame(frame));
1068 CHECK(!extensions_.IsSandboxedPage(url_info)); 1068 CHECK(!extensions_.IsSandboxedPage(url_info));
1069 1069
1070 return true; 1070 return true;
1071 } 1071 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_dispatcher.h ('k') | chrome/renderer/extensions/extension_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698