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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 NotifyObservers(); | 673 NotifyObservers(); |
674 } | 674 } |
675 | 675 |
676 TemplateURL* TemplateURLService::GetDefaultSearchProvider() { | 676 TemplateURL* TemplateURLService::GetDefaultSearchProvider() { |
677 if (loaded_ && !load_failed_) | 677 if (loaded_ && !load_failed_) |
678 return default_search_provider_; | 678 return default_search_provider_; |
679 // We're not loaded, rely on the default search provider stored in prefs. | 679 // We're not loaded, rely on the default search provider stored in prefs. |
680 return initial_default_search_provider_.get(); | 680 return initial_default_search_provider_.get(); |
681 } | 681 } |
682 | 682 |
683 bool TemplateURLService::IsSearchResultsPageFromDefaultSearchProvider( | |
684 const GURL current_url) { | |
685 TemplateURL* default_provider = GetDefaultSearchProvider(); | |
686 if (default_provider && default_provider->IsSearchURL(current_url)) | |
Peter Kasting
2013/07/31 23:56:51
Nit: Simpler:
return default_provider && defaul
rpetterson
2013/08/05 19:46:12
Done.
| |
687 return true; | |
688 return false; | |
689 } | |
690 | |
683 TemplateURL* TemplateURLService::FindNewDefaultSearchProvider() { | 691 TemplateURL* TemplateURLService::FindNewDefaultSearchProvider() { |
684 // See if the prepopulated default still exists. | 692 // See if the prepopulated default still exists. |
685 scoped_ptr<TemplateURL> prepopulated_default( | 693 scoped_ptr<TemplateURL> prepopulated_default( |
686 TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(profile_)); | 694 TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(profile_)); |
687 for (TemplateURLVector::iterator i = template_urls_.begin(); | 695 for (TemplateURLVector::iterator i = template_urls_.begin(); |
688 i != template_urls_.end(); ++i) { | 696 i != template_urls_.end(); ++i) { |
689 if ((*i)->prepopulate_id() == prepopulated_default->prepopulate_id()) | 697 if ((*i)->prepopulate_id() == prepopulated_default->prepopulate_id()) |
690 return *i; | 698 return *i; |
691 } | 699 } |
692 // If not, use the first non-extension keyword of the templates that supports | 700 // If not, use the first non-extension keyword of the templates that supports |
(...skipping 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2579 const ExtensionKeyword& extension_keyword) const { | 2587 const ExtensionKeyword& extension_keyword) const { |
2580 TemplateURLData data; | 2588 TemplateURLData data; |
2581 data.short_name = UTF8ToUTF16(extension_keyword.extension_name); | 2589 data.short_name = UTF8ToUTF16(extension_keyword.extension_name); |
2582 data.SetKeyword(UTF8ToUTF16(extension_keyword.extension_keyword)); | 2590 data.SetKeyword(UTF8ToUTF16(extension_keyword.extension_keyword)); |
2583 // This URL is not actually used for navigation. It holds the extension's | 2591 // This URL is not actually used for navigation. It holds the extension's |
2584 // ID, as well as forcing the TemplateURL to be treated as a search keyword. | 2592 // ID, as well as forcing the TemplateURL to be treated as a search keyword. |
2585 data.SetURL(std::string(extensions::kExtensionScheme) + "://" + | 2593 data.SetURL(std::string(extensions::kExtensionScheme) + "://" + |
2586 extension_keyword.extension_id + "/?q={searchTerms}"); | 2594 extension_keyword.extension_id + "/?q={searchTerms}"); |
2587 return new TemplateURL(profile_, data); | 2595 return new TemplateURL(profile_, data); |
2588 } | 2596 } |
OLD | NEW |