| OLD | NEW |
| 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/dispatcher.h" | 5 #include "chrome/renderer/extensions/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 Loading... |
| 270 } | 270 } |
| 271 | 271 |
| 272 private: | 272 private: |
| 273 std::string ToStringOrDefault(const v8::Handle<v8::String>& v8_string, | 273 std::string ToStringOrDefault(const v8::Handle<v8::String>& v8_string, |
| 274 const std::string& dflt) { | 274 const std::string& dflt) { |
| 275 if (v8_string.IsEmpty()) | 275 if (v8_string.IsEmpty()) |
| 276 return dflt; | 276 return dflt; |
| 277 std::string ascii_value = *v8::String::AsciiValue(v8_string); | 277 std::string ascii_value = *v8::String::AsciiValue(v8_string); |
| 278 return ascii_value.empty() ? dflt : ascii_value; | 278 return ascii_value.empty() ? dflt : ascii_value; |
| 279 } | 279 } |
| 280 | |
| 281 }; | 280 }; |
| 282 | 281 |
| 283 void InstallAppBindings(ModuleSystem* module_system, | 282 void InstallAppBindings(ModuleSystem* module_system, |
| 284 v8::Handle<v8::Object> chrome, | 283 v8::Handle<v8::Object> chrome, |
| 285 v8::Handle<v8::Object> chrome_hidden) { | 284 v8::Handle<v8::Object> chrome_hidden) { |
| 286 module_system->SetLazyField(chrome, "app", "app", "chromeApp"); | 285 module_system->SetLazyField(chrome, "app", "app", "chromeApp"); |
| 287 module_system->SetLazyField(chrome, "appNotifications", "app", | 286 module_system->SetLazyField(chrome, "appNotifications", "app", |
| 288 "chromeAppNotifications"); | 287 "chromeAppNotifications"); |
| 289 module_system->SetLazyField(chrome_hidden, "app", "app", | 288 module_system->SetLazyField(chrome_hidden, "app", "app", |
| 290 "chromeHiddenApp"); | 289 "chromeHiddenApp"); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 namespace { | 533 namespace { |
| 535 | 534 |
| 536 // This is what the extension_group variable will be when DidCreateScriptContext | 535 // This is what the extension_group variable will be when DidCreateScriptContext |
| 537 // is called. We know because it's the same as what AllowScriptExtension gets | 536 // is called. We know because it's the same as what AllowScriptExtension gets |
| 538 // passed, and the two functions are called sequentially from WebKit. | 537 // passed, and the two functions are called sequentially from WebKit. |
| 539 // | 538 // |
| 540 // TODO(koz): Plumb extension_group through to AllowScriptExtension() from | 539 // TODO(koz): Plumb extension_group through to AllowScriptExtension() from |
| 541 // WebKit. | 540 // WebKit. |
| 542 static int g_hack_extension_group = 0; | 541 static int g_hack_extension_group = 0; |
| 543 | 542 |
| 544 } | 543 } // namespace |
| 545 | 544 |
| 546 bool Dispatcher::AllowScriptExtension(WebFrame* frame, | 545 bool Dispatcher::AllowScriptExtension(WebFrame* frame, |
| 547 const std::string& v8_extension_name, | 546 const std::string& v8_extension_name, |
| 548 int extension_group, | 547 int extension_group, |
| 549 int world_id) { | 548 int world_id) { |
| 550 g_hack_extension_group = extension_group; | 549 g_hack_extension_group = extension_group; |
| 551 return true; | 550 return true; |
| 552 } | 551 } |
| 553 | 552 |
| 554 void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system, | 553 void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 source_map_.RegisterSource("omnibox", IDR_OMNIBOX_CUSTOM_BINDINGS_JS); | 657 source_map_.RegisterSource("omnibox", IDR_OMNIBOX_CUSTOM_BINDINGS_JS); |
| 659 source_map_.RegisterSource("pageActions", | 658 source_map_.RegisterSource("pageActions", |
| 660 IDR_PAGE_ACTIONS_CUSTOM_BINDINGS_JS); | 659 IDR_PAGE_ACTIONS_CUSTOM_BINDINGS_JS); |
| 661 source_map_.RegisterSource("pageAction", IDR_PAGE_ACTION_CUSTOM_BINDINGS_JS); | 660 source_map_.RegisterSource("pageAction", IDR_PAGE_ACTION_CUSTOM_BINDINGS_JS); |
| 662 source_map_.RegisterSource("pageCapture", | 661 source_map_.RegisterSource("pageCapture", |
| 663 IDR_PAGE_CAPTURE_CUSTOM_BINDINGS_JS); | 662 IDR_PAGE_CAPTURE_CUSTOM_BINDINGS_JS); |
| 664 source_map_.RegisterSource("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS); | 663 source_map_.RegisterSource("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS); |
| 665 source_map_.RegisterSource("storage", IDR_STORAGE_CUSTOM_BINDINGS_JS); | 664 source_map_.RegisterSource("storage", IDR_STORAGE_CUSTOM_BINDINGS_JS); |
| 666 source_map_.RegisterSource("syncFileSystem", | 665 source_map_.RegisterSource("syncFileSystem", |
| 667 IDR_SYNC_FILE_SYSTEM_CUSTOM_BINDINGS_JS); | 666 IDR_SYNC_FILE_SYSTEM_CUSTOM_BINDINGS_JS); |
| 667 source_map_.RegisterSource("systemIndicator", |
| 668 IDR_SYSTEM_INDICATOR_CUSTOM_BINDINGS_JS); |
| 668 source_map_.RegisterSource("tabCapture", IDR_TAB_CAPTURE_CUSTOM_BINDINGS_JS); | 669 source_map_.RegisterSource("tabCapture", IDR_TAB_CAPTURE_CUSTOM_BINDINGS_JS); |
| 669 source_map_.RegisterSource("tabs", IDR_TABS_CUSTOM_BINDINGS_JS); | 670 source_map_.RegisterSource("tabs", IDR_TABS_CUSTOM_BINDINGS_JS); |
| 670 source_map_.RegisterSource("tts", IDR_TTS_CUSTOM_BINDINGS_JS); | 671 source_map_.RegisterSource("tts", IDR_TTS_CUSTOM_BINDINGS_JS); |
| 671 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS); | 672 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS); |
| 672 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS); | 673 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS); |
| 673 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS); | 674 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS); |
| 674 source_map_.RegisterSource("webRequestInternal", | 675 source_map_.RegisterSource("webRequestInternal", |
| 675 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); | 676 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); |
| 676 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); | 677 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); |
| 677 | 678 |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 // we should abort. | 1119 // we should abort. |
| 1119 WebKit::WebFrame* frame = context->web_frame(); | 1120 WebKit::WebFrame* frame = context->web_frame(); |
| 1120 ExtensionURLInfo url_info(frame->document().securityOrigin(), | 1121 ExtensionURLInfo url_info(frame->document().securityOrigin(), |
| 1121 UserScriptSlave::GetDataSourceURLForFrame(frame)); | 1122 UserScriptSlave::GetDataSourceURLForFrame(frame)); |
| 1122 CHECK(!extensions_.IsSandboxedPage(url_info)); | 1123 CHECK(!extensions_.IsSandboxedPage(url_info)); |
| 1123 | 1124 |
| 1124 return true; | 1125 return true; |
| 1125 } | 1126 } |
| 1126 | 1127 |
| 1127 } // namespace extensions | 1128 } // namespace extensions |
| OLD | NEW |