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 28 matching lines...) Expand all Loading... |
39 #include "chrome/browser/webdata/web_data_service.h" | 39 #include "chrome/browser/webdata/web_data_service.h" |
40 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
41 #include "chrome/common/env_vars.h" | 41 #include "chrome/common/env_vars.h" |
42 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" | 42 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" |
43 #include "chrome/common/net/url_fixer_upper.h" | 43 #include "chrome/common/net/url_fixer_upper.h" |
44 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
45 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
46 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
47 #include "extensions/common/constants.h" | 47 #include "extensions/common/constants.h" |
48 #include "net/base/net_util.h" | 48 #include "net/base/net_util.h" |
| 49 #include "net/base/url_constants.h" |
49 #include "sync/api/sync_change.h" | 50 #include "sync/api/sync_change.h" |
50 #include "sync/api/sync_error_factory.h" | 51 #include "sync/api/sync_error_factory.h" |
51 #include "sync/protocol/search_engine_specifics.pb.h" | 52 #include "sync/protocol/search_engine_specifics.pb.h" |
52 #include "sync/protocol/sync.pb.h" | 53 #include "sync/protocol/sync.pb.h" |
53 #include "ui/base/l10n/l10n_util.h" | 54 #include "ui/base/l10n/l10n_util.h" |
54 | 55 |
55 typedef SearchHostToURLsMap::TemplateURLSet TemplateURLSet; | 56 typedef SearchHostToURLsMap::TemplateURLSet TemplateURLSet; |
56 typedef TemplateURLService::SyncDataMap SyncDataMap; | 57 typedef TemplateURLService::SyncDataMap SyncDataMap; |
57 | 58 |
58 namespace { | 59 namespace { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // Remove the scheme. | 338 // Remove the scheme. |
338 base::string16 result(base::i18n::ToLower(keyword)); | 339 base::string16 result(base::i18n::ToLower(keyword)); |
339 base::TrimWhitespace(result, base::TRIM_ALL, &result); | 340 base::TrimWhitespace(result, base::TRIM_ALL, &result); |
340 url_parse::Component scheme_component; | 341 url_parse::Component scheme_component; |
341 if (url_parse::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), | 342 if (url_parse::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), |
342 static_cast<int>(keyword.length()), | 343 static_cast<int>(keyword.length()), |
343 &scheme_component)) { | 344 &scheme_component)) { |
344 // If the scheme isn't "http" or "https", bail. The user isn't trying to | 345 // If the scheme isn't "http" or "https", bail. The user isn't trying to |
345 // type a web address, but rather an FTP, file:, or other scheme URL, or a | 346 // type a web address, but rather an FTP, file:, or other scheme URL, or a |
346 // search query with some sort of initial operator (e.g. "site:"). | 347 // search query with some sort of initial operator (e.g. "site:"). |
347 if (result.compare(0, scheme_component.end(), | 348 if (result.compare( |
348 base::ASCIIToUTF16(content::kHttpScheme)) && | 349 0, scheme_component.end(), base::ASCIIToUTF16(net::kHttpScheme)) && |
349 result.compare(0, scheme_component.end(), | 350 result.compare( |
350 base::ASCIIToUTF16(content::kHttpsScheme))) | 351 0, scheme_component.end(), base::ASCIIToUTF16(net::kHttpsScheme))) |
351 return base::string16(); | 352 return base::string16(); |
352 | 353 |
353 // Include trailing ':'. | 354 // Include trailing ':'. |
354 result.erase(0, scheme_component.end() + 1); | 355 result.erase(0, scheme_component.end() + 1); |
355 // Many schemes usually have "//" after them, so strip it too. | 356 // Many schemes usually have "//" after them, so strip it too. |
356 const base::string16 after_scheme(base::ASCIIToUTF16("//")); | 357 const base::string16 after_scheme(base::ASCIIToUTF16("//")); |
357 if (result.compare(0, after_scheme.length(), after_scheme) == 0) | 358 if (result.compare(0, after_scheme.length(), after_scheme) == 0) |
358 result.erase(0, after_scheme.length()); | 359 result.erase(0, after_scheme.length()); |
359 } | 360 } |
360 | 361 |
(...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2747 new_dse = *i; | 2748 new_dse = *i; |
2748 break; | 2749 break; |
2749 } | 2750 } |
2750 } | 2751 } |
2751 } | 2752 } |
2752 } | 2753 } |
2753 if (!new_dse) | 2754 if (!new_dse) |
2754 new_dse = FindNewDefaultSearchProvider(); | 2755 new_dse = FindNewDefaultSearchProvider(); |
2755 SetDefaultSearchProviderNoNotify(new_dse); | 2756 SetDefaultSearchProviderNoNotify(new_dse); |
2756 } | 2757 } |
OLD | NEW |