| 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/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 TemplateURLData data(default_from_prefs->data()); | 605 TemplateURLData data(default_from_prefs->data()); |
| 606 data.created_by_policy = true; | 606 data.created_by_policy = true; |
| 607 data.id = kInvalidTemplateURLID; | 607 data.id = kInvalidTemplateURLID; |
| 608 TemplateURL* managed_default = new TemplateURL(profile_, data); | 608 TemplateURL* managed_default = new TemplateURL(profile_, data); |
| 609 AddNoNotify(managed_default, true); | 609 AddNoNotify(managed_default, true); |
| 610 default_search_provider = managed_default; | 610 default_search_provider = managed_default; |
| 611 } | 611 } |
| 612 } | 612 } |
| 613 // Note that this saves the default search provider to prefs. | 613 // Note that this saves the default search provider to prefs. |
| 614 if (!default_search_provider || | 614 if (!default_search_provider || |
| 615 !default_search_provider->IsExtensionKeyword()) | 615 (!default_search_provider->IsExtensionKeyword() && |
| 616 default_search_provider->SupportsReplacement())) |
| 616 SetDefaultSearchProviderNoNotify(default_search_provider); | 617 SetDefaultSearchProviderNoNotify(default_search_provider); |
| 617 } else { | 618 } else { |
| 618 // If we had a managed default, replace it with the synced default if | 619 // If we had a managed default, replace it with the synced default if |
| 619 // applicable, or the first provider of the list. | 620 // applicable, or the first provider of the list. |
| 620 const TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider(); | 621 const TemplateURL* synced_default = GetPendingSyncedDefaultSearchProvider(); |
| 621 if (synced_default) { | 622 if (synced_default) { |
| 622 default_search_provider = synced_default; | 623 default_search_provider = synced_default; |
| 623 pending_synced_default_search_ = false; | 624 pending_synced_default_search_ = false; |
| 624 } else if (database_specified_a_default && | 625 } else if (database_specified_a_default && |
| 625 default_search_provider == NULL) { | 626 default_search_provider == NULL) { |
| (...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2003 // TODO(mpcomplete): If we allow editing extension keywords, then those |
| 2003 // should be persisted to disk and synced. | 2004 // should be persisted to disk and synced. |
| 2004 if (template_url->sync_guid().empty() && | 2005 if (template_url->sync_guid().empty() && |
| 2005 !template_url->IsExtensionKeyword()) { | 2006 !template_url->IsExtensionKeyword()) { |
| 2006 template_url->data_.sync_guid = guid::GenerateGUID(); | 2007 template_url->data_.sync_guid = guid::GenerateGUID(); |
| 2007 if (service_.get()) | 2008 if (service_.get()) |
| 2008 service_->UpdateKeyword(*template_url); | 2009 service_->UpdateKeyword(*template_url); |
| 2009 } | 2010 } |
| 2010 } | 2011 } |
| 2011 } | 2012 } |
| OLD | NEW |