Index: chrome/browser/resources/net_internals/mobile_view.js |
=================================================================== |
--- chrome/browser/resources/net_internals/mobile_view.js (revision 0) |
+++ chrome/browser/resources/net_internals/mobile_view.js (revision 0) |
@@ -0,0 +1,109 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * This view displays options for captured data into a file. |
+ */ |
+var MobileView = (function() { |
+ 'use strict'; |
+ |
+ // We inherit from DivView. |
+ var superClass = DivView; |
+ |
+ /** |
+ * @constructor |
+ */ |
+ function MobileView() { |
+ assertFirstConstructorCall(MobileView); |
+ |
+ // Call superclass's constructor. |
+ superClass.call(this, MobileView.MAIN_BOX_ID); |
+ |
+ g_browser.addMobileNetLogInfoObserver(this, true); |
+ |
+ this.startDataButton_ = $(MobileView.START_DATA_BUTTON_ID); |
+ this.startDataButton_.onclick = this.onStartData_.bind(this); |
+ this.stopDataButton_ = $(MobileView.STOP_DATA_BUTTON_ID); |
+ this.stopDataButton_.onclick = this.onStopData_.bind(this); |
+ this.sendDataButton_ = $(MobileView.SEND_DATA_BUTTON_ID); |
+ this.sendDataButton_.onclick = this.onSendData_.bind(this); |
+ this.filePathText_ = $(MobileView.FILE_PATH_TEXT_ID); |
+ } |
+ |
+ // ID for special HTML element in category_tabs.html |
+ MobileView.TAB_HANDLE_ID = 'tab-handle-mobile'; |
+ |
+ // IDs for special HTML elements in mobile_view.html |
+ MobileView.MAIN_BOX_ID = 'mobile-view-tab-content'; |
+ MobileView.START_DATA_BUTTON_ID = 'mobile-view-start-data'; |
+ MobileView.STOP_DATA_BUTTON_ID = 'mobile-view-stop-data'; |
+ MobileView.SEND_DATA_BUTTON_ID = 'mobile-view-send-data'; |
+ MobileView.FILE_PATH_TEXT_ID = 'mobile-view-file-path-text'; |
+ |
+ cr.addSingletonGetter(MobileView); |
+ |
+ MobileView.prototype = { |
+ // Inherit the superclass's methods. |
+ __proto__: superClass.prototype, |
+ |
+ onLoadLogFinish: function(data) { |
+ return this.onMobileNetLogInfoChanged(data.mobileNetLogInfo); |
+ }, |
+ |
+ /** |
+ * Starts saving NetLog data to a file. |
+ */ |
+ onStartData_: function() { |
+ g_browser.sendStartNetLog(); |
+ g_browser.checkForUpdatedInfo(false); |
+ }, |
+ |
+ /** |
+ * Stops saving NetLog data to a file. |
+ */ |
+ onStopData_: function() { |
+ g_browser.sendStopNetLog(); |
+ g_browser.checkForUpdatedInfo(false); |
+ }, |
+ |
+ /** |
+ * Sends NetLog data via email from browser. |
+ */ |
+ onSendData_: function() { |
+ g_browser.sendSendNetLog(); |
+ g_browser.checkForUpdatedInfo(false); |
+ }, |
+ |
+ onMobileNetLogInfoChanged: function(mobileNetLogInfo) { |
+ this.filePathText_.textContent = ''; |
+ if (mobileNetLogInfo.file) { |
+ var message = ''; |
+ if (mobileNetLogInfo.state == 'ALLOW_STOP') { |
+ message = 'NetLog data is collected in: '; |
+ } else if (mobileNetLogInfo.state == 'ALLOW_START_SEND') { |
+ message = 'NetLog data to send is in: '; |
+ } |
+ this.filePathText_.textContent = message + mobileNetLogInfo.file; |
+ } else { |
+ this.filePathText_.textContent = ''; |
+ } |
+ this.startDataButton_.disabled = false; |
+ this.stopDataButton_.disabled = false; |
+ this.sendDataButton_.disabled = false; |
+ if (mobileNetLogInfo.state == 'ALLOW_START') { |
+ this.stopDataButton_.disabled = true; |
+ this.sendDataButton_.disabled = true; |
+ } else if (mobileNetLogInfo.state == 'ALLOW_STOP') { |
+ this.startDataButton_.disabled = true; |
+ this.sendDataButton_.disabled = true; |
+ } else if (mobileNetLogInfo.state == 'ALLOW_START_SEND') { |
+ this.stopDataButton_.disabled = true; |
+ } |
+ return true; |
+ } |
+ |
+ }; |
+ |
+ return MobileView; |
+})(); |