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

Unified Diff: components/policy/core/browser/browser_policy_connector.cc

Issue 382813002: Added more policy UMA metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/browser/browser_policy_connector.cc
diff --git a/components/policy/core/browser/browser_policy_connector.cc b/components/policy/core/browser/browser_policy_connector.cc
index ead92324b6ba51131fa46d8aaa7764d45b161251..1ff2197d784d38597bbf2f2170e2735a1ca56111 100644
--- a/components/policy/core/browser/browser_policy_connector.cc
+++ b/components/policy/core/browser/browser_policy_connector.cc
@@ -11,6 +11,8 @@
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "base/metrics/histogram.h"
+#include "base/metrics/sparse_histogram.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
@@ -39,8 +41,30 @@ const char kDefaultDeviceManagementServerUrl[] =
bool g_created_policy_service = false;
ConfigurationPolicyProvider* g_testing_provider = NULL;
+void ReportRegexSuccessMetric(bool success) {
+ UMA_HISTOGRAM_BOOLEAN("Enterprise.DomainWhitelistRegexSuccess", success);
+}
+
+
Ilya Sherman 2014/07/24 17:29:32 nit: Spurious newline
Andrew T Wilson (Slow) 2014/07/25 07:39:01 Done.
+// Regexes that match many of the larger public email providers as we know
+// these users are not from hosted enterprise domains. Keep this list in sync
+// with the EnterpriseDomainRegex enum in histograms.xml.
+const wchar_t* kNonManagedDomainPatterns[] = {
Ilya Sherman 2014/07/24 17:29:33 nit: Can this be more const?
Andrew T Wilson (Slow) 2014/07/25 07:39:01 Done.
+ L"aol\\.com",
+ L"googlemail\\.com",
+ L"gmail\\.com",
+ L"hotmail(\\.co|\\.com|)\\.[^.]+", // hotmail.com, hotmail.it, hotmail.co.uk
Ilya Sherman 2014/07/24 17:29:33 Hmm, this is a slightly strange regex -- why speci
Andrew T Wilson (Slow) 2014/07/24 19:49:53 Agreed, I can fix this in a separate CL (this isn'
+ L"live\\.com",
+ L"mail\\.ru",
+ L"msn\\.com",
+ L"qq\\.com",
+ L"yahoo(\\.co|\\.com|)\\.[^.]+", // yahoo.com, yahoo.co.uk, yahoo.com.tw
+ L"yandex\\.ru",
+};
+
// Returns true if |domain| matches the regex |pattern|.
-bool MatchDomain(const base::string16& domain, const base::string16& pattern) {
+bool MatchDomain(const base::string16& domain, const base::string16& pattern,
+ size_t index) {
UErrorCode status = U_ZERO_ERROR;
const icu::UnicodeString icu_pattern(pattern.data(), pattern.length());
icu::RegexMatcher matcher(icu_pattern, UREGEX_CASE_INSENSITIVE, status);
@@ -52,8 +76,14 @@ bool MatchDomain(const base::string16& domain, const base::string16& pattern) {
// optimization than crash.
DLOG(ERROR) << "Possible invalid domain pattern: " << pattern
<< " - Error: " << status;
+ ReportRegexSuccessMetric(false);
+ UMA_HISTOGRAM_ENUMERATION("Enterprise.DomainWhitelistRegexFailureIndex",
+ index, arraysize(kNonManagedDomainPatterns));
Ilya Sherman 2014/07/24 17:29:33 Note that as you have this set up, the only valid
Andrew T Wilson (Slow) 2014/07/24 19:49:53 Yes. My goal isn't to have this be a long-term UMA
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Enterprise.DomainWhitelistRegexFailureStatus",
+ status);
return false;
}
+ ReportRegexSuccessMetric(true);
icu::UnicodeString icu_input(domain.data(), domain.length());
matcher.reset(icu_input);
status = U_ZERO_ERROR;
@@ -192,26 +222,11 @@ bool BrowserPolicyConnector::IsNonEnterpriseUser(const std::string& username) {
// users.
return true;
}
-
- // Exclude many of the larger public email providers as we know these users
- // are not from hosted enterprise domains.
- static const wchar_t* kNonManagedDomainPatterns[] = {
- L"aol\\.com",
- L"googlemail\\.com",
- L"gmail\\.com",
- L"hotmail(\\.co|\\.com|)\\.[^.]+", // hotmail.com, hotmail.it, hotmail.co.uk
- L"live\\.com",
- L"mail\\.ru",
- L"msn\\.com",
- L"qq\\.com",
- L"yahoo(\\.co|\\.com|)\\.[^.]+", // yahoo.com, yahoo.co.uk, yahoo.com.tw
- L"yandex\\.ru",
- };
const base::string16 domain = base::UTF8ToUTF16(
gaia::ExtractDomainName(gaia::CanonicalizeEmail(username)));
for (size_t i = 0; i < arraysize(kNonManagedDomainPatterns); i++) {
base::string16 pattern = base::WideToUTF16(kNonManagedDomainPatterns[i]);
- if (MatchDomain(domain, pattern))
+ if (MatchDomain(domain, pattern, i))
return true;
}
return false;

Powered by Google App Engine
This is Rietveld 408576698