Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/renderer/extensions/app_bindings.cc

Issue 9653022: Revert 125811 - Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 return true; 49 return true;
50 } 50 }
51 51
52 const char* kMissingClientIdError = "Missing clientId parameter"; 52 const char* kMissingClientIdError = "Missing clientId parameter";
53 const char* kInvalidClientIdError = "Invalid clientId"; 53 const char* kInvalidClientIdError = "Invalid clientId";
54 const char* kInvalidCallbackIdError = "Invalid callbackId"; 54 const char* kInvalidCallbackIdError = "Invalid callbackId";
55 55
56 } // namespace 56 } // namespace
57 57
58
58 AppBindings::AppBindings(ExtensionDispatcher* dispatcher, 59 AppBindings::AppBindings(ExtensionDispatcher* dispatcher,
59 ChromeV8Context* context) 60 ChromeV8Context* context)
60 : ChromeV8Extension(dispatcher), 61 : ChromeV8Extension(dispatcher),
61 ChromeV8ExtensionHandler(context) { 62 ChromeV8ExtensionHandler(context) {
62 RouteFunction("GetIsInstalled", 63 RouteFunction("GetIsInstalled",
63 base::Bind(&AppBindings::GetIsInstalled, base::Unretained(this))); 64 base::Bind(&AppBindings::GetIsInstalled, base::Unretained(this)));
64 RouteFunction("Install", 65 RouteFunction("Install",
65 base::Bind(&AppBindings::Install, base::Unretained(this))); 66 base::Bind(&AppBindings::Install, base::Unretained(this)));
66 RouteFunction("GetDetails", 67 RouteFunction("GetDetails",
67 base::Bind(&AppBindings::GetDetails, base::Unretained(this))); 68 base::Bind(&AppBindings::GetDetails, base::Unretained(this)));
68 RouteFunction("GetDetailsForFrame", 69 RouteFunction("GetDetailsForFrame",
69 base::Bind(&AppBindings::GetDetailsForFrame, base::Unretained(this))); 70 base::Bind(&AppBindings::GetDetailsForFrame, base::Unretained(this)));
70 RouteFunction("GetAppNotifyChannel", 71 RouteFunction("GetAppNotifyChannel",
71 base::Bind(&AppBindings::GetAppNotifyChannel, base::Unretained(this))); 72 base::Bind(&AppBindings::GetAppNotifyChannel, base::Unretained(this)));
72 } 73 }
73 74
75
74 v8::Handle<v8::Value> AppBindings::GetIsInstalled( 76 v8::Handle<v8::Value> AppBindings::GetIsInstalled(
75 const v8::Arguments& args) { 77 const v8::Arguments& args) {
76 // TODO(aa): Hm, maybe ExtensionBindingsContext should have GetExtension() 78 // TODO(aa): Hm, maybe ExtensionBindingsContext should have GetExtension()
77 // afterall? 79 // afterall?
78 const ::Extension* extension = 80 const ::Extension* extension =
79 extension_dispatcher_->extensions()->GetByID(context_->extension_id()); 81 extension_dispatcher_->extensions()->GetByID(context_->extension_id());
80 82
81 // TODO(aa): Why only hosted app? 83 // TODO(aa): Why only hosted app?
84 // TODO(aa): GARRR - why is there IsExtensionActive and IsApplicationActive!?
82 bool result = extension && extension->is_hosted_app() && 85 bool result = extension && extension->is_hosted_app() &&
83 extension_dispatcher_->IsExtensionActive(extension->id()); 86 extension_dispatcher_->IsApplicationActive(extension->id());
84 return v8::Boolean::New(result); 87 return v8::Boolean::New(result);
85 } 88 }
86 89
87 v8::Handle<v8::Value> AppBindings::Install(const v8::Arguments& args) { 90 v8::Handle<v8::Value> AppBindings::Install(const v8::Arguments& args) {
88 content::RenderView* render_view = context_->GetRenderView(); 91 content::RenderView* render_view = context_->GetRenderView();
89 CHECK(render_view); 92 CHECK(render_view);
90 93
91 string16 error; 94 string16 error;
92 ExtensionHelper* helper = ExtensionHelper::Get(render_view); 95 ExtensionHelper* helper = ExtensionHelper::Get(render_view);
93 if (!helper->InstallWebApplicationUsingDefinitionFile( 96 if (!helper->InstallWebApplicationUsingDefinitionFile(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 const std::string& channel_id, const std::string& error, int callback_id) { 203 const std::string& channel_id, const std::string& error, int callback_id) {
201 v8::HandleScope handle_scope; 204 v8::HandleScope handle_scope;
202 v8::Context::Scope context_scope(context_->v8_context()); 205 v8::Context::Scope context_scope(context_->v8_context());
203 v8::Handle<v8::Value> argv[3]; 206 v8::Handle<v8::Value> argv[3];
204 argv[0] = v8::String::New(channel_id.c_str()); 207 argv[0] = v8::String::New(channel_id.c_str());
205 argv[1] = v8::String::New(error.c_str()); 208 argv[1] = v8::String::New(error.c_str());
206 argv[2] = v8::Integer::New(callback_id); 209 argv[2] = v8::Integer::New(callback_id);
207 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse", 210 CHECK(context_->CallChromeHiddenMethod("app.onGetAppNotifyChannelResponse",
208 arraysize(argv), argv, NULL)); 211 arraysize(argv), argv, NULL));
209 } 212 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/feature_unittest.cc ('k') | chrome/renderer/extensions/chrome_v8_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698