| OLD | NEW |
| 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_data.h" | 5 #include "components/search_engines/template_url_data.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 | 12 |
| 13 TemplateURLData::TemplateURLData() | 13 TemplateURLData::TemplateURLData() |
| 14 : show_in_default_list(false), | 14 : show_in_default_list(false), |
| 15 safe_for_autoreplace(false), | 15 safe_for_autoreplace(false), |
| 16 id(0), | 16 id(0), |
| 17 date_created(base::Time::Now()), | 17 date_created(base::Time::Now()), |
| 18 last_modified(base::Time::Now()), | 18 last_modified(base::Time::Now()), |
| 19 created_by_policy(false), | 19 created_by_policy(false), |
| 20 usage_count(0), | 20 usage_count(0), |
| 21 prepopulate_id(0), | 21 prepopulate_id(0), |
| 22 sync_guid(base::GenerateGUID()), | 22 sync_guid(base::GenerateGUID()), |
| 23 keyword_(base::ASCIIToUTF16("dummy")), | 23 keyword_(base::ASCIIToUTF16("dummy")), |
| 24 url_("x") { | 24 url_("x") { |
| 25 } | 25 } |
| 26 | 26 |
| 27 TemplateURLData::TemplateURLData(const TemplateURLData& other) = default; |
| 28 |
| 27 TemplateURLData::~TemplateURLData() { | 29 TemplateURLData::~TemplateURLData() { |
| 28 } | 30 } |
| 29 | 31 |
| 30 void TemplateURLData::SetShortName(const base::string16& short_name) { | 32 void TemplateURLData::SetShortName(const base::string16& short_name) { |
| 31 DCHECK(!short_name.empty()); | 33 DCHECK(!short_name.empty()); |
| 32 | 34 |
| 33 // Remove tabs, carriage returns, and the like, as they can corrupt | 35 // Remove tabs, carriage returns, and the like, as they can corrupt |
| 34 // how the short name is displayed. | 36 // how the short name is displayed. |
| 35 short_name_ = base::CollapseWhitespace(short_name, true); | 37 short_name_ = base::CollapseWhitespace(short_name, true); |
| 36 } | 38 } |
| 37 | 39 |
| 38 void TemplateURLData::SetKeyword(const base::string16& keyword) { | 40 void TemplateURLData::SetKeyword(const base::string16& keyword) { |
| 39 DCHECK(!keyword.empty()); | 41 DCHECK(!keyword.empty()); |
| 40 | 42 |
| 41 // Case sensitive keyword matching is confusing. As such, we force all | 43 // Case sensitive keyword matching is confusing. As such, we force all |
| 42 // keywords to be lower case. | 44 // keywords to be lower case. |
| 43 keyword_ = base::i18n::ToLower(keyword); | 45 keyword_ = base::i18n::ToLower(keyword); |
| 44 } | 46 } |
| 45 | 47 |
| 46 void TemplateURLData::SetURL(const std::string& url) { | 48 void TemplateURLData::SetURL(const std::string& url) { |
| 47 DCHECK(!url.empty()); | 49 DCHECK(!url.empty()); |
| 48 url_ = url; | 50 url_ = url; |
| 49 } | 51 } |
| OLD | NEW |