OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 /** |
| 6 * This view displays options for captured data into a file. |
| 7 */ |
| 8 var MobileView = (function() { |
| 9 'use strict'; |
| 10 |
| 11 // We inherit from DivView. |
| 12 var superClass = DivView; |
| 13 |
| 14 /** |
| 15 * @constructor |
| 16 */ |
| 17 function MobileView() { |
| 18 assertFirstConstructorCall(MobileView); |
| 19 |
| 20 // Call superclass's constructor. |
| 21 superClass.call(this, MobileView.MAIN_BOX_ID); |
| 22 |
| 23 g_browser.addMobileNetLogInfoObserver(this, true); |
| 24 |
| 25 this.startDataButton_ = $(MobileView.START_DATA_BUTTON_ID); |
| 26 this.startDataButton_.onclick = this.onStartData_.bind(this); |
| 27 this.stopDataButton_ = $(MobileView.STOP_DATA_BUTTON_ID); |
| 28 this.stopDataButton_.onclick = this.onStopData_.bind(this); |
| 29 this.sendDataButton_ = $(MobileView.SEND_DATA_BUTTON_ID); |
| 30 this.sendDataButton_.onclick = this.onSendData_.bind(this); |
| 31 this.filePathText_ = $(MobileView.FILE_PATH_TEXT_ID); |
| 32 } |
| 33 |
| 34 // ID for special HTML element in category_tabs.html |
| 35 MobileView.TAB_HANDLE_ID = 'tab-handle-mobile'; |
| 36 |
| 37 // IDs for special HTML elements in mobile_view.html |
| 38 MobileView.MAIN_BOX_ID = 'mobile-view-tab-content'; |
| 39 MobileView.START_DATA_BUTTON_ID = 'mobile-view-start-data'; |
| 40 MobileView.STOP_DATA_BUTTON_ID = 'mobile-view-stop-data'; |
| 41 MobileView.SEND_DATA_BUTTON_ID = 'mobile-view-send-data'; |
| 42 MobileView.FILE_PATH_TEXT_ID = 'mobile-view-file-path-text'; |
| 43 |
| 44 cr.addSingletonGetter(MobileView); |
| 45 |
| 46 MobileView.prototype = { |
| 47 // Inherit the superclass's methods. |
| 48 __proto__: superClass.prototype, |
| 49 |
| 50 onLoadLogFinish: function(data) { |
| 51 return this.onMobileNetLogInfoChanged(data.mobileNetLogInfo); |
| 52 }, |
| 53 |
| 54 /** |
| 55 * Starts saving NetLog data to a file. |
| 56 */ |
| 57 onStartData_: function() { |
| 58 g_browser.sendStartNetLog(); |
| 59 g_browser.checkForUpdatedInfo(false); |
| 60 }, |
| 61 |
| 62 /** |
| 63 * Stops saving NetLog data to a file. |
| 64 */ |
| 65 onStopData_: function() { |
| 66 g_browser.sendStopNetLog(); |
| 67 g_browser.checkForUpdatedInfo(false); |
| 68 }, |
| 69 |
| 70 /** |
| 71 * Sends NetLog data via email from browser. |
| 72 */ |
| 73 onSendData_: function() { |
| 74 g_browser.sendSendNetLog(); |
| 75 g_browser.checkForUpdatedInfo(false); |
| 76 }, |
| 77 |
| 78 onMobileNetLogInfoChanged: function(mobileNetLogInfo) { |
| 79 this.filePathText_.textContent = ''; |
| 80 if (mobileNetLogInfo.file) { |
| 81 var message = ''; |
| 82 if (mobileNetLogInfo.state == 'ALLOW_STOP') { |
| 83 message = 'NetLog data is collected in: '; |
| 84 } else if (mobileNetLogInfo.state == 'ALLOW_START_SEND') { |
| 85 message = 'NetLog data to send is in: '; |
| 86 } |
| 87 this.filePathText_.textContent = message + mobileNetLogInfo.file; |
| 88 } else { |
| 89 this.filePathText_.textContent = ''; |
| 90 } |
| 91 this.startDataButton_.disabled = false; |
| 92 this.stopDataButton_.disabled = false; |
| 93 this.sendDataButton_.disabled = false; |
| 94 if (mobileNetLogInfo.state == 'ALLOW_START') { |
| 95 this.stopDataButton_.disabled = true; |
| 96 this.sendDataButton_.disabled = true; |
| 97 } else if (mobileNetLogInfo.state == 'ALLOW_STOP') { |
| 98 this.startDataButton_.disabled = true; |
| 99 this.sendDataButton_.disabled = true; |
| 100 } else if (mobileNetLogInfo.state == 'ALLOW_START_SEND') { |
| 101 this.stopDataButton_.disabled = true; |
| 102 } |
| 103 return true; |
| 104 } |
| 105 |
| 106 }; |
| 107 |
| 108 return MobileView; |
| 109 })(); |
OLD | NEW |