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

Side by Side Diff: ios/web/webui/mojo_facade.mm

Issue 2618693004: Mojo JS bindings: make sure that console.log() could be used in the bindings. (Closed)
Patch Set: . Created 3 years, 11 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
« no previous file with comments | « ios/web/webui/mojo_facade.h ('k') | ios/web/webui/mojo_js_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "ios/web/webui/mojo_facade.h" 5 #import "ios/web/webui/mojo_facade.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #import "base/ios/block_types.h" 9 #import "base/ios/block_types.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/logging.h"
12 #import "base/mac/bind_objc_block.h" 13 #import "base/mac/bind_objc_block.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #import "ios/web/public/web_state/js/crw_js_injection_evaluator.h" 16 #import "ios/web/public/web_state/js/crw_js_injection_evaluator.h"
16 #include "ios/web/public/web_thread.h" 17 #include "ios/web/public/web_thread.h"
17 #include "mojo/public/cpp/system/core.h" 18 #include "mojo/public/cpp/system/core.h"
18 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" 19 #include "services/service_manager/public/interfaces/interface_provider.mojom.h"
19 20
20 #if !defined(__has_feature) || !__has_feature(objc_arc) 21 #if !defined(__has_feature) || !__has_feature(objc_arc)
21 #error "This file requires ARC support." 22 #error "This file requires ARC support."
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } else if (name == "core.createMessagePipe") { 64 } else if (name == "core.createMessagePipe") {
64 result = HandleCoreCreateMessagePipe(args.get()); 65 result = HandleCoreCreateMessagePipe(args.get());
65 } else if (name == "core.writeMessage") { 66 } else if (name == "core.writeMessage") {
66 result = HandleCoreWriteMessage(args.get()); 67 result = HandleCoreWriteMessage(args.get());
67 } else if (name == "core.readMessage") { 68 } else if (name == "core.readMessage") {
68 result = HandleCoreReadMessage(args.get()); 69 result = HandleCoreReadMessage(args.get());
69 } else if (name == "support.watch") { 70 } else if (name == "support.watch") {
70 result = HandleSupportWatch(args.get()); 71 result = HandleSupportWatch(args.get());
71 } else if (name == "support.cancelWatch") { 72 } else if (name == "support.cancelWatch") {
72 result = HandleSupportCancelWatch(args.get()); 73 result = HandleSupportCancelWatch(args.get());
74 } else if (name == "console.log") {
75 result = HandleConsoleLog(args.get());
73 } 76 }
74 77
75 if (!result) { 78 if (!result) {
76 return ""; 79 return "";
77 } 80 }
78 81
79 std::string json_result; 82 std::string json_result;
80 base::JSONWriter::Write(*result, &json_result); 83 base::JSONWriter::Write(*result, &json_result);
81 return json_result; 84 return json_result;
82 } 85 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 266 }
264 267
265 std::unique_ptr<base::Value> MojoFacade::HandleSupportCancelWatch( 268 std::unique_ptr<base::Value> MojoFacade::HandleSupportCancelWatch(
266 const base::DictionaryValue* args) { 269 const base::DictionaryValue* args) {
267 int watch_id = 0; 270 int watch_id = 0;
268 CHECK(args->GetInteger("watchId", &watch_id)); 271 CHECK(args->GetInteger("watchId", &watch_id));
269 watchers_.erase(watch_id); 272 watchers_.erase(watch_id);
270 return nullptr; 273 return nullptr;
271 } 274 }
272 275
276 std::unique_ptr<base::Value> MojoFacade::HandleConsoleLog(
277 const base::DictionaryValue* args) {
278 std::string message;
279 CHECK(args->GetString("message", &message));
280 LOG(INFO) << message;
281 return nullptr;
282 }
283
273 } // namespace web 284 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/webui/mojo_facade.h ('k') | ios/web/webui/mojo_js_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698