| OLD | NEW |
| 1 // Copyright (c) 2012 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" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 RouteFunction("GetDetails", | 66 RouteFunction("GetDetails", |
| 67 base::Bind(&AppBindings::GetDetails, base::Unretained(this))); | 67 base::Bind(&AppBindings::GetDetails, base::Unretained(this))); |
| 68 RouteFunction("GetDetailsForFrame", | 68 RouteFunction("GetDetailsForFrame", |
| 69 base::Bind(&AppBindings::GetDetailsForFrame, base::Unretained(this))); | 69 base::Bind(&AppBindings::GetDetailsForFrame, base::Unretained(this))); |
| 70 RouteFunction("GetAppNotifyChannel", | 70 RouteFunction("GetAppNotifyChannel", |
| 71 base::Bind(&AppBindings::GetAppNotifyChannel, base::Unretained(this))); | 71 base::Bind(&AppBindings::GetAppNotifyChannel, base::Unretained(this))); |
| 72 } | 72 } |
| 73 | 73 |
| 74 v8::Handle<v8::Value> AppBindings::GetIsInstalled( | 74 v8::Handle<v8::Value> AppBindings::GetIsInstalled( |
| 75 const v8::Arguments& args) { | 75 const v8::Arguments& args) { |
| 76 // TODO(aa): Hm, maybe ExtensionBindingsContext should have GetExtension() | 76 const Extension* extension = context_->extension(); |
| 77 // afterall? | |
| 78 const ::Extension* extension = | |
| 79 extension_dispatcher_->extensions()->GetByID(context_->extension_id()); | |
| 80 | 77 |
| 81 // TODO(aa): Why only hosted app? | 78 // TODO(aa): Why only hosted app? |
| 82 bool result = extension && extension->is_hosted_app() && | 79 bool result = extension && extension->is_hosted_app() && |
| 83 extension_dispatcher_->IsExtensionActive(extension->id()); | 80 extension_dispatcher_->IsExtensionActive(extension->id()); |
| 84 return v8::Boolean::New(result); | 81 return v8::Boolean::New(result); |
| 85 } | 82 } |
| 86 | 83 |
| 87 v8::Handle<v8::Value> AppBindings::Install(const v8::Arguments& args) { | 84 v8::Handle<v8::Value> AppBindings::Install(const v8::Arguments& args) { |
| 88 content::RenderView* render_view = context_->GetRenderView(); | 85 content::RenderView* render_view = context_->GetRenderView(); |
| 89 CHECK(render_view); | 86 CHECK(render_view); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 const std::string& channel_id, const std::string& error, int callback_id) { | 197 const std::string& channel_id, const std::string& error, int callback_id) { |
| 201 v8::HandleScope handle_scope; | 198 v8::HandleScope handle_scope; |
| 202 v8::Context::Scope context_scope(context_->v8_context()); | 199 v8::Context::Scope context_scope(context_->v8_context()); |
| 203 v8::Handle<v8::Value> argv[3]; | 200 v8::Handle<v8::Value> argv[3]; |
| 204 argv[0] = v8::String::New(channel_id.c_str()); | 201 argv[0] = v8::String::New(channel_id.c_str()); |
| 205 argv[1] = v8::String::New(error.c_str()); | 202 argv[1] = v8::String::New(error.c_str()); |
| 206 argv[2] = v8::Integer::New(callback_id); | 203 argv[2] = v8::Integer::New(callback_id); |
| 207 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse", | 204 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse", |
| 208 arraysize(argv), argv, NULL)); | 205 arraysize(argv), argv, NULL)); |
| 209 } | 206 } |
| OLD | NEW |