Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/browser/resources/md_history/app.crisper.js

Issue 2238163002: [MD History] Add UMA stats for switching views and the CBD button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@start_focus_in_search_bar
Patch Set: rebase, vulcanize Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 * @fileoverview PromiseResolver is a helper class that allows creating a 6 * @fileoverview PromiseResolver is a helper class that allows creating a
7 * Promise that will be fulfilled (resolved or rejected) some time later. 7 * Promise that will be fulfilled (resolved or rejected) some time later.
8 * 8 *
9 * Example: 9 * Example:
10 * var resolver = new PromiseResolver(); 10 * var resolver = new PromiseResolver();
(...skipping 11421 matching lines...) Expand 10 before | Expand all | Expand 10 after
11432 */ 11432 */
11433 deleteForeignSession: function(sessionTag) { 11433 deleteForeignSession: function(sessionTag) {
11434 chrome.send('deleteForeignSession', [sessionTag]); 11434 chrome.send('deleteForeignSession', [sessionTag]);
11435 }, 11435 },
11436 11436
11437 openClearBrowsingData: function() { 11437 openClearBrowsingData: function() {
11438 chrome.send('clearBrowsingData'); 11438 chrome.send('clearBrowsingData');
11439 }, 11439 },
11440 11440
11441 /** 11441 /**
11442 * @param {string} histogram
11443 * @param {number} value
11444 * @param {number} max
11445 */
11446 recordHistogram: function(histogram, value, max) {
11447 chrome.send('metricsHandler:recordInHistogram', [histogram, value, max]);
11448 },
11449
11450 /**
11442 * Record an action in UMA. 11451 * Record an action in UMA.
11443 * @param {string} actionDesc The name of the action to be logged. 11452 * @param {string} actionDesc The name of the action to be logged.
11444 */ 11453 */
11445 recordAction: function(actionDesc) { 11454 recordAction: function(actionDesc) {
11446 chrome.send('metricsHandler:recordAction', [actionDesc]); 11455 chrome.send('metricsHandler:recordAction', [actionDesc]);
11447 }, 11456 },
11448 11457
11449 /** 11458 /**
11450 * @param {boolean} successful 11459 * @param {boolean} successful
11451 * @private 11460 * @private
(...skipping 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after
14346 Polymer({ 14355 Polymer({
14347 is: 'history-list-container', 14356 is: 'history-list-container',
14348 14357
14349 properties: { 14358 properties: {
14350 // The path of the currently selected page. 14359 // The path of the currently selected page.
14351 selectedPage_: String, 14360 selectedPage_: String,
14352 14361
14353 // Whether domain-grouped history is enabled. 14362 // Whether domain-grouped history is enabled.
14354 grouped: Boolean, 14363 grouped: Boolean,
14355 14364
14365 /** @type {HistoryRange} */
14366 groupedRange: {type: Number, observer: 'groupedRangeChanged_'},
14367
14356 /** @type {!QueryState} */ 14368 /** @type {!QueryState} */
14357 queryState: Object, 14369 queryState: Object,
14358 14370
14359 /** @type {!QueryResult} */ 14371 /** @type {!QueryResult} */
14360 queryResult: Object, 14372 queryResult: Object,
14361 }, 14373 },
14362 14374
14363 observers: [
14364 'groupedRangeChanged_(queryState.range)',
14365 ],
14366
14367 listeners: { 14375 listeners: {
14368 'history-list-scrolled': 'closeMenu_', 14376 'history-list-scrolled': 'closeMenu_',
14369 'load-more-history': 'loadMoreHistory_', 14377 'load-more-history': 'loadMoreHistory_',
14370 'toggle-menu': 'toggleMenu_', 14378 'toggle-menu': 'toggleMenu_',
14371 }, 14379 },
14372 14380
14373 /** 14381 /**
14374 * @param {HistoryQuery} info An object containing information about the 14382 * @param {HistoryQuery} info An object containing information about the
14375 * query. 14383 * query.
14376 * @param {!Array<HistoryEntry>} results A list of results. 14384 * @param {!Array<HistoryEntry>} results A list of results.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
14414 this.set('queryState.querying', true); 14422 this.set('queryState.querying', true);
14415 this.set('queryState.incremental', incremental); 14423 this.set('queryState.incremental', incremental);
14416 14424
14417 var lastVisitTime = 0; 14425 var lastVisitTime = 0;
14418 if (incremental) { 14426 if (incremental) {
14419 var lastVisit = this.queryResult.results.slice(-1)[0]; 14427 var lastVisit = this.queryResult.results.slice(-1)[0];
14420 lastVisitTime = lastVisit ? lastVisit.time : 0; 14428 lastVisitTime = lastVisit ? lastVisit.time : 0;
14421 } 14429 }
14422 14430
14423 var maxResults = 14431 var maxResults =
14424 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; 14432 this.groupedRange == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
14425 chrome.send('queryHistory', [ 14433 chrome.send('queryHistory', [
14426 queryState.searchTerm, queryState.groupedOffset, queryState.range, 14434 queryState.searchTerm, queryState.groupedOffset, queryState.range,
14427 lastVisitTime, maxResults 14435 lastVisitTime, maxResults
14428 ]); 14436 ]);
14429 }, 14437 },
14430 14438
14431 /** @return {number} */ 14439 /** @return {number} */
14432 getSelectedItemCount: function() { 14440 getSelectedItemCount: function() {
14433 return this.getSelectedList_().selectedPaths.size; 14441 return this.getSelectedList_().selectedPaths.size;
14434 }, 14442 },
(...skipping 12 matching lines...) Expand all
14447 return; 14455 return;
14448 this.$.dialog.get().then(function(dialog) { 14456 this.$.dialog.get().then(function(dialog) {
14449 dialog.showModal(); 14457 dialog.showModal();
14450 }); 14458 });
14451 }, 14459 },
14452 14460
14453 /** 14461 /**
14454 * @param {HistoryRange} range 14462 * @param {HistoryRange} range
14455 * @private 14463 * @private
14456 */ 14464 */
14457 groupedRangeChanged_: function(range) { 14465 groupedRangeChanged_: function(range, oldRange) {
14458 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? 14466 this.selectedPage_ = range == HistoryRange.ALL_TIME ?
14459 'infinite-list' : 'grouped-list'; 14467 'infinite-list' : 'grouped-list';
14460 14468
14469 if (oldRange == undefined)
14470 return;
14471
14461 this.queryHistory(false); 14472 this.queryHistory(false);
14473 this.fire('history-view-changed');
14462 }, 14474 },
14463 14475
14464 /** @private */ 14476 /** @private */
14465 loadMoreHistory_: function() { this.queryHistory(true); }, 14477 loadMoreHistory_: function() { this.queryHistory(true); },
14466 14478
14467 /** 14479 /**
14468 * @param {HistoryQuery} info 14480 * @param {HistoryQuery} info
14469 * @param {!Array<HistoryEntry>} results 14481 * @param {!Array<HistoryEntry>} results
14470 * @private 14482 * @private
14471 */ 14483 */
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
14695 /** 14707 /**
14696 * An array of synced devices with synced tab data. 14708 * An array of synced devices with synced tab data.
14697 * @type {!Array<!ForeignDeviceInternal>} 14709 * @type {!Array<!ForeignDeviceInternal>}
14698 */ 14710 */
14699 syncedDevices_: { 14711 syncedDevices_: {
14700 type: Array, 14712 type: Array,
14701 value: function() { return []; } 14713 value: function() { return []; }
14702 }, 14714 },
14703 14715
14704 /** @private */ 14716 /** @private */
14705 signInState_: { 14717 signInState: {
14706 type: Boolean, 14718 type: Boolean,
14719 // Updated on attach by chrome.sending 'otherDevicesInitialized'.
14707 value: loadTimeData.getBoolean('isUserSignedIn'), 14720 value: loadTimeData.getBoolean('isUserSignedIn'),
14721 observer: 'signInStateChanged_',
14708 }, 14722 },
14709 14723
14710 /** @private */ 14724 /** @private */
14711 guestSession_: { 14725 guestSession_: {
14712 type: Boolean, 14726 type: Boolean,
14713 value: loadTimeData.getBoolean('isGuestSession'), 14727 value: loadTimeData.getBoolean('isGuestSession'),
14714 }, 14728 },
14715 14729
14716 /** @private */ 14730 /** @private */
14717 fetchingSyncedTabs_: { 14731 fetchingSyncedTabs_: {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
14883 */ 14897 */
14884 tabSyncDisabled: function() { 14898 tabSyncDisabled: function() {
14885 this.fetchingSyncedTabs_ = false; 14899 this.fetchingSyncedTabs_ = false;
14886 this.clearDisplayedSyncedDevices_(); 14900 this.clearDisplayedSyncedDevices_();
14887 }, 14901 },
14888 14902
14889 /** 14903 /**
14890 * Get called when user's sign in state changes, this will affect UI of synced 14904 * Get called when user's sign in state changes, this will affect UI of synced
14891 * tabs page. Sign in promo gets displayed when user is signed out, and 14905 * tabs page. Sign in promo gets displayed when user is signed out, and
14892 * different messages are shown when there are no synced tabs. 14906 * different messages are shown when there are no synced tabs.
14893 * @param {boolean} isUserSignedIn 14907 * @param {boolean} signInState
14894 */ 14908 */
14895 updateSignInState: function(isUserSignedIn) { 14909 signInStateChanged_: function(signInState) {
14896 // If user's sign in state didn't change, then don't change message or 14910 this.fire('history-view-changed');
14897 // update UI.
14898 if (this.signInState_ == isUserSignedIn)
14899 return;
14900
14901 this.signInState_ = isUserSignedIn;
14902 14911
14903 // User signed out, clear synced device list and show the sign in promo. 14912 // User signed out, clear synced device list and show the sign in promo.
14904 if (!isUserSignedIn) { 14913 if (!signInState) {
14905 this.clearDisplayedSyncedDevices_(); 14914 this.clearDisplayedSyncedDevices_();
14906 return; 14915 return;
14907 } 14916 }
14908 // User signed in, show the loading message when querying for synced 14917 // User signed in, show the loading message when querying for synced
14909 // devices. 14918 // devices.
14910 this.fetchingSyncedTabs_ = true; 14919 this.fetchingSyncedTabs_ = true;
14911 }, 14920 },
14912 14921
14913 searchTermChanged: function(searchTerm) { 14922 searchTermChanged: function(searchTerm) {
14914 this.clearDisplayedSyncedDevices_(); 14923 this.clearDisplayedSyncedDevices_();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
14986 14995
14987 }); 14996 });
14988 // Copyright 2016 The Chromium Authors. All rights reserved. 14997 // Copyright 2016 The Chromium Authors. All rights reserved.
14989 // Use of this source code is governed by a BSD-style license that can be 14998 // Use of this source code is governed by a BSD-style license that can be
14990 // found in the LICENSE file. 14999 // found in the LICENSE file.
14991 15000
14992 Polymer({ 15001 Polymer({
14993 is: 'history-side-bar', 15002 is: 'history-side-bar',
14994 15003
14995 properties: { 15004 properties: {
14996 selectedPage: { 15005 selectedPage: {type: String, notify: true},
14997 type: String,
14998 notify: true
14999 },
15000 15006
15001 route: Object, 15007 route: Object,
15002 15008
15003 showFooter: Boolean, 15009 showFooter: Boolean,
15004 15010
15005 // If true, the sidebar is contained within an app-drawer. 15011 // If true, the sidebar is contained within an app-drawer.
15006 drawer: { 15012 drawer: {type: Boolean, reflectToAttribute: true},
15007 type: Boolean,
15008 reflectToAttribute: true
15009 },
15010 },
15011
15012 /** @private */
15013 onSelectorActivate_: function() {
15014 this.fire('history-close-drawer');
15015 }, 15013 },
15016 15014
15017 /** 15015 /**
15016 * @private
15017 */
15018 onSelectorActivate_: function() { this.fire('history-close-drawer'); },
15019
15020 /**
15018 * Relocates the user to the clear browsing data section of the settings page. 15021 * Relocates the user to the clear browsing data section of the settings page.
15019 * @param {Event} e 15022 * @param {Event} e
15020 * @private 15023 * @private
15021 */ 15024 */
15022 onClearBrowsingDataTap_: function(e) { 15025 onClearBrowsingDataTap_: function(e) {
15026 md_history.BrowserService.getInstance().recordAction(
15027 'HistoryPage_InitClearBrowsingData');
15023 md_history.BrowserService.getInstance().openClearBrowsingData(); 15028 md_history.BrowserService.getInstance().openClearBrowsingData();
15024 e.preventDefault(); 15029 e.preventDefault();
15025 }, 15030 },
15026 15031
15027 /** 15032 /**
15028 * @param {Object} route 15033 * @param {Object} route
15029 * @private 15034 * @private
15030 */ 15035 */
15031 getQueryString_: function(route) { 15036 getQueryString_: function(route) { return window.location.search; }
15032 return window.location.search;
15033 }
15034 }); 15037 });
15035 // Copyright 2016 The Chromium Authors. All rights reserved. 15038 // Copyright 2016 The Chromium Authors. All rights reserved.
15036 // Use of this source code is governed by a BSD-style license that can be 15039 // Use of this source code is governed by a BSD-style license that can be
15037 // found in the LICENSE file. 15040 // found in the LICENSE file.
15038 15041
15039 Polymer({ 15042 Polymer({
15040 is: 'history-app', 15043 is: 'history-app',
15041 15044
15042 properties: { 15045 properties: {
15043 showSidebarFooter: Boolean, 15046 showSidebarFooter: Boolean,
15044 15047
15045 // The id of the currently selected page. 15048 // The id of the currently selected page.
15046 selectedPage_: {type: String, value: 'history', observer: 'unselectAll'}, 15049 selectedPage_: {type: String, observer: 'unselectAll'},
15047 15050
15048 // Whether domain-grouped history is enabled. 15051 // Whether domain-grouped history is enabled.
15049 grouped_: {type: Boolean, reflectToAttribute: true}, 15052 grouped_: {type: Boolean, reflectToAttribute: true},
15050 15053
15051 /** @type {!QueryState} */ 15054 /** @type {!QueryState} */
15052 queryState_: { 15055 queryState_: {
15053 type: Object, 15056 type: Object,
15054 value: function() { 15057 value: function() {
15055 return { 15058 return {
15056 // Whether the most recent query was incremental. 15059 // Whether the most recent query was incremental.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
15103 ], 15106 ],
15104 15107
15105 // TODO(calamity): Replace these event listeners with data bound properties. 15108 // TODO(calamity): Replace these event listeners with data bound properties.
15106 listeners: { 15109 listeners: {
15107 'cr-menu-tap': 'onMenuTap_', 15110 'cr-menu-tap': 'onMenuTap_',
15108 'history-checkbox-select': 'checkboxSelected', 15111 'history-checkbox-select': 'checkboxSelected',
15109 'unselect-all': 'unselectAll', 15112 'unselect-all': 'unselectAll',
15110 'delete-selected': 'deleteSelected', 15113 'delete-selected': 'deleteSelected',
15111 'search-domain': 'searchDomain_', 15114 'search-domain': 'searchDomain_',
15112 'history-close-drawer': 'closeDrawer_', 15115 'history-close-drawer': 'closeDrawer_',
15116 'history-view-changed': 'recordHistoryView_',
15113 }, 15117 },
15114 15118
15115 /** @override */ 15119 /** @override */
15116 ready: function() { 15120 ready: function() {
15117 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); 15121 this.grouped_ = loadTimeData.getBoolean('groupByDomain');
15118 15122
15119 cr.ui.decorate('command', cr.ui.Command); 15123 cr.ui.decorate('command', cr.ui.Command);
15120 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); 15124 document.addEventListener('canExecute', this.onCanExecute_.bind(this));
15121 document.addEventListener('command', this.onCommand_.bind(this)); 15125 document.addEventListener('command', this.onCommand_.bind(this));
15122 15126
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
15256 15260
15257 /** 15261 /**
15258 * Update sign in state of synced device manager after user logs in or out. 15262 * Update sign in state of synced device manager after user logs in or out.
15259 * @param {boolean} isUserSignedIn 15263 * @param {boolean} isUserSignedIn
15260 */ 15264 */
15261 updateSignInState: function(isUserSignedIn) { 15265 updateSignInState: function(isUserSignedIn) {
15262 var syncedDeviceManagerElem = 15266 var syncedDeviceManagerElem =
15263 /** @type {HistorySyncedDeviceManagerElement} */this 15267 /** @type {HistorySyncedDeviceManagerElement} */this
15264 .$$('history-synced-device-manager'); 15268 .$$('history-synced-device-manager');
15265 if (syncedDeviceManagerElem) 15269 if (syncedDeviceManagerElem)
15266 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); 15270 syncedDeviceManagerElem.signInState = isUserSignedIn;
15267 }, 15271 },
15268 15272
15269 /** 15273 /**
15270 * @param {string} selectedPage 15274 * @param {string} selectedPage
15271 * @return {boolean} 15275 * @return {boolean}
15272 * @private 15276 * @private
15273 */ 15277 */
15274 syncedTabsSelected_: function(selectedPage) { 15278 syncedTabsSelected_: function(selectedPage) {
15275 return selectedPage == 'syncedTabs'; 15279 return selectedPage == 'syncedTabs';
15276 }, 15280 },
(...skipping 17 matching lines...) Expand all
15294 routeDataChanged_: function(page) { 15298 routeDataChanged_: function(page) {
15295 this.selectedPage_ = page; 15299 this.selectedPage_ = page;
15296 }, 15300 },
15297 15301
15298 /** 15302 /**
15299 * @param {string} selectedPage 15303 * @param {string} selectedPage
15300 * @private 15304 * @private
15301 */ 15305 */
15302 selectedPageChanged_: function(selectedPage) { 15306 selectedPageChanged_: function(selectedPage) {
15303 this.set('routeData_.page', selectedPage); 15307 this.set('routeData_.page', selectedPage);
15308
15309 // Log the current view on the next animation frame to allow the iron-pages
15310 // to detect that the synced-device-manager has been rendered.
15311 requestAnimationFrame(function() {
15312 this.recordHistoryView_();
15313 }.bind(this));
15304 }, 15314 },
15305 15315
15306 /** 15316 /**
15307 * This computed binding is needed to make the iron-pages selector update when 15317 * This computed binding is needed to make the iron-pages selector update when
15308 * the synced-device-manager is instantiated for the first time. Otherwise the 15318 * the synced-device-manager is instantiated for the first time. Otherwise the
15309 * fallback selection will continue to be used after the corresponding item is 15319 * fallback selection will continue to be used after the corresponding item is
15310 * added as a child of iron-pages. 15320 * added as a child of iron-pages.
15311 * @param {string} selectedPage 15321 * @param {string} selectedPage
15312 * @param {Array} items 15322 * @param {Array} items
15313 * @return {string} 15323 * @return {string}
15314 * @private 15324 * @private
15315 */ 15325 */
15316 getSelectedPage_: function(selectedPage, items) { 15326 getSelectedPage_: function(selectedPage, items) {
15317 return selectedPage; 15327 return selectedPage;
15318 }, 15328 },
15319 15329
15320 /** @private */ 15330 /** @private */
15321 closeDrawer_: function() { 15331 closeDrawer_: function() {
15322 var drawer = this.$$('#drawer'); 15332 var drawer = this.$$('#drawer');
15323 if (drawer) 15333 if (drawer)
15324 drawer.close(); 15334 drawer.close();
15325 }, 15335 },
15336
15337 /** @private */
15338 recordHistoryView_: function() {
15339 var histogramValue = HistoryViewHistogram.END;
15340 switch (this.$.content.selectedItem.id) {
15341 case 'history':
15342 switch (this.queryState_.range) {
15343 case HistoryRange.ALL_TIME:
15344 histogramValue = HistoryViewHistogram.HISTORY;
15345 break;
15346 case HistoryRange.WEEK:
15347 histogramValue = HistoryViewHistogram.GROUPED_WEEK;
15348 break;
15349 case HistoryRange.MONTH:
15350 histogramValue = HistoryViewHistogram.GROUPED_MONTH;
15351 break;
15352 }
15353 break;
15354 case 'synced-devices':
15355 var syncedDeviceManager =
15356 /** @type {HistorySyncedDeviceManagerElement} */ this.$.content
15357 .selectedItem;
15358 histogramValue = syncedDeviceManager.signInState ?
15359 HistoryViewHistogram.SYNCED_TABS :
15360 HistoryViewHistogram.SIGNIN_PROMO;
15361 break;
15362 }
15363
15364 md_history.BrowserService.getInstance().recordHistogram(
15365 'History.HistoryView', histogramValue, HistoryViewHistogram.END
15366 );
15367 },
15326 }); 15368 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698