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

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

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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/web_state/ui/web_view_js_utils_unittest.mm ('k') | ipc/ipc_message_utils.cc » ('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 #include "base/ios/block_types.h" 9 #include "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/mac/bind_objc_block.h" 12 #include "base/mac/bind_objc_block.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #import "ios/web/public/web_state/js/crw_js_injection_evaluator.h" 15 #import "ios/web/public/web_state/js/crw_js_injection_evaluator.h"
16 #include "ios/web/public/web_thread.h" 16 #include "ios/web/public/web_thread.h"
17 #include "mojo/public/cpp/system/core.h" 17 #include "mojo/public/cpp/system/core.h"
18 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" 18 #include "services/service_manager/public/interfaces/interface_provider.mojom.h"
19 19
20 #if !defined(__has_feature) || !__has_feature(objc_arc) 20 #if !defined(__has_feature) || !__has_feature(objc_arc)
21 #error "This file requires ARC support." 21 #error "This file requires ARC support."
22 #endif 22 #endif
23 23
24 namespace web { 24 namespace web {
25 25
26 namespace { 26 namespace {
27 27
28 // Wraps an integer into |base::Value| as |TYPE_INTEGER|. 28 // Wraps an integer into |base::Value| as |Type::INTEGER|.
29 template <typename IntegerT> 29 template <typename IntegerT>
30 std::unique_ptr<base::Value> ValueFromInteger(IntegerT handle) { 30 std::unique_ptr<base::Value> ValueFromInteger(IntegerT handle) {
31 return std::unique_ptr<base::Value>( 31 return std::unique_ptr<base::Value>(
32 new base::FundamentalValue(static_cast<int>(handle))); 32 new base::FundamentalValue(static_cast<int>(handle)));
33 } 33 }
34 34
35 } // namespace 35 } // namespace
36 36
37 MojoFacade::MojoFacade( 37 MojoFacade::MojoFacade(
38 service_manager::mojom::InterfaceProvider* interface_provider, 38 service_manager::mojom::InterfaceProvider* interface_provider,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 mojo::Handle(handle).Close(); 129 mojo::Handle(handle).Close();
130 130
131 return ValueFromInteger(MOJO_RESULT_OK); 131 return ValueFromInteger(MOJO_RESULT_OK);
132 } 132 }
133 133
134 std::unique_ptr<base::Value> MojoFacade::HandleCoreCreateMessagePipe( 134 std::unique_ptr<base::Value> MojoFacade::HandleCoreCreateMessagePipe(
135 base::DictionaryValue* args) { 135 base::DictionaryValue* args) {
136 const base::Value* options_as_value = nullptr; 136 const base::Value* options_as_value = nullptr;
137 CHECK(args->Get("optionsDict", &options_as_value)); 137 CHECK(args->Get("optionsDict", &options_as_value));
138 138
139 if (options_as_value->IsType(base::Value::TYPE_DICTIONARY)) { 139 if (options_as_value->IsType(base::Value::Type::DICTIONARY)) {
140 // There are no options defined for CreateMessagePipe yet. 140 // There are no options defined for CreateMessagePipe yet.
141 const base::DictionaryValue* options_as_dict; 141 const base::DictionaryValue* options_as_dict;
142 options_as_value->GetAsDictionary(&options_as_dict); 142 options_as_value->GetAsDictionary(&options_as_dict);
143 CHECK(options_as_dict->empty()); 143 CHECK(options_as_dict->empty());
144 } 144 }
145 145
146 CHECK(options_as_value->IsType(base::Value::TYPE_NULL)); 146 CHECK(options_as_value->IsType(base::Value::Type::NONE));
147 147
148 mojo::MessagePipe message_pipe; 148 mojo::MessagePipe message_pipe;
149 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); 149 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
150 result->SetInteger("handle0", message_pipe.handle0.release().value()); 150 result->SetInteger("handle0", message_pipe.handle0.release().value());
151 result->SetInteger("handle1", message_pipe.handle1.release().value()); 151 result->SetInteger("handle1", message_pipe.handle1.release().value());
152 return std::unique_ptr<base::Value>(result.release()); 152 return std::unique_ptr<base::Value>(result.release());
153 } 153 }
154 154
155 std::unique_ptr<base::Value> MojoFacade::HandleCoreWriteMessage( 155 std::unique_ptr<base::Value> MojoFacade::HandleCoreWriteMessage(
156 base::DictionaryValue* args) { 156 base::DictionaryValue* args) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 std::unique_ptr<base::Value> MojoFacade::HandleSupportCancelWatch( 265 std::unique_ptr<base::Value> MojoFacade::HandleSupportCancelWatch(
266 const base::DictionaryValue* args) { 266 const base::DictionaryValue* args) {
267 int watch_id = 0; 267 int watch_id = 0;
268 CHECK(args->GetInteger("watchId", &watch_id)); 268 CHECK(args->GetInteger("watchId", &watch_id));
269 watchers_.erase(watch_id); 269 watchers_.erase(watch_id);
270 return nullptr; 270 return nullptr;
271 } 271 }
272 272
273 } // namespace web 273 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/web_view_js_utils_unittest.mm ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698