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 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 default_search_manager_.SetUserSelectedDefaultSearchEngine(data); | 1560 default_search_manager_.SetUserSelectedDefaultSearchEngine(data); |
1561 } | 1561 } |
1562 } | 1562 } |
1563 | 1563 |
1564 // Request a server check for the correct Google URL if Google is the | 1564 // Request a server check for the correct Google URL if Google is the |
1565 // default search engine and not in headless mode. | 1565 // default search engine and not in headless mode. |
1566 TemplateURL* default_search_provider = GetDefaultSearchProvider(); | 1566 TemplateURL* default_search_provider = GetDefaultSearchProvider(); |
1567 if (profile_ && default_search_provider && | 1567 if (profile_ && default_search_provider && |
1568 default_search_provider->HasGoogleBaseURLs()) { | 1568 default_search_provider->HasGoogleBaseURLs()) { |
1569 scoped_ptr<base::Environment> env(base::Environment::Create()); | 1569 scoped_ptr<base::Environment> env(base::Environment::Create()); |
1570 if (!env->HasVar(env_vars::kHeadless)) | 1570 if (!env->HasVar(env_vars::kHeadless)) { |
1571 GoogleURLTracker::RequestServerCheck(profile_, false); | 1571 GoogleURLTracker* tracker = |
| 1572 GoogleURLTrackerFactory::GetForProfile(profile_); |
| 1573 if (tracker) |
| 1574 tracker->RequestServerCheck(false); |
| 1575 } |
1572 } | 1576 } |
1573 } | 1577 } |
1574 | 1578 |
1575 void TemplateURLService::RemoveFromMaps(TemplateURL* template_url) { | 1579 void TemplateURLService::RemoveFromMaps(TemplateURL* template_url) { |
1576 const base::string16& keyword = template_url->keyword(); | 1580 const base::string16& keyword = template_url->keyword(); |
1577 DCHECK_NE(0U, keyword_to_template_map_.count(keyword)); | 1581 DCHECK_NE(0U, keyword_to_template_map_.count(keyword)); |
1578 if (keyword_to_template_map_[keyword] == template_url) { | 1582 if (keyword_to_template_map_[keyword] == template_url) { |
1579 // We need to check whether the keyword can now be provided by another | 1583 // We need to check whether the keyword can now be provided by another |
1580 // TemplateURL. See the comments in AddToMaps() for more information on | 1584 // TemplateURL. See the comments in AddToMaps() for more information on |
1581 // extension keywords and how they can coexist with non-extension keywords. | 1585 // extension keywords and how they can coexist with non-extension keywords. |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 default_search_provider_->sync_guid()); | 2061 default_search_provider_->sync_guid()); |
2058 } | 2062 } |
2059 | 2063 |
2060 } | 2064 } |
2061 | 2065 |
2062 default_search_provider_source_ = source; | 2066 default_search_provider_source_ = source; |
2063 | 2067 |
2064 bool changed = default_search_provider_ != previous_default_search_engine; | 2068 bool changed = default_search_provider_ != previous_default_search_engine; |
2065 | 2069 |
2066 if (profile_ && changed && default_search_provider_ && | 2070 if (profile_ && changed && default_search_provider_ && |
2067 default_search_provider_->HasGoogleBaseURLs()) | 2071 default_search_provider_->HasGoogleBaseURLs()) { |
2068 GoogleURLTracker::RequestServerCheck(profile_, false); | 2072 GoogleURLTracker* tracker = |
| 2073 GoogleURLTrackerFactory::GetForProfile(profile_); |
| 2074 if (tracker) |
| 2075 tracker->RequestServerCheck(false); |
| 2076 } |
2069 | 2077 |
2070 NotifyObservers(); | 2078 NotifyObservers(); |
2071 | 2079 |
2072 return changed; | 2080 return changed; |
2073 } | 2081 } |
2074 | 2082 |
2075 bool TemplateURLService::AddNoNotify(TemplateURL* template_url, | 2083 bool TemplateURLService::AddNoNotify(TemplateURL* template_url, |
2076 bool newly_adding) { | 2084 bool newly_adding) { |
2077 DCHECK(template_url); | 2085 DCHECK(template_url); |
2078 | 2086 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2517 | 2525 |
2518 if (most_recently_intalled_default) { | 2526 if (most_recently_intalled_default) { |
2519 base::AutoReset<DefaultSearchChangeOrigin> change_origin( | 2527 base::AutoReset<DefaultSearchChangeOrigin> change_origin( |
2520 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); | 2528 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); |
2521 default_search_manager_.SetExtensionControlledDefaultSearchEngine( | 2529 default_search_manager_.SetExtensionControlledDefaultSearchEngine( |
2522 most_recently_intalled_default->data()); | 2530 most_recently_intalled_default->data()); |
2523 } else { | 2531 } else { |
2524 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); | 2532 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); |
2525 } | 2533 } |
2526 } | 2534 } |
OLD | NEW |