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

Side by Side Diff: components/search_engines/template_url_service.cc

Issue 2367373003: [Android] Allow setting recently visited search engines as default search engine (Closed)
Patch Set: Update based on Ian's comments and fix bugs caused by test cases. Created 4 years, 1 month 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
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/search_engines/template_url_service.h" 5 #include "components/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 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 if (!urls) 1635 if (!urls)
1636 return true; 1636 return true;
1637 for (TemplateURLSet::const_iterator i(urls->begin()); i != urls->end(); ++i) { 1637 for (TemplateURLSet::const_iterator i(urls->begin()); i != urls->end(); ++i) {
1638 if (!(*i)->safe_for_autoreplace()) 1638 if (!(*i)->safe_for_autoreplace())
1639 return false; 1639 return false;
1640 } 1640 }
1641 return true; 1641 return true;
1642 } 1642 }
1643 1643
1644 bool TemplateURLService::CanReplace(const TemplateURL* t_url) { 1644 bool TemplateURLService::CanReplace(const TemplateURL* t_url) {
1645 return (t_url != default_search_provider_ && !t_url->show_in_default_list() && 1645 return (t_url != default_search_provider_ && t_url->prepopulate_id() <= 0 &&
1646 t_url->safe_for_autoreplace()); 1646 !t_url->created_by_policy() && t_url->safe_for_autoreplace());
1647 } 1647 }
1648 1648
1649 TemplateURL* TemplateURLService::FindNonExtensionTemplateURLForKeyword( 1649 TemplateURL* TemplateURLService::FindNonExtensionTemplateURLForKeyword(
1650 const base::string16& keyword) { 1650 const base::string16& keyword) {
1651 TemplateURL* keyword_turl = GetTemplateURLForKeyword(keyword); 1651 TemplateURL* keyword_turl = GetTemplateURLForKeyword(keyword);
1652 if (!keyword_turl || (keyword_turl->type() == TemplateURL::NORMAL)) 1652 if (!keyword_turl || (keyword_turl->type() == TemplateURL::NORMAL))
1653 return keyword_turl; 1653 return keyword_turl;
1654 // The extension keyword in the model may be hiding a replaceable 1654 // The extension keyword in the model may be hiding a replaceable
1655 // non-extension keyword. Look for it. 1655 // non-extension keyword. Look for it.
1656 for (const auto& turl : template_urls_) { 1656 for (const auto& turl : template_urls_) {
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 2474
2475 if (most_recently_intalled_default) { 2475 if (most_recently_intalled_default) {
2476 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 2476 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
2477 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); 2477 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION);
2478 default_search_manager_.SetExtensionControlledDefaultSearchEngine( 2478 default_search_manager_.SetExtensionControlledDefaultSearchEngine(
2479 most_recently_intalled_default->data()); 2479 most_recently_intalled_default->data());
2480 } else { 2480 } else {
2481 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); 2481 default_search_manager_.ClearExtensionControlledDefaultSearchEngine();
2482 } 2482 }
2483 } 2483 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698