OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.View} |
33 */ | 34 */ |
34 WebInspector.WorkspaceController = function(workspace) | 35 WebInspector.ScreencastView = function() |
35 { | 36 { |
36 this._workspace = workspace; | 37 WebInspector.View.call(this); |
37 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod
el.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this); | 38 this.element.addStyleClass("fill"); |
38 window.addEventListener("focus", this._windowFocused.bind(this), false); | 39 this._isCasting = false; |
| 40 this._imageElement = this.element.createChild("img"); |
| 41 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod
el.EventTypes.ScreencastFrame, this._screencastFrame, this); |
39 } | 42 } |
40 | 43 |
41 WebInspector.WorkspaceController.prototype = { | 44 WebInspector.ScreencastView.prototype = { |
| 45 wasShown: function() |
| 46 { |
| 47 this.startCasting(); |
| 48 }, |
| 49 |
| 50 willHide: function() |
| 51 { |
| 52 this.stopCasting(); |
| 53 }, |
| 54 |
| 55 startCasting: function() |
| 56 { |
| 57 if (this._isCasting) |
| 58 return; |
| 59 this._isCasting = true; |
| 60 PageAgent.startScreencast("jpeg", 80, 0.7); |
| 61 }, |
| 62 |
| 63 stopCasting: function() |
| 64 { |
| 65 if (!this._isCasting) |
| 66 return; |
| 67 this._isCasting = false; |
| 68 PageAgent.stopScreencast(); |
| 69 }, |
| 70 |
42 /** | 71 /** |
43 * @param {WebInspector.Event} event | 72 * @param {WebInspector.Event} event |
44 */ | 73 */ |
45 _inspectedURLChanged: function(event) | 74 _screencastFrame: function(event) |
46 { | 75 { |
47 WebInspector.Revision.filterOutStaleRevisions(); | 76 var base64Data = /** type {string} */(event.data); |
| 77 this._imageElement.src = "data:image/jpg;base64," + base64Data; |
48 }, | 78 }, |
49 | 79 |
50 /** | 80 __proto__: WebInspector.View.prototype |
51 * @param {Event} event | |
52 */ | |
53 _windowFocused: function(event) | |
54 { | |
55 if (!WebInspector.experimentsSettings.refreshFileSystemsOnFocus.isEnable
d()) | |
56 return; | |
57 if (this._fileSystemRefreshTimeout) | |
58 return; | |
59 this._fileSystemRefreshTimeout = setTimeout(refreshFileSystems.bind(this
), 1000); | |
60 | |
61 function refreshFileSystems() | |
62 { | |
63 delete this._fileSystemRefreshTimeout; | |
64 var projects = this._workspace.projects(); | |
65 for (var i = 0; i < projects.length; ++i) | |
66 projects[i].refresh("/"); | |
67 } | |
68 } | |
69 } | 81 } |
70 | |
71 /** | |
72 * @type {?WebInspector.WorkspaceController} | |
73 */ | |
74 WebInspector.workspaceController = null; | |
75 | |
OLD | NEW |