OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/protector/protector_service.h" | 5 #include "chrome/browser/protector/protector_service.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/google/google_util.h" | 8 #include "chrome/browser/google/google_util.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/protector/composite_settings_change.h" | 10 #include "chrome/browser/protector/composite_settings_change.h" |
11 #include "chrome/browser/protector/keys.h" | 11 #include "chrome/browser/protector/keys.h" |
12 #include "chrome/browser/protector/protected_prefs_watcher.h" | 12 #include "chrome/browser/protector/protected_prefs_watcher.h" |
13 #include "chrome/browser/protector/protector_utils.h" | 13 #include "chrome/browser/protector/protector_utils.h" |
14 #include "chrome/browser/protector/settings_change_global_error.h" | 14 #include "chrome/browser/protector/settings_change_global_error.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
19 #include "net/base/registry_controlled_domain.h" | 19 #include "net/base/registry_controlled_domain.h" |
20 | 20 |
21 namespace protector { | 21 namespace protector { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Returns true if changes with URLs |url1| and |url2| can be merged. | 25 // Returns true if changes with URLs |url1| and |url2| can be merged. |
26 bool CanMerge(const GURL& url1, const GURL& url2) { | 26 bool CanMerge(const GURL& url1, const GURL& url2) { |
27 VLOG(1) << "Checking if can merge " << url1.spec() << " with " << url2.spec(); | 27 VLOG(1) << "Checking if can merge " << url1.spec() << " with " << url2.spec(); |
28 // All Google URLs are considered the same one. | 28 // All Google URLs are considered the same one. |
29 if (google_util::IsGoogleHostname(url1.host(), | 29 if (google_util::IsGoogleHostname(url1.host())) |
30 google_util::DISALLOW_SUBDOMAIN)) { | 30 return google_util::IsGoogleHostname(url2.host()); |
31 return google_util::IsGoogleHostname(url2.host(), | |
32 google_util::DISALLOW_SUBDOMAIN); | |
33 } | |
34 // Otherwise URLs must have the same domain. | 31 // Otherwise URLs must have the same domain. |
35 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2); | 32 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2); |
36 } | 33 } |
37 | 34 |
38 } // namespace | 35 } // namespace |
39 | 36 |
40 ProtectorService::ProtectorService(Profile* profile) | 37 ProtectorService::ProtectorService(Profile* profile) |
41 : profile_(profile), | 38 : profile_(profile), |
42 has_active_change_(false) { | 39 has_active_change_(false) { |
43 // Start observing pref changes. | 40 // Start observing pref changes. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 ProtectorService::MatchItemByError::MatchItemByError( | 212 ProtectorService::MatchItemByError::MatchItemByError( |
216 const SettingsChangeGlobalError* other) : other_(other) { | 213 const SettingsChangeGlobalError* other) : other_(other) { |
217 } | 214 } |
218 | 215 |
219 bool ProtectorService::MatchItemByError::operator()( | 216 bool ProtectorService::MatchItemByError::operator()( |
220 const ProtectorService::Item& item) { | 217 const ProtectorService::Item& item) { |
221 return other_ == item.error.get(); | 218 return other_ == item.error.get(); |
222 } | 219 } |
223 | 220 |
224 } // namespace protector | 221 } // namespace protector |
OLD | NEW |