OLD | NEW |
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/request_sender.h" | 5 #include "extensions/renderer/request_sender.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "content/public/renderer/render_view.h" | 8 #include "content/public/renderer/render_view.h" |
9 #include "extensions/common/extension_messages.h" | 9 #include "extensions/common/extension_messages.h" |
10 #include "extensions/renderer/dispatcher.h" | 10 #include "extensions/renderer/dispatcher.h" |
11 #include "extensions/renderer/script_context.h" | 11 #include "extensions/renderer/script_context.h" |
12 #include "third_party/WebKit/public/web/WebDocument.h" | 12 #include "third_party/WebKit/public/web/WebDocument.h" |
13 #include "third_party/WebKit/public/web/WebFrame.h" | 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
14 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" | 14 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" |
15 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 15 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
16 #include "third_party/WebKit/public/web/WebUserGestureToken.h" | 16 #include "third_party/WebKit/public/web/WebUserGestureToken.h" |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 // Contains info relevant to a pending API request. | 20 // Contains info relevant to a pending API request. |
21 struct PendingRequest { | 21 struct PendingRequest { |
22 public: | 22 public: |
23 PendingRequest(const std::string& name, | 23 PendingRequest(const std::string& name, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 << "Unexpected function " << name | 90 << "Unexpected function " << name |
91 << ". Did you remember to register it with ExtensionFunctionRegistry?"; | 91 << ". Did you remember to register it with ExtensionFunctionRegistry?"; |
92 return; | 92 return; |
93 } | 93 } |
94 | 94 |
95 // TODO(koz): See if we can make this a CHECK. | 95 // TODO(koz): See if we can make this a CHECK. |
96 if (!dispatcher_->CheckContextAccessToExtensionAPI(name, context)) | 96 if (!dispatcher_->CheckContextAccessToExtensionAPI(name, context)) |
97 return; | 97 return; |
98 | 98 |
99 GURL source_url; | 99 GURL source_url; |
100 if (blink::WebFrame* webframe = context->web_frame()) | 100 if (blink::WebLocalFrame* webframe = context->web_frame()) |
101 source_url = webframe->document().url(); | 101 source_url = webframe->document().url(); |
102 | 102 |
103 InsertRequest(request_id, new PendingRequest(name, source, | 103 InsertRequest(request_id, new PendingRequest(name, source, |
104 blink::WebUserGestureIndicator::currentUserGestureToken())); | 104 blink::WebUserGestureIndicator::currentUserGestureToken())); |
105 | 105 |
106 ExtensionHostMsg_Request_Params params; | 106 ExtensionHostMsg_Request_Params params; |
107 params.name = name; | 107 params.name = name; |
108 params.arguments.Swap(value_args); | 108 params.arguments.Swap(value_args); |
109 params.extension_id = context->GetExtensionID(); | 109 params.extension_id = context->GetExtensionID(); |
110 params.source_url = source_url; | 110 params.source_url = source_url; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 for (PendingRequestMap::iterator it = pending_requests_.begin(); | 142 for (PendingRequestMap::iterator it = pending_requests_.begin(); |
143 it != pending_requests_.end();) { | 143 it != pending_requests_.end();) { |
144 if (it->second->source == source) | 144 if (it->second->source == source) |
145 pending_requests_.erase(it++); | 145 pending_requests_.erase(it++); |
146 else | 146 else |
147 ++it; | 147 ++it; |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 } // namespace extensions | 151 } // namespace extensions |
OLD | NEW |