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