OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Dictionary of constants (Initialized soon after loading by data from browser, | 6 * Dictionary of constants (Initialized soon after loading by data from browser, |
7 * updated on load log). The *Types dictionaries map strings to numeric IDs, | 7 * updated on load log). The *Types dictionaries map strings to numeric IDs, |
8 * while the *TypeNames are the other way around. | 8 * while the *TypeNames are the other way around. |
9 */ | 9 */ |
10 var EventType = null; | 10 var EventType = null; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 // This must be the first constants observer, so other constants observers | 62 // This must be the first constants observer, so other constants observers |
63 // can safely use the globals, rather than depending on walking through | 63 // can safely use the globals, rather than depending on walking through |
64 // the constants themselves. | 64 // the constants themselves. |
65 g_browser.addConstantsObserver(new ConstantsObserver()); | 65 g_browser.addConstantsObserver(new ConstantsObserver()); |
66 | 66 |
67 // Create the tab switcher. | 67 // Create the tab switcher. |
68 this.initTabs_(); | 68 this.initTabs_(); |
69 | 69 |
70 // Cut out a small vertical strip at the top of the window, to display | 70 // Cut out a small vertical strip at the top of the window, to display |
71 // a high level status (i.e. if we are capturing events, or displaying a | 71 // a high level status (i.e. if we are displaying a log file or not). |
72 // log file). Below it we will position the main tabs and their content | 72 // Below it we will position the main tabs and their content area. |
73 // area. | |
74 this.topBarView_ = TopBarView.getInstance(this); | 73 this.topBarView_ = TopBarView.getInstance(this); |
75 var verticalSplitView = new VerticalSplitView( | 74 var verticalSplitView = new VerticalSplitView( |
76 this.topBarView_, this.tabSwitcher_); | 75 this.topBarView_, this.tabSwitcher_); |
77 | 76 |
78 superClass.call(this, verticalSplitView); | 77 superClass.call(this, verticalSplitView); |
79 | 78 |
80 // Trigger initial layout. | 79 // Trigger initial layout. |
81 this.resetGeometry(); | 80 this.resetGeometry(); |
82 | 81 |
83 window.onhashchange = this.onUrlHashChange_.bind(this); | 82 window.onhashchange = this.onUrlHashChange_.bind(this); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 * HTML elements that send messages to the browser. Cannot be undone | 120 * HTML elements that send messages to the browser. Cannot be undone |
122 * without reloading the page. Must be called before passing loaded data | 121 * without reloading the page. Must be called before passing loaded data |
123 * to the individual views. | 122 * to the individual views. |
124 * | 123 * |
125 * @param {string} opt_fileName The name of the log file that has been | 124 * @param {string} opt_fileName The name of the log file that has been |
126 * loaded, if we're loading a log file. | 125 * loaded, if we're loading a log file. |
127 */ | 126 */ |
128 onLoadLog: function(opt_fileName) { | 127 onLoadLog: function(opt_fileName) { |
129 isViewingLoadedLog = true; | 128 isViewingLoadedLog = true; |
130 | 129 |
131 this.stopCapturing(); | |
132 if (opt_fileName != undefined) { | 130 if (opt_fileName != undefined) { |
133 // If there's a file name, a log file was loaded, so swap out the status | 131 // If there's a file name, a log file was loaded, so display the |
134 // bar to indicate we're no longer capturing events. | 132 // file's name in the status bar. |
135 this.topBarView_.switchToSubView('loaded').setFileName(opt_fileName); | 133 this.topBarView_.switchToSubView('loaded').setFileName(opt_fileName); |
136 SourceTracker.getInstance().setPrivacyStripping(false); | 134 SourceTracker.getInstance().setPrivacyStripping(false); |
137 } | 135 } |
138 }, | 136 }, |
139 | 137 |
140 switchToViewOnlyMode: function() { | 138 switchToViewOnlyMode: function() { |
141 // Since this won't be dumped to a file, we don't want to remove | 139 // Since this won't be dumped to a file, we don't want to remove |
142 // cookies and credentials. | 140 // cookies and credentials. |
143 log_util.createLogDumpAsync('', log_util.loadLogFile, false); | 141 log_util.createLogDumpAsync('', log_util.loadLogFile, false); |
144 }, | 142 }, |
145 | 143 |
146 stopCapturing: function() { | |
147 g_browser.disable(); | |
148 document.styleSheets[0].insertRule( | |
149 '.hide-when-not-capturing { display: none; }', 0); | |
150 }, | |
151 | |
152 initTabs_: function() { | 144 initTabs_: function() { |
153 this.tabIdToHash_ = {}; | 145 this.tabIdToHash_ = {}; |
154 this.hashToTabId_ = {}; | 146 this.hashToTabId_ = {}; |
155 | 147 |
156 this.tabSwitcher_ = new TabSwitcherView(this.onTabSwitched_.bind(this)); | 148 this.tabSwitcher_ = new TabSwitcherView(this.onTabSwitched_.bind(this)); |
157 | 149 |
158 // Helper function to add a tab given the class for a view singleton. | 150 // Helper function to add a tab given the class for a view singleton. |
159 var addTab = function(viewClass) { | 151 var addTab = function(viewClass) { |
160 var tabId = viewClass.TAB_ID; | 152 var tabId = viewClass.TAB_ID; |
161 var tabHash = viewClass.TAB_HASH; | 153 var tabHash = viewClass.TAB_HASH; |
(...skipping 20 matching lines...) Expand all Loading... |
182 addTab(ProxyView); | 174 addTab(ProxyView); |
183 addTab(EventsView); | 175 addTab(EventsView); |
184 addTab(TimelineView); | 176 addTab(TimelineView); |
185 addTab(DnsView); | 177 addTab(DnsView); |
186 addTab(SocketsView); | 178 addTab(SocketsView); |
187 addTab(AltSvcView); | 179 addTab(AltSvcView); |
188 addTab(SpdyView); | 180 addTab(SpdyView); |
189 addTab(QuicView); | 181 addTab(QuicView); |
190 addTab(SdchView); | 182 addTab(SdchView); |
191 addTab(HttpCacheView); | 183 addTab(HttpCacheView); |
192 // TODO(rayraymond): Re-enable, Modules, Bandwidth, and Prerender tabs. | 184 addTab(ModulesView); |
193 // addTab(ModulesView); | 185 addTab(BandwidthView); |
194 // addTab(BandwidthView); | 186 addTab(PrerenderView); |
195 // addTab(PrerenderView); | |
196 addTab(CrosView); | 187 addTab(CrosView); |
197 | 188 |
| 189 // Tab links start off hidden (besides import) since a log file has not |
| 190 // been loaded yet. This must be done after all the tabs are added so |
| 191 // that the width of the tab-list div is correctly styled. |
| 192 for (var tabId in this.tabSwitcher_.getAllTabViews()) { |
| 193 if (tabId != ImportView.TAB_ID) { |
| 194 this.tabSwitcher_.showTabLink(tabId, false); |
| 195 } |
| 196 } |
| 197 |
198 this.tabSwitcher_.showTabLink(CrosView.TAB_ID, cr.isChromeOS); | 198 this.tabSwitcher_.showTabLink(CrosView.TAB_ID, cr.isChromeOS); |
199 }, | 199 }, |
200 | 200 |
201 /** | 201 /** |
202 * This function is called by the tab switcher when the current tab has been | 202 * This function is called by the tab switcher when the current tab has been |
203 * changed. It will update the current URL to reflect the new active tab, | 203 * changed. It will update the current URL to reflect the new active tab, |
204 * so the back can be used to return to previous view. | 204 * so the back can be used to return to previous view. |
205 */ | 205 */ |
206 onTabSwitched_: function(oldTabId, newTabId) { | 206 onTabSwitched_: function(oldTabId, newTabId) { |
207 // Update data needed by newly active tab, as it may be | 207 // Update data needed by newly active tab, as it may be |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 * | 385 * |
386 * Example: sdchProblemCodeToString(5) should return | 386 * Example: sdchProblemCodeToString(5) should return |
387 * "DECODE_BODY_ERROR". | 387 * "DECODE_BODY_ERROR". |
388 * @param {number} sdchProblemCode The SDCH problem code. | 388 * @param {number} sdchProblemCode The SDCH problem code. |
389 * @return {string} The name of the given problem code. | 389 * @return {string} The name of the given problem code. |
390 */ | 390 */ |
391 function sdchProblemCodeToString(sdchProblemCode) { | 391 function sdchProblemCodeToString(sdchProblemCode) { |
392 return getKeyWithValue(SdchProblemCode, sdchProblemCode); | 392 return getKeyWithValue(SdchProblemCode, sdchProblemCode); |
393 } | 393 } |
394 | 394 |
OLD | NEW |