| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // Remove the scheme. | 339 // Remove the scheme. |
| 339 base::string16 result(base::i18n::ToLower(keyword)); | 340 base::string16 result(base::i18n::ToLower(keyword)); |
| 340 base::TrimWhitespace(result, base::TRIM_ALL, &result); | 341 base::TrimWhitespace(result, base::TRIM_ALL, &result); |
| 341 url_parse::Component scheme_component; | 342 url_parse::Component scheme_component; |
| 342 if (url_parse::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), | 343 if (url_parse::ExtractScheme(base::UTF16ToUTF8(keyword).c_str(), |
| 343 static_cast<int>(keyword.length()), | 344 static_cast<int>(keyword.length()), |
| 344 &scheme_component)) { | 345 &scheme_component)) { |
| 345 // If the scheme isn't "http" or "https", bail. The user isn't trying to | 346 // If the scheme isn't "http" or "https", bail. The user isn't trying to |
| 346 // type a web address, but rather an FTP, file:, or other scheme URL, or a | 347 // type a web address, but rather an FTP, file:, or other scheme URL, or a |
| 347 // search query with some sort of initial operator (e.g. "site:"). | 348 // search query with some sort of initial operator (e.g. "site:"). |
| 348 if (result.compare(0, scheme_component.end(), | 349 if (result.compare( |
| 349 base::ASCIIToUTF16(content::kHttpScheme)) && | 350 0, scheme_component.end(), base::ASCIIToUTF16(net::kHttpScheme)) && |
| 350 result.compare(0, scheme_component.end(), | 351 result.compare( |
| 351 base::ASCIIToUTF16(content::kHttpsScheme))) | 352 0, scheme_component.end(), base::ASCIIToUTF16(net::kHttpsScheme))) |
| 352 return base::string16(); | 353 return base::string16(); |
| 353 | 354 |
| 354 // Include trailing ':'. | 355 // Include trailing ':'. |
| 355 result.erase(0, scheme_component.end() + 1); | 356 result.erase(0, scheme_component.end() + 1); |
| 356 // Many schemes usually have "//" after them, so strip it too. | 357 // Many schemes usually have "//" after them, so strip it too. |
| 357 const base::string16 after_scheme(base::ASCIIToUTF16("//")); | 358 const base::string16 after_scheme(base::ASCIIToUTF16("//")); |
| 358 if (result.compare(0, after_scheme.length(), after_scheme) == 0) | 359 if (result.compare(0, after_scheme.length(), after_scheme) == 0) |
| 359 result.erase(0, after_scheme.length()); | 360 result.erase(0, after_scheme.length()); |
| 360 } | 361 } |
| 361 | 362 |
| (...skipping 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2754 new_dse = *i; | 2755 new_dse = *i; |
| 2755 break; | 2756 break; |
| 2756 } | 2757 } |
| 2757 } | 2758 } |
| 2758 } | 2759 } |
| 2759 } | 2760 } |
| 2760 if (!new_dse) | 2761 if (!new_dse) |
| 2761 new_dse = FindNewDefaultSearchProvider(); | 2762 new_dse = FindNewDefaultSearchProvider(); |
| 2762 SetDefaultSearchProviderNoNotify(new_dse); | 2763 SetDefaultSearchProviderNoNotify(new_dse); |
| 2763 } | 2764 } |
| OLD | NEW |