| 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/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" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const std::string& error, | 79 const std::string& error, |
| 80 int callback_id); | 80 int callback_id); |
| 81 | 81 |
| 82 ExtensionDispatcher* dispatcher_; | 82 ExtensionDispatcher* dispatcher_; |
| 83 DISALLOW_COPY_AND_ASSIGN(AppBindingsHandler); | 83 DISALLOW_COPY_AND_ASSIGN(AppBindingsHandler); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 } // namespace | 86 } // namespace |
| 87 | 87 |
| 88 | 88 |
| 89 AppBindings::AppBindings(ExtensionDispatcher* dispatcher) | 89 AppBindings::AppBindings( |
| 90 : ChromeV8Extension("extensions/app.js", IDR_APP_BINDINGS_JS, | 90 int dependency_count, |
| 91 dispatcher) { | 91 const char** dependencies, |
| 92 } | 92 ExtensionDispatcher* extension_dispatcher) |
| 93 : ChromeV8Extension( |
| 94 "extensions/app_custom_bindings.js", |
| 95 IDR_APP_CUSTOM_BINDINGS_JS, |
| 96 dependency_count, |
| 97 dependencies, |
| 98 extension_dispatcher) {} |
| 93 | 99 |
| 94 ChromeV8ExtensionHandler* AppBindings::CreateHandler( | 100 ChromeV8ExtensionHandler* AppBindings::CreateHandler( |
| 95 ChromeV8Context* context) { | 101 ChromeV8Context* context) { |
| 96 return new AppBindingsHandler(extension_dispatcher(), context); | 102 return new AppBindingsHandler(extension_dispatcher(), context); |
| 97 } | 103 } |
| 98 | 104 |
| 99 | |
| 100 | |
| 101 AppBindingsHandler::AppBindingsHandler(ExtensionDispatcher* dispatcher, | 105 AppBindingsHandler::AppBindingsHandler(ExtensionDispatcher* dispatcher, |
| 102 ChromeV8Context* context) | 106 ChromeV8Context* context) |
| 103 : ChromeV8ExtensionHandler(context), | 107 : ChromeV8ExtensionHandler(context), |
| 104 dispatcher_(dispatcher) { | 108 dispatcher_(dispatcher) { |
| 105 } | 109 } |
| 106 | 110 |
| 107 v8::Handle<v8::Value> AppBindingsHandler::HandleNativeFunction( | 111 v8::Handle<v8::Value> AppBindingsHandler::HandleNativeFunction( |
| 108 const std::string& name, const v8::Arguments& args) { | 112 const std::string& name, const v8::Arguments& args) { |
| 109 // TODO(aa): Create a helper map of callback that can be used in either | 113 // TODO(aa): Create a helper map of callback that can be used in either |
| 110 // extensions or handlers. | 114 // extensions or handlers. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 const std::string& channel_id, const std::string& error, int callback_id) { | 259 const std::string& channel_id, const std::string& error, int callback_id) { |
| 256 v8::HandleScope handle_scope; | 260 v8::HandleScope handle_scope; |
| 257 v8::Context::Scope context_scope(context_->v8_context()); | 261 v8::Context::Scope context_scope(context_->v8_context()); |
| 258 v8::Handle<v8::Value> argv[3]; | 262 v8::Handle<v8::Value> argv[3]; |
| 259 argv[0] = v8::String::New(channel_id.c_str()); | 263 argv[0] = v8::String::New(channel_id.c_str()); |
| 260 argv[1] = v8::String::New(error.c_str()); | 264 argv[1] = v8::String::New(error.c_str()); |
| 261 argv[2] = v8::Integer::New(callback_id); | 265 argv[2] = v8::Integer::New(callback_id); |
| 262 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse", | 266 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse", |
| 263 arraysize(argv), argv, NULL)); | 267 arraysize(argv), argv, NULL)); |
| 264 } | 268 } |
| OLD | NEW |