OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/schema_generated_bindings.h" | 5 #include "chrome/renderer/extensions/schema_generated_bindings.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 27 matching lines...) Expand all Loading... | |
38 #include "chrome/renderer/extensions/extension_helper.h" | 38 #include "chrome/renderer/extensions/extension_helper.h" |
39 #include "chrome/renderer/extensions/miscellaneous_bindings.h" | 39 #include "chrome/renderer/extensions/miscellaneous_bindings.h" |
40 #include "chrome/renderer/extensions/user_script_slave.h" | 40 #include "chrome/renderer/extensions/user_script_slave.h" |
41 #include "content/public/renderer/render_view.h" | 41 #include "content/public/renderer/render_view.h" |
42 #include "content/public/renderer/v8_value_converter.h" | 42 #include "content/public/renderer/v8_value_converter.h" |
43 #include "grit/common_resources.h" | 43 #include "grit/common_resources.h" |
44 #include "grit/renderer_resources.h" | 44 #include "grit/renderer_resources.h" |
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBlob.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBlob.h" |
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | |
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
49 #include "third_party/skia/include/core/SkBitmap.h" | 50 #include "third_party/skia/include/core/SkBitmap.h" |
50 #include "third_party/skia/include/core/SkColor.h" | 51 #include "third_party/skia/include/core/SkColor.h" |
51 #include "ui/base/resource/resource_bundle.h" | 52 #include "ui/base/resource/resource_bundle.h" |
52 #include "v8/include/v8.h" | 53 #include "v8/include/v8.h" |
53 #include "webkit/glue/webkit_glue.h" | 54 #include "webkit/glue/webkit_glue.h" |
54 | 55 |
55 using content::V8ValueConverter; | 56 using content::V8ValueConverter; |
56 using extensions::ExtensionAPI; | 57 using extensions::ExtensionAPI; |
57 using WebKit::WebFrame; | 58 using WebKit::WebFrame; |
59 using WebKit::WebSecurityOrigin; | |
58 using WebKit::WebView; | 60 using WebKit::WebView; |
59 | 61 |
60 namespace { | 62 namespace { |
61 | 63 |
62 const char* kExtensionDeps[] = { | 64 const char* kExtensionDeps[] = { |
63 "extensions/event.js", | 65 "extensions/event.js", |
64 "extensions/json_schema.js", | 66 "extensions/json_schema.js", |
65 "extensions/miscellaneous_bindings.js", | 67 "extensions/miscellaneous_bindings.js", |
66 "extensions/apitest.js" | 68 "extensions/apitest.js" |
67 }; | 69 }; |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 v8_extension->extension_dispatcher_->function_names(); | 496 v8_extension->extension_dispatcher_->function_names(); |
495 if (function_names.find(name) == function_names.end()) { | 497 if (function_names.find(name) == function_names.end()) { |
496 NOTREACHED() << "Unexpected function " << name; | 498 NOTREACHED() << "Unexpected function " << name; |
497 return v8::Undefined(); | 499 return v8::Undefined(); |
498 } | 500 } |
499 | 501 |
500 if (!v8_extension->CheckCurrentContextAccessToExtensionAPI(name)) | 502 if (!v8_extension->CheckCurrentContextAccessToExtensionAPI(name)) |
501 return v8::Undefined(); | 503 return v8::Undefined(); |
502 | 504 |
503 GURL source_url; | 505 GURL source_url; |
506 WebSecurityOrigin origin; | |
504 WebFrame* webframe = current_context->web_frame(); | 507 WebFrame* webframe = current_context->web_frame(); |
505 if (webframe) | 508 if (webframe) { |
506 source_url = webframe->document().url(); | 509 source_url = webframe->document().url(); |
510 origin = webframe->document().securityOrigin(); | |
511 } | |
507 | 512 |
508 int request_id = args[2]->Int32Value(); | 513 int request_id = args[2]->Int32Value(); |
509 bool has_callback = args[3]->BooleanValue(); | 514 bool has_callback = args[3]->BooleanValue(); |
510 bool for_io_thread = args[4]->BooleanValue(); | 515 bool for_io_thread = args[4]->BooleanValue(); |
511 | 516 |
512 v8::Persistent<v8::Context> v8_context = | 517 v8::Persistent<v8::Context> v8_context = |
513 v8::Persistent<v8::Context>::New(v8::Context::GetCurrent()); | 518 v8::Persistent<v8::Context>::New(v8::Context::GetCurrent()); |
514 DCHECK(!v8_context.IsEmpty()); | 519 DCHECK(!v8_context.IsEmpty()); |
515 g_pending_requests.Get()[request_id].reset(new PendingRequest( | 520 g_pending_requests.Get()[request_id].reset(new PendingRequest( |
516 v8_context, name, current_context->extension_id())); | 521 v8_context, name, current_context->extension_id())); |
517 | 522 |
518 ExtensionHostMsg_Request_Params params; | 523 ExtensionHostMsg_Request_Params params; |
519 params.name = name; | 524 params.name = name; |
520 params.arguments.Swap(value_args); | 525 params.arguments.Swap(value_args); |
521 params.extension_id = current_context->extension_id(); | 526 params.extension_id = current_context->extension_id(); |
522 params.source_url = source_url; | 527 params.source_url = source_url; |
528 params.origin = origin.toString(); | |
Aaron Boodman
2011/12/09 16:05:20
Can you call this source_origin for clarity?
Yoyo Zhou
2011/12/09 19:59:09
Done.
| |
523 params.request_id = request_id; | 529 params.request_id = request_id; |
524 params.has_callback = has_callback; | 530 params.has_callback = has_callback; |
525 params.user_gesture = | 531 params.user_gesture = |
526 webframe ? webframe->isProcessingUserGesture() : false; | 532 webframe ? webframe->isProcessingUserGesture() : false; |
527 if (for_io_thread) { | 533 if (for_io_thread) { |
528 renderview->Send(new ExtensionHostMsg_RequestForIOThread( | 534 renderview->Send(new ExtensionHostMsg_RequestForIOThread( |
529 renderview->GetRoutingId(), params)); | 535 renderview->GetRoutingId(), params)); |
530 } else { | 536 } else { |
531 renderview->Send(new ExtensionHostMsg_Request( | 537 renderview->Send(new ExtensionHostMsg_Request( |
532 renderview->GetRoutingId(), params)); | 538 renderview->GetRoutingId(), params)); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 const std::string& extension_id) { | 709 const std::string& extension_id) { |
704 for (PendingRequestMap::const_iterator it = g_pending_requests.Get().begin(); | 710 for (PendingRequestMap::const_iterator it = g_pending_requests.Get().begin(); |
705 it != g_pending_requests.Get().end(); ++it) { | 711 it != g_pending_requests.Get().end(); ++it) { |
706 if (it->second->extension_id == extension_id) | 712 if (it->second->extension_id == extension_id) |
707 return true; | 713 return true; |
708 } | 714 } |
709 return false; | 715 return false; |
710 } | 716 } |
711 | 717 |
712 } // namespace | 718 } // namespace |
OLD | NEW |