Updated drag and drop thumbnails.
[chromium-blink-merge.git] / chrome / browser / resources / net_internals / capture_status_view.js
blobb4789a25baa85c8817c463cb707d4c786c27468e
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
3 // found in the LICENSE file.
5 /**
6 * The status view at the top of the page when in capturing mode.
7 */
8 var CaptureStatusView = (function() {
9 'use strict';
11 // We inherit from DivView.
12 var superClass = DivView;
14 function CaptureStatusView() {
15 superClass.call(this, CaptureStatusView.MAIN_BOX_ID);
17 $(CaptureStatusView.STOP_BUTTON_ID).onclick = switchToViewOnlyMode_;
19 $(CaptureStatusView.RESET_BUTTON_ID).onclick =
20 EventsTracker.getInstance().deleteAllLogEntries.bind(
21 EventsTracker.getInstance());
22 $(CaptureStatusView.CLEAR_CACHE_BUTTON_ID).onclick =
23 g_browser.sendClearAllCache.bind(g_browser);
24 $(CaptureStatusView.FLUSH_SOCKETS_BUTTON_ID).onclick =
25 g_browser.sendFlushSocketPools.bind(g_browser);
27 $(CaptureStatusView.TOGGLE_EXTRAS_ID).onclick =
28 this.toggleExtras_.bind(this);
30 this.capturedEventsCountBox_ =
31 $(CaptureStatusView.CAPTURED_EVENTS_COUNT_ID);
32 this.updateEventCounts_();
34 EventsTracker.getInstance().addLogEntryObserver(this);
37 // IDs for special HTML elements in status_view.html
38 CaptureStatusView.MAIN_BOX_ID = 'capture-status-view';
39 CaptureStatusView.STOP_BUTTON_ID = 'capture-status-view-stop';
40 CaptureStatusView.RESET_BUTTON_ID = 'capture-status-view-reset';
41 CaptureStatusView.CLEAR_CACHE_BUTTON_ID = 'capture-status-view-clear-cache';
42 CaptureStatusView.FLUSH_SOCKETS_BUTTON_ID =
43 'capture-status-view-flush-sockets';
44 CaptureStatusView.CAPTURED_EVENTS_COUNT_ID =
45 'capture-status-view-captured-events-count';
46 CaptureStatusView.TOGGLE_EXTRAS_ID = 'capture-status-view-toggle-extras';
47 CaptureStatusView.EXTRAS_ID = 'capture-status-view-extras';
49 CaptureStatusView.prototype = {
50 // Inherit the superclass's methods.
51 __proto__: superClass.prototype,
53 /**
54 * Called whenever new log entries have been received.
56 onReceivedLogEntries: function(logEntries) {
57 this.updateEventCounts_();
60 /**
61 * Called whenever all log events are deleted.
63 onAllLogEntriesDeleted: function() {
64 this.updateEventCounts_();
67 /**
68 * Updates the counters showing how many events have been captured.
70 updateEventCounts_: function() {
71 this.capturedEventsCountBox_.textContent =
72 EventsTracker.getInstance().getNumCapturedEvents();
75 /**
76 * Toggles the visibility of the "extras" action bar.
78 toggleExtras_: function() {
79 var toggle = $(CaptureStatusView.TOGGLE_EXTRAS_ID);
80 var extras = $(CaptureStatusView.EXTRAS_ID);
82 var isVisible = extras.style.display == '';
84 // Toggle between the left-facing triangle and right-facing triange.
85 toggle.className = isVisible ?
86 'capture-status-view-rotateleft' : 'capture-status-view-rotateright';
87 setNodeDisplay(extras, !isVisible);
91 /**
92 * Calls the corresponding function of MainView. This is needed because we
93 * can't call MainView.getInstance() in the constructor, as it hasn't been
94 * created yet.
96 function switchToViewOnlyMode_() {
97 MainView.getInstance().switchToViewOnlyMode();
100 return CaptureStatusView;
101 })();