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