| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/search/search.h" | 5 #include "chrome/browser/search/search.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 30 #include "components/pref_registry/pref_registry_syncable.h" | 30 #include "components/pref_registry/pref_registry_syncable.h" |
| 31 #include "components/sessions/serialized_navigation_entry.h" | 31 #include "components/sessions/serialized_navigation_entry.h" |
| 32 #include "content/public/browser/navigation_entry.h" | 32 #include "content/public/browser/navigation_entry.h" |
| 33 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
| 34 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 | 37 |
| 38 #if defined(ENABLE_MANAGED_USERS) | 38 #if defined(ENABLE_MANAGED_USERS) |
| 39 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" | 39 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 40 #include "chrome/browser/managed_mode/managed_user_service.h" | 40 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 41 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 41 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 namespace chrome { | 44 namespace chrome { |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 // Configuration options for Embedded Search. | 48 // Configuration options for Embedded Search. |
| 49 // EmbeddedSearch field trials are named in such a way that we can parse out | 49 // EmbeddedSearch field trials are named in such a way that we can parse out |
| 50 // the experiment configuration from the trial's group name in order to give | 50 // the experiment configuration from the trial's group name in order to give |
| 51 // us maximum flexability in running experiments. | 51 // us maximum flexability in running experiments. |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 275 |
| 276 if (!IsQueryExtractionAllowedForURL(profile, entry->GetVirtualURL())) | 276 if (!IsQueryExtractionAllowedForURL(profile, entry->GetVirtualURL())) |
| 277 return base::string16(); | 277 return base::string16(); |
| 278 | 278 |
| 279 // Otherwise, extract from the URL. | 279 // Otherwise, extract from the URL. |
| 280 return ExtractSearchTermsFromURL(profile, entry->GetVirtualURL()); | 280 return ExtractSearchTermsFromURL(profile, entry->GetVirtualURL()); |
| 281 } | 281 } |
| 282 | 282 |
| 283 bool IsURLAllowedForSupervisedUser(const GURL& url, Profile* profile) { | 283 bool IsURLAllowedForSupervisedUser(const GURL& url, Profile* profile) { |
| 284 #if defined(ENABLE_MANAGED_USERS) | 284 #if defined(ENABLE_MANAGED_USERS) |
| 285 ManagedUserService* managed_user_service = | 285 SupervisedUserService* supervised_user_service = |
| 286 ManagedUserServiceFactory::GetForProfile(profile); | 286 SupervisedUserServiceFactory::GetForProfile(profile); |
| 287 ManagedModeURLFilter* url_filter = | 287 SupervisedUserURLFilter* url_filter = |
| 288 managed_user_service->GetURLFilterForUIThread(); | 288 supervised_user_service->GetURLFilterForUIThread(); |
| 289 if (url_filter->GetFilteringBehaviorForURL(url) == | 289 if (url_filter->GetFilteringBehaviorForURL(url) == |
| 290 ManagedModeURLFilter::BLOCK) { | 290 SupervisedUserURLFilter::BLOCK) { |
| 291 return false; | 291 return false; |
| 292 } | 292 } |
| 293 #endif | 293 #endif |
| 294 return true; | 294 return true; |
| 295 } | 295 } |
| 296 | 296 |
| 297 // Returns whether |new_tab_url| can be used as a URL for the New Tab page. | 297 // Returns whether |new_tab_url| can be used as a URL for the New Tab page. |
| 298 // NEW_TAB_URL_VALID means a valid URL; other enum values imply an invalid URL. | 298 // NEW_TAB_URL_VALID means a valid URL; other enum values imply an invalid URL. |
| 299 NewTabURLState IsValidNewTabURL(Profile* profile, const GURL& new_tab_url) { | 299 NewTabURLState IsValidNewTabURL(Profile* profile, const GURL& new_tab_url) { |
| 300 if (profile->IsOffTheRecord()) | 300 if (profile->IsOffTheRecord()) |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 819 |
| 820 // Given a FieldTrialFlags object, returns the boolean value of the provided | 820 // Given a FieldTrialFlags object, returns the boolean value of the provided |
| 821 // flag. | 821 // flag. |
| 822 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 822 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
| 823 bool default_value, | 823 bool default_value, |
| 824 const FieldTrialFlags& flags) { | 824 const FieldTrialFlags& flags) { |
| 825 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 825 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
| 826 } | 826 } |
| 827 | 827 |
| 828 } // namespace chrome | 828 } // namespace chrome |
| OLD | NEW |