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

Side by Side Diff: components/policy/core/browser/browser_policy_connector.cc

Issue 386573002: Gracefully handle icu errors when checking for enterprise domains. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/policy/core/browser/browser_policy_connector.h" 5 #include "components/policy/core/browser/browser_policy_connector.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 26 matching lines...) Expand all
37 37
38 // Used in BrowserPolicyConnector::SetPolicyProviderForTesting. 38 // Used in BrowserPolicyConnector::SetPolicyProviderForTesting.
39 bool g_created_policy_service = false; 39 bool g_created_policy_service = false;
40 ConfigurationPolicyProvider* g_testing_provider = NULL; 40 ConfigurationPolicyProvider* g_testing_provider = NULL;
41 41
42 // Returns true if |domain| matches the regex |pattern|. 42 // Returns true if |domain| matches the regex |pattern|.
43 bool MatchDomain(const base::string16& domain, const base::string16& pattern) { 43 bool MatchDomain(const base::string16& domain, const base::string16& pattern) {
44 UErrorCode status = U_ZERO_ERROR; 44 UErrorCode status = U_ZERO_ERROR;
45 const icu::UnicodeString icu_pattern(pattern.data(), pattern.length()); 45 const icu::UnicodeString icu_pattern(pattern.data(), pattern.length());
46 icu::RegexMatcher matcher(icu_pattern, UREGEX_CASE_INSENSITIVE, status); 46 icu::RegexMatcher matcher(icu_pattern, UREGEX_CASE_INSENSITIVE, status);
47 DCHECK(U_SUCCESS(status)) << "Invalid domain pattern: " << pattern; 47 if (!U_SUCCESS(status)) {
48 // http://crbug.com/365351 - if for some reason the matcher creation fails
49 // just return that the pattern doesn't match the domain. This is safe
50 // because the calling method (IsNonEnterpriseUser()) is just used to enable
51 // an optimization for non-enterprise users - better to skip the
52 // optimization than crash.
53 DLOG(ERROR) << "Possible invalid domain pattern: " << pattern
Joao da Silva 2014/07/10 10:23:41 WDYT of gathering some UMA samples for this? We co
54 << " - Error: " << status;
55 return false;
56 }
48 icu::UnicodeString icu_input(domain.data(), domain.length()); 57 icu::UnicodeString icu_input(domain.data(), domain.length());
49 matcher.reset(icu_input); 58 matcher.reset(icu_input);
50 status = U_ZERO_ERROR; 59 status = U_ZERO_ERROR;
51 UBool match = matcher.matches(status); 60 UBool match = matcher.matches(status);
52 DCHECK(U_SUCCESS(status)); 61 DCHECK(U_SUCCESS(status));
53 return !!match; // !! == convert from UBool to bool. 62 return !!match; // !! == convert from UBool to bool.
54 } 63 }
55 64
56 } // namespace 65 } // namespace
57 66
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 239 }
231 240
232 void BrowserPolicyConnector::SetPlatformPolicyProvider( 241 void BrowserPolicyConnector::SetPlatformPolicyProvider(
233 scoped_ptr<ConfigurationPolicyProvider> provider) { 242 scoped_ptr<ConfigurationPolicyProvider> provider) {
234 CHECK(!platform_policy_provider_); 243 CHECK(!platform_policy_provider_);
235 platform_policy_provider_ = provider.get(); 244 platform_policy_provider_ = provider.get();
236 AddPolicyProvider(provider.Pass()); 245 AddPolicyProvider(provider.Pass());
237 } 246 }
238 247
239 } // namespace policy 248 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698