Chromium Code Reviews| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 next_id_(kInvalidTemplateURLID + 1), | 299 next_id_(kInvalidTemplateURLID + 1), |
| 300 time_provider_(&base::Time::Now), | 300 time_provider_(&base::Time::Now), |
| 301 models_associated_(false), | 301 models_associated_(false), |
| 302 processing_syncer_changes_(false), | 302 processing_syncer_changes_(false), |
| 303 pending_synced_default_search_(false), | 303 pending_synced_default_search_(false), |
| 304 dsp_change_origin_(DSP_CHANGE_NOT_SYNC) { | 304 dsp_change_origin_(DSP_CHANGE_NOT_SYNC) { |
| 305 Init(initializers, count); | 305 Init(initializers, count); |
| 306 } | 306 } |
| 307 | 307 |
| 308 TemplateURLService::~TemplateURLService() { | 308 TemplateURLService::~TemplateURLService() { |
| 309 } | |
| 310 | |
| 311 void TemplateURLService::Shutdown() { | |
| 309 if (load_handle_) { | 312 if (load_handle_) { |
|
Peter Kasting
2013/04/12 22:32:17
Add a comment about why it's important to do this
| |
| 310 DCHECK(service_.get()); | 313 DCHECK(service_.get()); |
| 311 service_->CancelRequest(load_handle_); | 314 service_->CancelRequest(load_handle_); |
| 312 } | 315 } |
| 313 | 316 service_ = NULL; |
| 314 STLDeleteElements(&template_urls_); | 317 STLDeleteElements(&template_urls_); |
| 315 } | 318 } |
| 316 | 319 |
| 317 // static | 320 // static |
| 318 string16 TemplateURLService::GenerateKeyword(const GURL& url) { | 321 string16 TemplateURLService::GenerateKeyword(const GURL& url) { |
| 319 DCHECK(url.is_valid()); | 322 DCHECK(url.is_valid()); |
| 320 // Strip "www." off the front of the keyword; otherwise the keyword won't work | 323 // Strip "www." off the front of the keyword; otherwise the keyword won't work |
| 321 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . | 324 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . |
| 322 // Special case: if the host was exactly "www." (not sure this can happen but | 325 // Special case: if the host was exactly "www." (not sure this can happen but |
| 323 // perhaps with some weird intranet and custom DNS server?), ensure we at | 326 // perhaps with some weird intranet and custom DNS server?), ensure we at |
| (...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2482 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2485 // TODO(mpcomplete): If we allow editing extension keywords, then those |
| 2483 // should be persisted to disk and synced. | 2486 // should be persisted to disk and synced. |
| 2484 if (template_url->sync_guid().empty() && | 2487 if (template_url->sync_guid().empty() && |
| 2485 !template_url->IsExtensionKeyword()) { | 2488 !template_url->IsExtensionKeyword()) { |
| 2486 template_url->data_.sync_guid = base::GenerateGUID(); | 2489 template_url->data_.sync_guid = base::GenerateGUID(); |
| 2487 if (service_.get()) | 2490 if (service_.get()) |
| 2488 service_->UpdateKeyword(template_url->data()); | 2491 service_->UpdateKeyword(template_url->data()); |
| 2489 } | 2492 } |
| 2490 } | 2493 } |
| 2491 } | 2494 } |
| OLD | NEW |