Index: chrome/browser/chromeos/login/report_custom_flags.cc |
diff --git a/chrome/browser/chromeos/login/report_custom_flags.cc b/chrome/browser/chromeos/login/report_custom_flags.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2e1ea919997f328846bb7142c50ce57c1506ec05 |
--- /dev/null |
+++ b/chrome/browser/chromeos/login/report_custom_flags.cc |
@@ -0,0 +1,333 @@ |
+// Copyright 2014 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. |
+ |
+#include "chrome/browser/chromeos/login/report_custom_flags.h" |
+ |
+#include <algorithm> |
+#include <set> |
+#include <string> |
+ |
+#include "ash/ash_switches.h" |
+#include "base/logging.h" |
+#include "base/metrics/sparse_histogram.h" |
+#include "cc/base/switches.h" |
+#include "chrome/common/chrome_switches.h" |
+#include "chromeos/chromeos_switches.h" |
+#include "components/autofill/core/common/autofill_switches.h" |
+#include "components/cloud_devices/common/cloud_devices_switches.h" |
+#include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h" |
+#include "components/nacl/common/nacl_switches.h" |
+#include "components/password_manager/core/common/password_manager_switches.h" |
+#include "content/public/common/content_switches.h" |
+#include "extensions/common/switches.h" |
+#include "third_party/cros_system_api/switches/chrome_switches.h" |
+#include "ui/app_list/app_list_switches.h" |
+#include "ui/base/ui_base_switches.h" |
+#include "ui/display/display_switches.h" |
+#include "ui/events/event_switches.h" |
+#include "ui/gfx/switches.h" |
+#include "ui/keyboard/keyboard_switches.h" |
+#include "ui/native_theme/native_theme_switches.h" |
+#include "ui/views/views_switches.h" |
+ |
+namespace { |
+ |
+/* Reserved histogram values */ |
+enum { |
+ UNKNOWN_FLAG = 0, |
+ BAD_FLAG_FORMAT = 1, |
+}; |
+ |
+/* This table shoud consist of all possible command-line switches from |
+ chrome/browser/about_flags.cc |
+ |
+ This is a mapping between switch name and UMA id. Indexes in this table |
sky
2014/06/25 16:14:36
Hm, I would expect a mapping to have two values, t
|
+ must never be modified. Plase add new value to the end of the table only! |
+ |
+ If some entry should be deleted, replace it with empty string and a comment |
+ describing what was deleted. |
+ |
+ This table must be in sync with LoginCustomFlags in |
+ tools/metrics/histogram.xml . |
sky
2014/06/25 16:14:36
I think you mean tools/metrics/histograms/histogra
|
+ |
+ NOTE: This table is intentionally unsorted to force anyone to read this |
sky
2014/06/25 16:14:36
If only it were that easy.
|
+ comment before modifying the table. |
+*/ |
+ |
+const char* const chrome_custom_histogram_switches[] = { |
+ "" /* UNKNOWN_FLAG - reserved */, |
+ "" /* BAD_FLAG_FORMAT - reserved */, |
+ "" /* unused - reserved */, |
+ "" /* unused - reserved */, |
+ "" /* unused - reserved */, |
+ switches::kOverscrollHistoryNavigation, |
+ switches::kEnableServiceWorkerSync, |
+ switches::kNoPings, |
+ switches::kNoExperiments, |
+ switches::kEnableOneCopy, |
+ switches::kDisableGestureTapHighlight, |
+ chromeos::switches::kFileManagerEnableNewGallery, |
+ switches::kEnableQuicHttps, |
+ chromeos::switches::kEnableNetworkPortalNotification, |
+ switches::kEnableCompositingForFixedPosition, |
+ keyboard::switches::kEnableVirtualKeyboardOverscroll, |
+ switches::kAllowInsecureWebSocketFromHttpsOrigin, |
+ switches::kEnableWebBasedSignin, |
+ cc::switches::kShowFPSCounter, |
+ switches::kEnableOfflineAutoReload, |
+ chromeos::switches::kEnableFileManagerMTP, |
+ switches::kEnablePanels, |
+ extensions::switches::kEnableScriptsRequireAction, |
+ switches::kEnableSmoothScrolling, |
+ switches::kDisableDelegatedRenderer, |
+ switches::kTouchEventsDisabled, |
+ switches::kMalwareInterstitialVersionV2, |
+ switches::kDisableTouchEditing, |
+ switches::kPrefetchSearchResults, |
+ switches::kDisablePasswordManagerReauthentication, |
+ switches::kEnableSearchButtonInOmniboxAlways, |
+ switches::kDisableWebAudio, |
+ switches::kDefaultTileHeight, |
+ switches::kEnableSessionCrashedBubble, |
+ chromeos::switches::kDisableQuickofficeComponentApp, |
+ switches::kDebugPackedApps, |
+ switches::kEnableSuggestionsService, |
+ switches::kTabCaptureDownscaleQuality, |
+ switches::kManualEnhancedBookmarksOptout, |
+ switches::kDisableAcceleratedFixedRootBackground, |
+ ash::switches::kAshTouchHud, |
+ switches::kDisableDeviceEnumeration, |
+ cc::switches::kDisablePinchVirtualViewport, |
+ switches::kEnableDeferredImageDecoding, |
+ keyboard::switches::kDisableInputView, |
+ switches::kDisableDeviceDiscoveryNotifications, |
+ autofill::switches::kEnablePasswordGeneration, |
+ switches::kManualEnhancedBookmarks, |
+ extensions::switches::kExtensionContentVerification, |
+ switches::kEnableEphemeralApps, |
+ switches::kEnableQuic, |
+ chromeos::switches::kEnableFirstRunUITransitions, |
+ switches::kEnableSearchButtonInOmniboxForStr, |
+ switches::kEnableDistanceFieldText, |
+ switches::kDisableTextInputFocusManager, |
+ switches::kTouchScrollingMode, |
+ switches::kDisableOverlayScrollbar, |
+ cc::switches::kMaxTilesForInterestArea, |
+ switches::kForceGpuRasterization, |
+ switches::kAllowNaClSocketAPI, |
+ chromeos::switches::kEnableRequestTabletSite, |
+ extensions::switches::kExtensionContentVerificationEnforceStrict, |
+ switches::kDisableSoftwareRasterizer, |
+ switches::kEnableAppsFileAssociations, |
+ switches::kSSLInterstitialVersionV2Gray, |
+ autofill::switches::kShowAutofillTypePredictions, |
+ switches::kEnableViewportMeta, |
+ switches::kSilentDebuggerExtensionAPI, |
+ switches::kDisableGpuRasterization, |
+ switches::kFlagSwitchesBegin, |
+ switches::kDisableOfflineLoadStaleCache, |
+ keyboard::switches::kEnableVirtualKeyboard, |
+ switches::kDisableThreadedCompositing, |
+ switches::kEnableGpuRasterization, |
+ switches::kDisableSettingsWindow, |
+ switches::kEnableDelegatedRenderer, |
+ switches::kEnableScrollPrediction, |
+ switches::kEnableAcceleratedOverflowScroll, |
+ switches::kDisableCompositingForFixedPosition, |
+ switches::kDisableWebRtcHWEncoding, |
+ switches::kEnableSearchButtonInOmniboxForStrOrIip, |
+ switches::kEnableBleedingEdgeRenderingFastPaths, |
+ switches::kDisableSavePasswordBubble, |
+ switches::kEnableSettingsWindow, |
+ switches::kDisableDeviceDiscovery, |
+ switches::kDisableZeroCopy, |
+ switches::kEnableNaClDebug, |
+ switches::kEnableSavePasswordBubble, |
+ switches::kDisablePrefixedEncryptedMedia, |
+ switches::kDefaultTileWidth, |
+ switches::kDisableEmbeddedSharedWorker, |
+ switches::kDisableSessionCrashedBubble, |
+ switches::kEnableDeviceDiscoveryNotifications, |
+ chromeos::switches::kEnableCarrierSwitching, |
+ switches::kEnableOfflineLoadStaleCache, |
+ switches::kEnableAnswersInSuggest, |
+ switches::kEnableAppList, |
+ cc::switches::kEnablePinchVirtualViewport, |
+ switches::kDisableOfflineAutoReload, |
+ switches::kEnableFastTextAutosizing, |
+ switches::kEnablePrintPreviewRegisterPromos, |
+ switches::kEnableThreadedCompositing, |
+ switches::kEnablePermissionsBubbles, |
+ switches::kEnableEasyUnlock, |
+ chromeos::switches::kDisableSamlSignin, |
+ autofill::switches::kDisableIgnoreAutocompleteOff, |
+ views::switches::kDisableViewsRectBasedTargeting, |
+ switches::kPerformanceMonitorGathering, |
+ cc::switches::kShowCompositedLayerBorders, |
+ keyboard::switches::kEnableInputView, |
+ autofill::switches::kWalletServiceUseSandbox, |
+ chromeos::switches::kPolicySwitchesBegin, |
+ switches::kEnableOverlayScrollbar, |
+ switches::kEnableAccountConsistency, |
+ switches::kDisableMediaSource, |
+ switches::kEnableServiceWorker, |
+ switches::kEnableTouchEditing, |
+ switches::kEnableTranslateNewUX, |
+ switches::kForceDeviceScaleFactor, |
+ ash::switches::kAshDebugShortcuts, |
+ switches::kDisableAccelerated2dCanvas, |
+ switches::kDisableSuggestionsService, |
+ switches::kNumRasterThreads, |
+ password_manager::switches::kEnableAutomaticPasswordSaving, |
+ switches::kEnableAppWindowControls, |
+ switches::kDisableQuic, |
+ switches::kDisableOriginChip, |
+ switches::kMalwareInterstitialVersionV3, |
+ switches::kTouchEvents, |
+ keyboard::switches::kEnableExperimentalInputViewFeatures, |
+ keyboard::switches::kDisableVirtualKeyboardOverscroll, |
+ switches::kEnableAsyncDns, |
+ switches::kGoogleProfileInfo, |
+ switches::kEnableExperimentalWebPlatformFeatures, |
+ switches::kEnableSpellingAutoCorrect, |
+ switches::kEnableWebMIDI, |
+ switches::kEnableNaCl, |
+ switches::kOutOfProcessPdf, |
+ switches::kDisableTouchAdjustment, |
+ switches::kEnableProminentURLAppFlow, |
+ switches::kEnableHarfBuzzRenderText, |
+ switches::kEnableOriginChipAlways, |
+ switches::kDisableDistanceFieldText, |
+ switches::kEnableTextInputFocusManager, |
+ switches::kFastUserSwitching, |
+ switches::kEnableEncryptedMedia, |
+ switches::kDisableQuicHttps, |
+ switches::kSSLInterstitialVersionV1, |
+ switches::kEnableSpdy4, |
+ switches::kDisablePermissionsBubbles, |
+ switches::kNewAvatarMenu, |
+ switches::kEnableHighDpiCompositingForFixedPosition, |
+ switches::kEnableTouchDragDrop, |
+ switches::kDisableLCDText, |
+ switches::kEnableCompositingForTransition, |
+ switches::kEnableImplSidePainting, |
+ switches::kIgnoreGpuBlacklist, |
+ switches::kTouchEventsEnabled, |
+ switches::kEnableDownloadResumption, |
+ switches::kJavaScriptFlags, |
+ switches::kDisableCompositingForTransition, |
+ switches::kTouchScrollingModeSyncTouchmove, |
+ extensions::switches::kEnableExperimentalExtensionApis, |
+ switches::kEnableGestureTapHighlight, |
+ switches::kNaClDebugMask, |
+ switches::kEnhancedBookmarksExperiment, |
+ switches::kEnableFastUnload, |
+ chromeos::switches::kDisableBootAnimation, |
+ switches::kDisableNTPOtherSessionsMenu, |
+ switches::kEnableOriginChipOnSrp, |
+ switches::kDisableAccountConsistency, |
+ switches::kScrollEndEffect, |
+ switches::kTouchScrollingModeTouchcancel, |
+ switches::kDisablePnacl, |
+ switches::kSSLInterstitialVersionV2Colorful, |
+ switches::kEnableNewProfileManagement, |
+ switches::kEnableAppsShowOnFirstPaint, |
+ switches::kEnablePinch, |
+ switches::kResetAppListInstallState, |
+ switches::kDisableImplSidePainting, |
+ autofill::switches::kDisablePasswordGeneration, |
+ switches::kEnableExperimentalCanvasFeatures, |
+ switches::kEnableOfflineAutoReloadVisibleOnly, |
+ switches::kEnableStreamlinedHostedApps, |
+ switches::kTouchScrollingModeAsyncTouchmove, |
+ switches::kDisableTouchDragDrop, |
+ data_reduction_proxy::switches::kEnableDataReductionProxyDev, |
+ switches::kEnableSpellingFeedbackFieldTrial, |
+ switches::kTabCaptureUpscaleQuality, |
+ switches::kEnableLCDText, |
+ keyboard::switches::kEnableSwipeSelection, |
+ switches::kEnableWebGLDraftExtensions, |
+ switches::kEnableSyncSyncedNotifications, |
+ switches::kEnableCloudDevices, |
+ extensions::switches::kExtensionContentVerificationBootstrap, |
+ switches::kFlagSwitchesEnd, |
+ switches::kDisableSearchButtonInOmnibox, |
+ switches::kDisableOfflineAutoReloadVisibleOnly, |
+ chromeos::switches::kPolicySwitchesEnd, |
+ switches::kDisableExperimentalWebGL, |
+ extensions::switches::kExtensionContentVerificationEnforce, |
+ switches::kDisableLayerSquashing, |
+ extensions::switches::kExtensionsOnChromeURLs, |
+ chromeos::switches::kDisableNetworkPortalNotification, |
+ ash::switches::kAshEnableTouchViewTesting, |
+ chromeos::switches::kEnableTouchpadThreeFingerClick, |
+ chromeos::switches::kFileManagerEnableNewAudioPlayer, |
+ switches::kDisableFastTextAutosizing, |
+ switches::kDisableMinimizeOnSecondLauncherItemClick, |
+ switches::kDisableWebRtcHWDecoding, |
+ switches::kDisableAcceleratedVideoDecode, |
+ switches::kSavePageAsMHTML, |
+ switches::kDisableNewProfileManagement, |
+ switches::kEnableZeroCopy, |
+ switches::kEnableLinkableEphemeralApps, |
+ switches::kUseSimpleCacheBackend, |
+ switches::kEnableDevToolsExperiments, |
+ switches::kDisableSyncSyncedNotifications, |
+ cc::switches::kDisableCompositorTouchHitTesting, |
+ switches::kEnableAcceleratedFixedRootBackground, |
+ switches::kEnableTcpFastOpen, |
+ switches::kDisableAsyncDns, |
+ switches::kSyncfsEnableDirectoryOperation, |
+ data_reduction_proxy::switches::kDisableDataReductionProxyDev, |
+ ui::switches::kDisableDisplayColorCalibration, |
+ switches::kDisableAcceleratedOverflowScroll, |
+ |
+ /* Insert new entries here. Never modify existing entries! */ |
+}; |
+ |
+} // namespace |
+ |
+namespace chromeos { |
+ |
+void ReportCustomFlags(const std::set<std::string>& command_line_difference) { |
+ for (std::set<std::string>::const_iterator i = |
+ command_line_difference.begin(); |
+ i != command_line_difference.end(); |
+ ++i) { |
+ int uma_id = UNKNOWN_FLAG; |
+ if (i->size() > 2) { |
+ // skip '--' before switch name |
+ const char* switch_name = &((*i)[2]); |
+ const char* const* end = chrome_custom_histogram_switches + |
+ arraysize(chrome_custom_histogram_switches); |
+ const char* const* histflag = std::find_if( |
+ chrome_custom_histogram_switches, |
+ end, |
+ std::not1(std::bind1st(std::ptr_fun(strcmp), switch_name))); |
+ uma_id = histflag - chrome_custom_histogram_switches; |
+ if (histflag == end) { |
+ uma_id = UNKNOWN_FLAG; |
+ LOG(ERROR) << "ReportCustomFlags(): flag '" << *i << "' ('" |
+ << switch_name << "') is unknown."; |
+ } |
+ } else { |
+ uma_id = BAD_FLAG_FORMAT; |
+ LOG(ERROR) << "ReportCustomFlags(): flag '" << *i |
+ << "' has incorrect format."; |
+ } |
+ DCHECK_LT(uma_id, |
+ static_cast<int>(arraysize(chrome_custom_histogram_switches))); |
+ VLOG(1) << "ReportCustomFlags(): '" << *i << "', uma_id=" << uma_id << " ('" |
+ << chrome_custom_histogram_switches[uma_id] << "')"; |
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Login.CustomFlags", uma_id); |
+ } |
+} |
+ |
+const char* const* GetChromeCustomHistogramSwitchesForTesting( |
+ size_t* out_size) { |
+ *out_size = arraysize(chrome_custom_histogram_switches); |
+ return chrome_custom_histogram_switches; |
+} |
+ |
+} // namespace chromeos |