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

Side by Side Diff: chrome/renderer/extensions/experimental.app_custom_bindings.cc

Issue 10834261: Move chrome.experimental.app.onLaunched event handler to chrome.app.runtime.onLaunched. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another merge before retrying commit. Created 8 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/extensions/experimental.app_custom_bindings.h"
6
7 #include "base/string_number_conversions.h"
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBlob.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize dScriptValue.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
11
12 using WebKit::WebBlob;
13 using WebKit::WebSerializedScriptValue;
14 using WebKit::WebString;
15
16 namespace {
17
18 v8::Handle<v8::Value> DeserializeString(const v8::Arguments &args) {
19 DCHECK(args.Length() == 1);
20 DCHECK(args[0]->IsString());
21
22 std::string data_v8(*v8::String::Utf8Value(args[0]));
23 WebString data_webstring = WebString::fromUTF8(data_v8);
24 WebSerializedScriptValue serialized =
25 WebSerializedScriptValue::fromString(data_webstring);
26 return serialized.deserialize();
27 }
28
29 v8::Handle<v8::Value> CreateBlob(const v8::Arguments &args) {
30 DCHECK(args.Length() == 2);
31 DCHECK(args[0]->IsString());
32 DCHECK(args[1]->IsNumber());
33
34 std::string blob_file_path(*v8::String::Utf8Value(args[0]));
35 std::string blob_length_string(*v8::String::Utf8Value(args[1]));
36 int64 blob_length = 0;
37 DCHECK(base::StringToInt64(blob_length_string, &blob_length));
38 WebKit::WebBlob web_blob = WebBlob::createFromFile(
39 WebString::fromUTF8(blob_file_path), blob_length);
40 return web_blob.toV8Value();
41 }
42
43 } // namespace
44
45 namespace extensions {
46
47 ExperimentalAppCustomBindings::ExperimentalAppCustomBindings()
48 : ChromeV8Extension(NULL) {
49 RouteStaticFunction("DeserializeString", &DeserializeString);
50 RouteStaticFunction("CreateBlob", &CreateBlob);
51 }
52
53 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/experimental.app_custom_bindings.h ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698