| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 library navigation_mojom; | 5 library navigation_mojom; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'package:mojo/bindings.dart' as bindings; | 7 import 'package:mojo/bindings.dart' as bindings; |
| 8 import 'package:mojo/core.dart' as core; | 8 import 'package:mojo/core.dart' as core; |
| 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
| 10 import 'package:mojo/mojo/url_request.mojom.dart' as url_request_mojom; | 10 import 'package:mojo/mojo/url_request.mojom.dart' as url_request_mojom; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 } | 318 } |
| 319 | 319 |
| 320 abstract class NavigatorHost { | 320 abstract class NavigatorHost { |
| 321 static const String serviceName = "mojo::NavigatorHost"; | 321 static const String serviceName = "mojo::NavigatorHost"; |
| 322 void requestNavigate(Target target, url_request_mojom.UrlRequest request); | 322 void requestNavigate(Target target, url_request_mojom.UrlRequest request); |
| 323 void requestNavigateHistory(int delta); | 323 void requestNavigateHistory(int delta); |
| 324 void didNavigateLocally(String url); | 324 void didNavigateLocally(String url); |
| 325 } | 325 } |
| 326 | 326 |
| 327 | 327 |
| 328 class _NavigatorHostProxyImpl extends bindings.Proxy { | 328 class _NavigatorHostProxyControl extends bindings.ProxyMessageHandler |
| 329 _NavigatorHostProxyImpl.fromEndpoint( | 329 implements bindings.ProxyControl { |
| 330 _NavigatorHostProxyControl.fromEndpoint( |
| 330 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 331 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 331 | 332 |
| 332 _NavigatorHostProxyImpl.fromHandle(core.MojoHandle handle) : | 333 _NavigatorHostProxyControl.fromHandle( |
| 333 super.fromHandle(handle); | 334 core.MojoHandle handle) : super.fromHandle(handle); |
| 334 | 335 |
| 335 _NavigatorHostProxyImpl.unbound() : super.unbound(); | 336 _NavigatorHostProxyControl.unbound() : super.unbound(); |
| 336 | |
| 337 static _NavigatorHostProxyImpl newFromEndpoint( | |
| 338 core.MojoMessagePipeEndpoint endpoint) { | |
| 339 assert(endpoint.setDescription("For _NavigatorHostProxyImpl")); | |
| 340 return new _NavigatorHostProxyImpl.fromEndpoint(endpoint); | |
| 341 } | |
| 342 | 337 |
| 343 service_describer.ServiceDescription get serviceDescription => | 338 service_describer.ServiceDescription get serviceDescription => |
| 344 new _NavigatorHostServiceDescription(); | 339 new _NavigatorHostServiceDescription(); |
| 345 | 340 |
| 341 String get serviceName => NavigatorHost.serviceName; |
| 342 |
| 343 @override |
| 346 void handleResponse(bindings.ServiceMessage message) { | 344 void handleResponse(bindings.ServiceMessage message) { |
| 347 switch (message.header.type) { | 345 switch (message.header.type) { |
| 348 default: | 346 default: |
| 349 proxyError("Unexpected message type: ${message.header.type}"); | 347 proxyError("Unexpected message type: ${message.header.type}"); |
| 350 close(immediate: true); | 348 close(immediate: true); |
| 351 break; | 349 break; |
| 352 } | 350 } |
| 353 } | 351 } |
| 354 | 352 |
| 353 @override |
| 355 String toString() { | 354 String toString() { |
| 356 var superString = super.toString(); | 355 var superString = super.toString(); |
| 357 return "_NavigatorHostProxyImpl($superString)"; | 356 return "_NavigatorHostProxyControl($superString)"; |
| 358 } | 357 } |
| 359 } | 358 } |
| 360 | 359 |
| 361 | 360 |
| 362 class _NavigatorHostProxyCalls implements NavigatorHost { | 361 class NavigatorHostProxy extends bindings.Proxy |
| 363 _NavigatorHostProxyImpl _proxyImpl; | 362 implements NavigatorHost { |
| 363 NavigatorHostProxy.fromEndpoint( |
| 364 core.MojoMessagePipeEndpoint endpoint) |
| 365 : super(new _NavigatorHostProxyControl.fromEndpoint(endpoint)); |
| 364 | 366 |
| 365 _NavigatorHostProxyCalls(this._proxyImpl); | 367 NavigatorHostProxy.fromHandle(core.MojoHandle handle) |
| 366 void requestNavigate(Target target, url_request_mojom.UrlRequest request) { | 368 : super(new _NavigatorHostProxyControl.fromHandle(handle)); |
| 367 if (!_proxyImpl.isBound) { | |
| 368 _proxyImpl.proxyError("The Proxy is closed."); | |
| 369 return; | |
| 370 } | |
| 371 var params = new _NavigatorHostRequestNavigateParams(); | |
| 372 params.target = target; | |
| 373 params.request = request; | |
| 374 _proxyImpl.sendMessage(params, _navigatorHostMethodRequestNavigateName); | |
| 375 } | |
| 376 void requestNavigateHistory(int delta) { | |
| 377 if (!_proxyImpl.isBound) { | |
| 378 _proxyImpl.proxyError("The Proxy is closed."); | |
| 379 return; | |
| 380 } | |
| 381 var params = new _NavigatorHostRequestNavigateHistoryParams(); | |
| 382 params.delta = delta; | |
| 383 _proxyImpl.sendMessage(params, _navigatorHostMethodRequestNavigateHistoryN
ame); | |
| 384 } | |
| 385 void didNavigateLocally(String url) { | |
| 386 if (!_proxyImpl.isBound) { | |
| 387 _proxyImpl.proxyError("The Proxy is closed."); | |
| 388 return; | |
| 389 } | |
| 390 var params = new _NavigatorHostDidNavigateLocallyParams(); | |
| 391 params.url = url; | |
| 392 _proxyImpl.sendMessage(params, _navigatorHostMethodDidNavigateLocallyName)
; | |
| 393 } | |
| 394 } | |
| 395 | 369 |
| 370 NavigatorHostProxy.unbound() |
| 371 : super(new _NavigatorHostProxyControl.unbound()); |
| 396 | 372 |
| 397 class NavigatorHostProxy implements bindings.ProxyBase { | 373 static NavigatorHostProxy newFromEndpoint( |
| 398 final bindings.Proxy impl; | 374 core.MojoMessagePipeEndpoint endpoint) { |
| 399 NavigatorHost ptr; | 375 assert(endpoint.setDescription("For NavigatorHostProxy")); |
| 400 | 376 return new NavigatorHostProxy.fromEndpoint(endpoint); |
| 401 NavigatorHostProxy(_NavigatorHostProxyImpl proxyImpl) : | |
| 402 impl = proxyImpl, | |
| 403 ptr = new _NavigatorHostProxyCalls(proxyImpl); | |
| 404 | |
| 405 NavigatorHostProxy.fromEndpoint( | |
| 406 core.MojoMessagePipeEndpoint endpoint) : | |
| 407 impl = new _NavigatorHostProxyImpl.fromEndpoint(endpoint) { | |
| 408 ptr = new _NavigatorHostProxyCalls(impl); | |
| 409 } | |
| 410 | |
| 411 NavigatorHostProxy.fromHandle(core.MojoHandle handle) : | |
| 412 impl = new _NavigatorHostProxyImpl.fromHandle(handle) { | |
| 413 ptr = new _NavigatorHostProxyCalls(impl); | |
| 414 } | |
| 415 | |
| 416 NavigatorHostProxy.unbound() : | |
| 417 impl = new _NavigatorHostProxyImpl.unbound() { | |
| 418 ptr = new _NavigatorHostProxyCalls(impl); | |
| 419 } | 377 } |
| 420 | 378 |
| 421 factory NavigatorHostProxy.connectToService( | 379 factory NavigatorHostProxy.connectToService( |
| 422 bindings.ServiceConnector s, String url, [String serviceName]) { | 380 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 423 NavigatorHostProxy p = new NavigatorHostProxy.unbound(); | 381 NavigatorHostProxy p = new NavigatorHostProxy.unbound(); |
| 424 s.connectToService(url, p, serviceName); | 382 s.connectToService(url, p, serviceName); |
| 425 return p; | 383 return p; |
| 426 } | 384 } |
| 427 | 385 |
| 428 static NavigatorHostProxy newFromEndpoint( | 386 |
| 429 core.MojoMessagePipeEndpoint endpoint) { | 387 void requestNavigate(Target target, url_request_mojom.UrlRequest request) { |
| 430 assert(endpoint.setDescription("For NavigatorHostProxy")); | 388 if (!ctrl.isBound) { |
| 431 return new NavigatorHostProxy.fromEndpoint(endpoint); | 389 ctrl.proxyError("The Proxy is closed."); |
| 390 return; |
| 391 } |
| 392 var params = new _NavigatorHostRequestNavigateParams(); |
| 393 params.target = target; |
| 394 params.request = request; |
| 395 ctrl.sendMessage(params, |
| 396 _navigatorHostMethodRequestNavigateName); |
| 432 } | 397 } |
| 433 | 398 void requestNavigateHistory(int delta) { |
| 434 String get serviceName => NavigatorHost.serviceName; | 399 if (!ctrl.isBound) { |
| 435 | 400 ctrl.proxyError("The Proxy is closed."); |
| 436 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 401 return; |
| 437 | 402 } |
| 438 Future responseOrError(Future f) => impl.responseOrError(f); | 403 var params = new _NavigatorHostRequestNavigateHistoryParams(); |
| 439 | 404 params.delta = delta; |
| 440 Future get errorFuture => impl.errorFuture; | 405 ctrl.sendMessage(params, |
| 441 | 406 _navigatorHostMethodRequestNavigateHistoryName); |
| 442 int get version => impl.version; | |
| 443 | |
| 444 Future<int> queryVersion() => impl.queryVersion(); | |
| 445 | |
| 446 void requireVersion(int requiredVersion) { | |
| 447 impl.requireVersion(requiredVersion); | |
| 448 } | 407 } |
| 449 | 408 void didNavigateLocally(String url) { |
| 450 String toString() { | 409 if (!ctrl.isBound) { |
| 451 return "NavigatorHostProxy($impl)"; | 410 ctrl.proxyError("The Proxy is closed."); |
| 411 return; |
| 412 } |
| 413 var params = new _NavigatorHostDidNavigateLocallyParams(); |
| 414 params.url = url; |
| 415 ctrl.sendMessage(params, |
| 416 _navigatorHostMethodDidNavigateLocallyName); |
| 452 } | 417 } |
| 453 } | 418 } |
| 454 | 419 |
| 455 | 420 |
| 456 class NavigatorHostStub extends bindings.Stub { | 421 class NavigatorHostStub extends bindings.Stub { |
| 457 NavigatorHost _impl; | 422 NavigatorHost _impl; |
| 458 | 423 |
| 459 NavigatorHostStub.fromEndpoint( | 424 NavigatorHostStub.fromEndpoint( |
| 460 core.MojoMessagePipeEndpoint endpoint, [NavigatorHost impl]) | 425 core.MojoMessagePipeEndpoint endpoint, [NavigatorHost impl]) |
| 461 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 426 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 static service_describer.ServiceDescription get serviceDescription { | 505 static service_describer.ServiceDescription get serviceDescription { |
| 541 if (_cachedServiceDescription == null) { | 506 if (_cachedServiceDescription == null) { |
| 542 _cachedServiceDescription = new _NavigatorHostServiceDescription(); | 507 _cachedServiceDescription = new _NavigatorHostServiceDescription(); |
| 543 } | 508 } |
| 544 return _cachedServiceDescription; | 509 return _cachedServiceDescription; |
| 545 } | 510 } |
| 546 } | 511 } |
| 547 | 512 |
| 548 | 513 |
| 549 | 514 |
| OLD | NEW |