1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * The status view at the top of the page. It displays what mode net-internals
7 * is in (capturing, viewing only, viewing loaded log), and may have extra
8 * information and actions depending on the mode.
10 var TopBarView
= (function() {
13 // We inherit from View.
14 var superClass
= DivView
;
17 * Main entry point. Called once the page has loaded.
20 function TopBarView() {
21 assertFirstConstructorCall(TopBarView
);
23 superClass
.call(this, TopBarView
.BOX_ID
);
25 this.nameToSubView_
= {
26 capture
: new CaptureStatusView(),
27 loaded
: new LoadedStatusView(),
28 halted
: new HaltedStatusView()
31 this.activeSubView_
= null;
34 TopBarView
.BOX_ID
= 'top-bar-view';
35 TopBarView
.TAB_DROPDOWN_MENU_ID
= 'top-bar-view-tab-selecter';
37 cr
.addSingletonGetter(TopBarView
);
39 TopBarView
.prototype = {
40 // Inherit the superclass's methods.
41 __proto__
: superClass
.prototype,
43 switchToSubView: function(name
) {
44 var newSubView
= this.nameToSubView_
[name
];
47 throw Error('Invalid subview name');
49 var prevSubView
= this.activeSubView_
;
50 this.activeSubView_
= newSubView
;
53 prevSubView
.show(false);
54 newSubView
.show(this.isVisible());
56 // Let the subview change the color scheme of the top bar.
57 $(TopBarView
.BOX_ID
).className
= name
+ '-status-view';