| 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 if (load_handle_) { | 302 if (load_handle_) { |
| 303 DCHECK(service_.get()); | 303 DCHECK(service_.get()); |
| 304 service_->CancelRequest(load_handle_); | 304 service_->CancelRequest(load_handle_); |
| 305 } | 305 } |
| 306 | 306 |
| 307 STLDeleteElements(&template_urls_); | 307 STLDeleteElements(&template_urls_); |
| 308 } | 308 } |
| 309 | 309 |
| 310 // static | 310 // static |
| 311 string16 TemplateURLService::GenerateKeyword(const GURL& url) { | 311 string16 TemplateURLService::GenerateKeyword(const GURL& url) { |
| 312 DCHECK(url.is_valid()); | |
| 313 // Strip "www." off the front of the keyword; otherwise the keyword won't work | 312 // Strip "www." off the front of the keyword; otherwise the keyword won't work |
| 314 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . | 313 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . |
| 315 // Special case: if the host was exactly "www." (not sure this can happen but | 314 // Special case: if the host was exactly "www." (not sure this can happen but |
| 316 // perhaps with some weird intranet and custom DNS server?), ensure we at | 315 // perhaps with some weird intranet and custom DNS server?), ensure we at |
| 317 // least don't return the empty string. | 316 // least don't return the empty string. |
| 318 string16 keyword(net::StripWWW(UTF8ToUTF16(url.host()))); | 317 string16 keyword(net::StripWWW(UTF8ToUTF16(url.host()))); |
| 319 return keyword.empty() ? ASCIIToUTF16("www") : keyword; | 318 return keyword.empty() ? ASCIIToUTF16("www") : keyword; |
| 320 } | 319 } |
| 321 | 320 |
| 322 // static | 321 // static |
| (...skipping 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2522 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2521 // TODO(mpcomplete): If we allow editing extension keywords, then those |
| 2523 // should be persisted to disk and synced. | 2522 // should be persisted to disk and synced. |
| 2524 if (template_url->sync_guid().empty() && | 2523 if (template_url->sync_guid().empty() && |
| 2525 !template_url->IsExtensionKeyword()) { | 2524 !template_url->IsExtensionKeyword()) { |
| 2526 template_url->data_.sync_guid = base::GenerateGUID(); | 2525 template_url->data_.sync_guid = base::GenerateGUID(); |
| 2527 if (service_.get()) | 2526 if (service_.get()) |
| 2528 service_->UpdateKeyword(template_url->data()); | 2527 service_->UpdateKeyword(template_url->data()); |
| 2529 } | 2528 } |
| 2530 } | 2529 } |
| 2531 } | 2530 } |
| OLD | NEW |