| 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/search_engines/template_url_service.h" | 5 #include "chrome/browser/search_engines/template_url_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
| 27 #include "chrome/browser/google/google_url_tracker.h" | 27 #include "chrome/browser/google/google_url_tracker.h" |
| 28 #include "chrome/browser/history/history_notifications.h" | 28 #include "chrome/browser/history/history_notifications.h" |
| 29 #include "chrome/browser/history/history_service.h" | 29 #include "chrome/browser/history/history_service.h" |
| 30 #include "chrome/browser/history/history_service_factory.h" | 30 #include "chrome/browser/history/history_service_factory.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/rlz/rlz.h" | 32 #include "chrome/browser/rlz/rlz.h" |
| 33 #include "chrome/browser/search_engines/search_host_to_urls_map.h" | 33 #include "chrome/browser/search_engines/search_host_to_urls_map.h" |
| 34 #include "chrome/browser/search_engines/search_terms_data.h" | 34 #include "chrome/browser/search_engines/search_terms_data.h" |
| 35 #include "chrome/browser/search_engines/template_url.h" | 35 #include "chrome/browser/search_engines/template_url.h" |
| 36 #include "chrome/browser/search_engines/template_url_keys.h" |
| 36 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 37 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 37 #include "chrome/browser/search_engines/template_url_service_observer.h" | 38 #include "chrome/browser/search_engines/template_url_service_observer.h" |
| 38 #include "chrome/browser/search_engines/util.h" | 39 #include "chrome/browser/search_engines/util.h" |
| 39 #include "chrome/browser/webdata/web_data_service.h" | 40 #include "chrome/browser/webdata/web_data_service.h" |
| 40 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 41 #include "chrome/common/env_vars.h" | 42 #include "chrome/common/env_vars.h" |
| 42 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" | 43 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" |
| 43 #include "chrome/common/net/url_fixer_upper.h" | 44 #include "chrome/common/net/url_fixer_upper.h" |
| 44 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 45 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 return !is_default_search_managed() && | 672 return !is_default_search_managed() && |
| 672 !IsExtensionControlledDefaultSearch() && | 673 !IsExtensionControlledDefaultSearch() && |
| 673 (url != GetDefaultSearchProvider()) && | 674 (url != GetDefaultSearchProvider()) && |
| 674 url->url_ref().SupportsReplacement() && | 675 url->url_ref().SupportsReplacement() && |
| 675 (url->GetType() == TemplateURL::NORMAL); | 676 (url->GetType() == TemplateURL::NORMAL); |
| 676 } | 677 } |
| 677 | 678 |
| 678 void TemplateURLService::SetUserSelectedDefaultSearchProvider( | 679 void TemplateURLService::SetUserSelectedDefaultSearchProvider( |
| 679 TemplateURL* url) { | 680 TemplateURL* url) { |
| 680 SetDefaultSearchProvider(url); | 681 SetDefaultSearchProvider(url); |
| 682 default_search_manager_.SaveToPrefService(GetPrefs(), &url->data_); |
| 681 } | 683 } |
| 682 | 684 |
| 683 TemplateURL* TemplateURLService::GetDefaultSearchProvider() { | 685 TemplateURL* TemplateURLService::GetDefaultSearchProvider() { |
| 684 if (loaded_ && !load_failed_) | 686 if (loaded_ && !load_failed_) |
| 685 return default_search_provider_; | 687 return default_search_provider_; |
| 686 // We're not loaded, rely on the default search provider stored in prefs. | 688 // We're not loaded, rely on the default search provider stored in prefs. |
| 687 return initial_default_search_provider_.get(); | 689 return initial_default_search_provider_.get(); |
| 688 } | 690 } |
| 689 | 691 |
| 690 bool TemplateURLService::IsSearchResultsPageFromDefaultSearchProvider( | 692 bool TemplateURLService::IsSearchResultsPageFromDefaultSearchProvider( |
| (...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2747 new_dse = *i; | 2749 new_dse = *i; |
| 2748 break; | 2750 break; |
| 2749 } | 2751 } |
| 2750 } | 2752 } |
| 2751 } | 2753 } |
| 2752 } | 2754 } |
| 2753 if (!new_dse) | 2755 if (!new_dse) |
| 2754 new_dse = FindNewDefaultSearchProvider(); | 2756 new_dse = FindNewDefaultSearchProvider(); |
| 2755 SetDefaultSearchProviderNoNotify(new_dse); | 2757 SetDefaultSearchProviderNoNotify(new_dse); |
| 2756 } | 2758 } |
| OLD | NEW |