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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 responseFactory(null); | 317 responseFactory(null); |
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 class _NavigatorHostProxyControl |
328 class _NavigatorHostProxyControl extends bindings.ProxyMessageHandler | 328 extends bindings.ProxyMessageHandler |
329 implements bindings.ProxyControl { | 329 implements bindings.ProxyControl { |
330 _NavigatorHostProxyControl.fromEndpoint( | 330 _NavigatorHostProxyControl.fromEndpoint( |
331 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 331 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
332 | 332 |
333 _NavigatorHostProxyControl.fromHandle( | 333 _NavigatorHostProxyControl.fromHandle( |
334 core.MojoHandle handle) : super.fromHandle(handle); | 334 core.MojoHandle handle) : super.fromHandle(handle); |
335 | 335 |
336 _NavigatorHostProxyControl.unbound() : super.unbound(); | 336 _NavigatorHostProxyControl.unbound() : super.unbound(); |
337 | 337 |
338 service_describer.ServiceDescription get serviceDescription => | 338 service_describer.ServiceDescription get serviceDescription => |
339 new _NavigatorHostServiceDescription(); | 339 new _NavigatorHostServiceDescription(); |
340 | 340 |
341 String get serviceName => NavigatorHost.serviceName; | 341 String get serviceName => NavigatorHost.serviceName; |
342 | 342 |
343 @override | |
344 void handleResponse(bindings.ServiceMessage message) { | 343 void handleResponse(bindings.ServiceMessage message) { |
345 switch (message.header.type) { | 344 switch (message.header.type) { |
346 default: | 345 default: |
347 proxyError("Unexpected message type: ${message.header.type}"); | 346 proxyError("Unexpected message type: ${message.header.type}"); |
348 close(immediate: true); | 347 close(immediate: true); |
349 break; | 348 break; |
350 } | 349 } |
351 } | 350 } |
352 | 351 |
353 @override | 352 @override |
354 String toString() { | 353 String toString() { |
355 var superString = super.toString(); | 354 var superString = super.toString(); |
356 return "_NavigatorHostProxyControl($superString)"; | 355 return "_NavigatorHostProxyControl($superString)"; |
357 } | 356 } |
358 } | 357 } |
359 | 358 |
360 | 359 class NavigatorHostProxy |
361 class NavigatorHostProxy extends bindings.Proxy | 360 extends bindings.Proxy |
362 implements NavigatorHost { | 361 implements NavigatorHost { |
363 NavigatorHostProxy.fromEndpoint( | 362 NavigatorHostProxy.fromEndpoint( |
364 core.MojoMessagePipeEndpoint endpoint) | 363 core.MojoMessagePipeEndpoint endpoint) |
365 : super(new _NavigatorHostProxyControl.fromEndpoint(endpoint)); | 364 : super(new _NavigatorHostProxyControl.fromEndpoint(endpoint)); |
366 | 365 |
367 NavigatorHostProxy.fromHandle(core.MojoHandle handle) | 366 NavigatorHostProxy.fromHandle(core.MojoHandle handle) |
368 : super(new _NavigatorHostProxyControl.fromHandle(handle)); | 367 : super(new _NavigatorHostProxyControl.fromHandle(handle)); |
369 | 368 |
370 NavigatorHostProxy.unbound() | 369 NavigatorHostProxy.unbound() |
371 : super(new _NavigatorHostProxyControl.unbound()); | 370 : super(new _NavigatorHostProxyControl.unbound()); |
372 | 371 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 ctrl.proxyError("The Proxy is closed."); | 409 ctrl.proxyError("The Proxy is closed."); |
411 return; | 410 return; |
412 } | 411 } |
413 var params = new _NavigatorHostDidNavigateLocallyParams(); | 412 var params = new _NavigatorHostDidNavigateLocallyParams(); |
414 params.url = url; | 413 params.url = url; |
415 ctrl.sendMessage(params, | 414 ctrl.sendMessage(params, |
416 _navigatorHostMethodDidNavigateLocallyName); | 415 _navigatorHostMethodDidNavigateLocallyName); |
417 } | 416 } |
418 } | 417 } |
419 | 418 |
420 | 419 class _NavigatorHostStubControl |
421 class NavigatorHostStub extends bindings.Stub { | 420 extends bindings.StubMessageHandler |
| 421 implements bindings.StubControl<NavigatorHost> { |
422 NavigatorHost _impl; | 422 NavigatorHost _impl; |
423 | 423 |
424 NavigatorHostStub.fromEndpoint( | 424 _NavigatorHostStubControl.fromEndpoint( |
425 core.MojoMessagePipeEndpoint endpoint, [NavigatorHost impl]) | 425 core.MojoMessagePipeEndpoint endpoint, [NavigatorHost impl]) |
426 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 426 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
427 _impl = impl; | 427 _impl = impl; |
428 } | 428 } |
429 | 429 |
430 NavigatorHostStub.fromHandle( | 430 _NavigatorHostStubControl.fromHandle( |
431 core.MojoHandle handle, [NavigatorHost impl]) | 431 core.MojoHandle handle, [NavigatorHost impl]) |
432 : super.fromHandle(handle, autoBegin: impl != null) { | 432 : super.fromHandle(handle, autoBegin: impl != null) { |
433 _impl = impl; | 433 _impl = impl; |
434 } | 434 } |
435 | 435 |
436 NavigatorHostStub.unbound([this._impl]) : super.unbound(); | 436 _NavigatorHostStubControl.unbound([this._impl]) : super.unbound(); |
437 | |
438 static NavigatorHostStub newFromEndpoint( | |
439 core.MojoMessagePipeEndpoint endpoint) { | |
440 assert(endpoint.setDescription("For NavigatorHostStub")); | |
441 return new NavigatorHostStub.fromEndpoint(endpoint); | |
442 } | |
443 | 437 |
444 | 438 |
445 | 439 |
446 dynamic handleMessage(bindings.ServiceMessage message) { | 440 dynamic handleMessage(bindings.ServiceMessage message) { |
447 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 441 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
448 return bindings.ControlMessageHandler.handleMessage(this, | 442 return bindings.ControlMessageHandler.handleMessage(this, |
449 0, | 443 0, |
450 message); | 444 message); |
451 } | 445 } |
452 if (_impl == null) { | 446 if (_impl == null) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 } | 481 } |
488 | 482 |
489 @override | 483 @override |
490 void bind(core.MojoMessagePipeEndpoint endpoint) { | 484 void bind(core.MojoMessagePipeEndpoint endpoint) { |
491 super.bind(endpoint); | 485 super.bind(endpoint); |
492 if (!isOpen && (_impl != null)) { | 486 if (!isOpen && (_impl != null)) { |
493 beginHandlingEvents(); | 487 beginHandlingEvents(); |
494 } | 488 } |
495 } | 489 } |
496 | 490 |
| 491 @override |
497 String toString() { | 492 String toString() { |
498 var superString = super.toString(); | 493 var superString = super.toString(); |
499 return "NavigatorHostStub($superString)"; | 494 return "_NavigatorHostStubControl($superString)"; |
500 } | 495 } |
501 | 496 |
502 int get version => 0; | 497 int get version => 0; |
503 | 498 |
504 static service_describer.ServiceDescription _cachedServiceDescription; | 499 static service_describer.ServiceDescription _cachedServiceDescription; |
505 static service_describer.ServiceDescription get serviceDescription { | 500 static service_describer.ServiceDescription get serviceDescription { |
506 if (_cachedServiceDescription == null) { | 501 if (_cachedServiceDescription == null) { |
507 _cachedServiceDescription = new _NavigatorHostServiceDescription(); | 502 _cachedServiceDescription = new _NavigatorHostServiceDescription(); |
508 } | 503 } |
509 return _cachedServiceDescription; | 504 return _cachedServiceDescription; |
510 } | 505 } |
511 } | 506 } |
512 | 507 |
| 508 class NavigatorHostStub |
| 509 extends bindings.Stub<NavigatorHost> |
| 510 implements NavigatorHost { |
| 511 NavigatorHostStub.fromEndpoint( |
| 512 core.MojoMessagePipeEndpoint endpoint, [NavigatorHost impl]) |
| 513 : super(new _NavigatorHostStubControl.fromEndpoint(endpoint, impl)); |
| 514 |
| 515 NavigatorHostStub.fromHandle( |
| 516 core.MojoHandle handle, [NavigatorHost impl]) |
| 517 : super(new _NavigatorHostStubControl.fromHandle(handle, impl)); |
| 518 |
| 519 NavigatorHostStub.unbound([NavigatorHost impl]) |
| 520 : super(new _NavigatorHostStubControl.unbound(impl)); |
| 521 |
| 522 static NavigatorHostStub newFromEndpoint( |
| 523 core.MojoMessagePipeEndpoint endpoint) { |
| 524 assert(endpoint.setDescription("For NavigatorHostStub")); |
| 525 return new NavigatorHostStub.fromEndpoint(endpoint); |
| 526 } |
| 527 |
| 528 static service_describer.ServiceDescription get serviceDescription => |
| 529 _NavigatorHostStubControl.serviceDescription; |
| 530 |
| 531 |
| 532 void requestNavigate(Target target, url_request_mojom.UrlRequest request) { |
| 533 return impl.requestNavigate(target, request); |
| 534 } |
| 535 void requestNavigateHistory(int delta) { |
| 536 return impl.requestNavigateHistory(delta); |
| 537 } |
| 538 void didNavigateLocally(String url) { |
| 539 return impl.didNavigateLocally(url); |
| 540 } |
| 541 } |
| 542 |
513 | 543 |
514 | 544 |
OLD | NEW |