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 "content/renderer/intents_dispatcher.h" | 5 #include "content/renderer/intents_dispatcher.h" |
6 | 6 |
7 #include "base/command_line.h" | |
7 #include "content/common/intents_messages.h" | 8 #include "content/common/intents_messages.h" |
9 #include "content/public/common/content_switches.h" | |
8 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
9 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa lue.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa lue.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | |
14 #include "v8/include/v8.h" | 17 #include "v8/include/v8.h" |
15 #include "webkit/glue/cpp_bound_class.h" | 18 #include "webkit/glue/cpp_bound_class.h" |
16 | 19 |
17 using WebKit::WebCString; | 20 using WebKit::WebCString; |
18 using WebKit::WebString; | 21 using WebKit::WebString; |
19 | 22 |
20 // This class encapsulates the API the Intent object will expose to Javascript. | 23 // This class encapsulates the API the Intent object will expose to Javascript. |
21 // It is made available to the Javascript runtime in the service page using | 24 // It is made available to the Javascript runtime in the service page using |
22 // NPAPI methods as with plugin/Javascript interaction objects and other | 25 // NPAPI methods as with plugin/Javascript interaction objects and other |
23 // browser-provided Javascript API objects on |window|. | 26 // browser-provided Javascript API objects on |window|. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 int intent_id) { | 143 int intent_id) { |
141 intent_.reset(new webkit_glue::WebIntentData(intent)); | 144 intent_.reset(new webkit_glue::WebIntentData(intent)); |
142 intent_id_ = intent_id; | 145 intent_id_ = intent_id; |
143 } | 146 } |
144 | 147 |
145 void IntentsDispatcher::OnWebIntentReply( | 148 void IntentsDispatcher::OnWebIntentReply( |
146 webkit_glue::WebIntentReplyType reply_type, | 149 webkit_glue::WebIntentReplyType reply_type, |
147 const WebKit::WebString& data, | 150 const WebKit::WebString& data, |
148 int intent_id) { | 151 int intent_id) { |
149 LOG(INFO) << "RenderView got reply to intent type " << reply_type; | 152 LOG(INFO) << "RenderView got reply to intent type " << reply_type; |
153 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) | |
James Hawkins
2011/11/23 21:23:18
Eh, just leave this out. We'll enable it soon eno
Greg Billock
2011/11/23 22:29:48
Done.
| |
154 NOTREACHED(); | |
155 | |
156 if (reply_type == webkit_glue::WEB_INTENT_REPLY_SUCCESS) { | |
157 render_view()->GetWebView()->mainFrame()->handleIntentResult( | |
158 intent_id, data); | |
159 } else { | |
160 render_view()->GetWebView()->mainFrame()->handleIntentFailure( | |
161 intent_id, data); | |
162 } | |
150 } | 163 } |
151 | 164 |
152 void IntentsDispatcher::OnResult(const WebKit::WebString& data) { | 165 void IntentsDispatcher::OnResult(const WebKit::WebString& data) { |
153 Send(new IntentsMsg_WebIntentReply( | 166 Send(new IntentsMsg_WebIntentReply( |
154 routing_id(), | 167 routing_id(), |
155 webkit_glue::WEB_INTENT_REPLY_SUCCESS, | 168 webkit_glue::WEB_INTENT_REPLY_SUCCESS, |
156 data, | 169 data, |
157 intent_id_)); | 170 intent_id_)); |
158 } | 171 } |
159 | 172 |
(...skipping 10 matching lines...) Expand all Loading... | |
170 // sub-frames. TODO(gbillock): This policy needs to be fine-tuned and | 183 // sub-frames. TODO(gbillock): This policy needs to be fine-tuned and |
171 // documented. | 184 // documented. |
172 void IntentsDispatcher::DidClearWindowObject(WebKit::WebFrame* frame) { | 185 void IntentsDispatcher::DidClearWindowObject(WebKit::WebFrame* frame) { |
173 if (intent_.get() == NULL || frame->top() != frame) | 186 if (intent_.get() == NULL || frame->top() != frame) |
174 return; | 187 return; |
175 | 188 |
176 delivered_intent_.reset(new BoundDeliveredIntent( | 189 delivered_intent_.reset(new BoundDeliveredIntent( |
177 intent_->action, intent_->type, intent_->data, this, frame)); | 190 intent_->action, intent_->type, intent_->data, this, frame)); |
178 delivered_intent_->BindToJavascript(frame, "intent"); | 191 delivered_intent_->BindToJavascript(frame, "intent"); |
179 } | 192 } |
OLD | NEW |