OLD | NEW |
1 // Copyright (c) 2011 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/app_bindings.h" | 5 #include "chrome/renderer/extensions/app_bindings.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 v8::ThrowException(v8::String::New(kInvalidCallbackIdError)); | 230 v8::ThrowException(v8::String::New(kInvalidCallbackIdError)); |
231 return v8::Undefined(); | 231 return v8::Undefined(); |
232 } | 232 } |
233 callback_id = args[1]->Int32Value(); | 233 callback_id = args[1]->Int32Value(); |
234 } | 234 } |
235 | 235 |
236 content::RenderView* render_view = context_->GetRenderView(); | 236 content::RenderView* render_view = context_->GetRenderView(); |
237 CHECK(render_view); | 237 CHECK(render_view); |
238 | 238 |
239 Send(new ExtensionHostMsg_GetAppNotifyChannel( | 239 Send(new ExtensionHostMsg_GetAppNotifyChannel( |
240 render_view->GetRoutingId(), context_->web_frame()->document().url(), | 240 render_view->GetRoutingID(), context_->web_frame()->document().url(), |
241 client_id, GetRoutingId(), callback_id)); | 241 client_id, GetRoutingID(), callback_id)); |
242 return v8::Undefined(); | 242 return v8::Undefined(); |
243 } | 243 } |
244 | 244 |
245 bool AppBindingsHandler::OnMessageReceived(const IPC::Message& message) { | 245 bool AppBindingsHandler::OnMessageReceived(const IPC::Message& message) { |
246 IPC_BEGIN_MESSAGE_MAP(AppBindingsHandler, message) | 246 IPC_BEGIN_MESSAGE_MAP(AppBindingsHandler, message) |
247 IPC_MESSAGE_HANDLER(ExtensionMsg_GetAppNotifyChannelResponse, | 247 IPC_MESSAGE_HANDLER(ExtensionMsg_GetAppNotifyChannelResponse, |
248 OnGetAppNotifyChannelResponse) | 248 OnGetAppNotifyChannelResponse) |
249 IPC_MESSAGE_UNHANDLED(CHECK(false) << "Unhandled IPC message") | 249 IPC_MESSAGE_UNHANDLED(CHECK(false) << "Unhandled IPC message") |
250 IPC_END_MESSAGE_MAP() | 250 IPC_END_MESSAGE_MAP() |
251 return true; | 251 return true; |
252 } | 252 } |
253 | 253 |
254 void AppBindingsHandler::OnGetAppNotifyChannelResponse( | 254 void AppBindingsHandler::OnGetAppNotifyChannelResponse( |
255 const std::string& channel_id, const std::string& error, int callback_id) { | 255 const std::string& channel_id, const std::string& error, int callback_id) { |
256 v8::HandleScope handle_scope; | 256 v8::HandleScope handle_scope; |
257 v8::Context::Scope context_scope(context_->v8_context()); | 257 v8::Context::Scope context_scope(context_->v8_context()); |
258 v8::Handle<v8::Value> argv[3]; | 258 v8::Handle<v8::Value> argv[3]; |
259 argv[0] = v8::String::New(channel_id.c_str()); | 259 argv[0] = v8::String::New(channel_id.c_str()); |
260 argv[1] = v8::String::New(error.c_str()); | 260 argv[1] = v8::String::New(error.c_str()); |
261 argv[2] = v8::Integer::New(callback_id); | 261 argv[2] = v8::Integer::New(callback_id); |
262 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse", | 262 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse", |
263 arraysize(argv), argv, NULL)); | 263 arraysize(argv), argv, NULL)); |
264 } | 264 } |
OLD | NEW |