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

Side by Side Diff: remoting/webapp/base/js/base.js

Issue 952353002: Requiem for client_screen.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + Ready for Check-in Created 5 years, 9 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 | « remoting/webapp/base/js/application.js ('k') | remoting/webapp/browser_test/browser_test.js » ('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 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * A module that contains basic utility components and methods for the 7 * A module that contains basic utility components and methods for the
8 * chromoting project 8 * chromoting project
9 * 9 *
10 */ 10 */
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 * ); 527 * );
528 * } 528 * }
529 * 529 *
530 * MyConstructor.prototype.dispose = function() { 530 * MyConstructor.prototype.dispose = function() {
531 * this.eventHooks_.dispose(); 531 * this.eventHooks_.dispose();
532 * this.eventHooks_ = null; 532 * this.eventHooks_ = null;
533 * } 533 * }
534 * 534 *
535 * @param {base.EventSource} src 535 * @param {base.EventSource} src
536 * @param {string} eventName 536 * @param {string} eventName
537 * @param {function(...?)} listener 537 * @param {Function} listener
538 * 538 *
539 * @constructor 539 * @constructor
540 * @implements {base.Disposable} 540 * @implements {base.Disposable}
541 */ 541 */
542 base.EventHook = function(src, eventName, listener) { 542 base.EventHook = function(src, eventName, listener) {
543 this.src_ = src; 543 this.src_ = src;
544 this.eventName_ = eventName; 544 this.eventName_ = eventName;
545 this.listener_ = listener; 545 this.listener_ = listener;
546 src.addEventListener(eventName, listener); 546 src.addEventListener(eventName, listener);
547 }; 547 };
548 548
549 base.EventHook.prototype.dispose = function() { 549 base.EventHook.prototype.dispose = function() {
550 this.src_.removeEventListener(this.eventName_, this.listener_); 550 this.src_.removeEventListener(this.eventName_, this.listener_);
551 }; 551 };
552 552
553 /** 553 /**
554 * An event hook implementation for DOM Events. 554 * An event hook implementation for DOM Events.
555 * 555 *
556 * @param {HTMLElement|Element} src 556 * @param {HTMLElement|Element|Window|HTMLDocument} src
557 * @param {string} eventName 557 * @param {string} eventName
558 * @param {function(...?)} listener 558 * @param {Function} listener
559 * @param {boolean} capture 559 * @param {boolean} capture
560 * 560 *
561 * @constructor 561 * @constructor
562 * @implements {base.Disposable} 562 * @implements {base.Disposable}
563 */ 563 */
564 base.DomEventHook = function(src, eventName, listener, capture) { 564 base.DomEventHook = function(src, eventName, listener, capture) {
565 this.src_ = src; 565 this.src_ = src;
566 this.eventName_ = eventName; 566 this.eventName_ = eventName;
567 this.listener_ = listener; 567 this.listener_ = listener;
568 this.capture_ = capture; 568 this.capture_ = capture;
569 src.addEventListener(eventName, listener, capture); 569 src.addEventListener(eventName, listener, capture);
570 }; 570 };
571 571
572 base.DomEventHook.prototype.dispose = function() { 572 base.DomEventHook.prototype.dispose = function() {
573 this.src_.removeEventListener(this.eventName_, this.listener_, this.capture_); 573 this.src_.removeEventListener(this.eventName_, this.listener_, this.capture_);
574 }; 574 };
575 575
576 576
577 /** 577 /**
578 * An event hook implementation for Chrome Events. 578 * An event hook implementation for Chrome Events.
579 * 579 *
580 * @param {chrome.Event} src 580 * @param {chrome.Event} src
581 * @param {function(...?)} listener 581 * @param {Function} listener
582 * 582 *
583 * @constructor 583 * @constructor
584 * @implements {base.Disposable} 584 * @implements {base.Disposable}
585 */ 585 */
586 base.ChromeEventHook = function(src, listener) { 586 base.ChromeEventHook = function(src, listener) {
587 this.src_ = src; 587 this.src_ = src;
588 this.listener_ = listener; 588 this.listener_ = listener;
589 src.addListener(listener); 589 src.addListener(listener);
590 }; 590 };
591 591
592 base.ChromeEventHook.prototype.dispose = function() { 592 base.ChromeEventHook.prototype.dispose = function() {
593 this.src_.removeListener(this.listener_); 593 this.src_.removeListener(this.listener_);
594 }; 594 };
595 595
596 /**
597 * A disposable repeating timer.
598 *
599 * @constructor
600 * @implements {base.Disposable}
601 */
602 base.RepeatingTimer = function(/** Function */callback, /** number */interval) {
603 /** @private */
604 this.intervalId_ = window.setInterval(callback, interval);
605 };
606
607 base.RepeatingTimer.prototype.dispose = function() {
608 window.clearInterval(this.intervalId_);
609 this.intervalId_ = null;
610 };
596 611
597 /** 612 /**
598 * Converts UTF-8 string to ArrayBuffer. 613 * Converts UTF-8 string to ArrayBuffer.
599 * 614 *
600 * @param {string} string 615 * @param {string} string
601 * @return {ArrayBuffer} 616 * @return {ArrayBuffer}
602 */ 617 */
603 base.encodeUtf8 = function(string) { 618 base.encodeUtf8 = function(string) {
604 var utf8String = unescape(encodeURIComponent(string)); 619 var utf8String = unescape(encodeURIComponent(string));
605 var result = new Uint8Array(utf8String.length); 620 var result = new Uint8Array(utf8String.length);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 */ 663 */
649 base.resizeWindowToContent = function() { 664 base.resizeWindowToContent = function() {
650 var appWindow = chrome.app.window.current(); 665 var appWindow = chrome.app.window.current();
651 var outerBounds = appWindow.outerBounds; 666 var outerBounds = appWindow.outerBounds;
652 var borderY = outerBounds.height - appWindow.innerBounds.height; 667 var borderY = outerBounds.height - appWindow.innerBounds.height;
653 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); 668 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY);
654 // Sometimes, resizing the window causes its position to be reset to (0, 0), 669 // Sometimes, resizing the window causes its position to be reset to (0, 0),
655 // so restore it explicitly. 670 // so restore it explicitly.
656 appWindow.moveTo(outerBounds.left, outerBounds.top); 671 appWindow.moveTo(outerBounds.left, outerBounds.top);
657 }; 672 };
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/application.js ('k') | remoting/webapp/browser_test/browser_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698