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/environment.h" | 9 #include "base/environment.h" |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/protector/protector_service_factory.h" | 28 #include "chrome/browser/protector/protector_service_factory.h" |
29 #include "chrome/browser/protector/protector_utils.h" | 29 #include "chrome/browser/protector/protector_utils.h" |
30 #include "chrome/browser/rlz/rlz.h" | 30 #include "chrome/browser/rlz/rlz.h" |
31 #include "chrome/browser/search_engines/search_host_to_urls_map.h" | 31 #include "chrome/browser/search_engines/search_host_to_urls_map.h" |
32 #include "chrome/browser/search_engines/search_terms_data.h" | 32 #include "chrome/browser/search_engines/search_terms_data.h" |
33 #include "chrome/browser/search_engines/template_url.h" | 33 #include "chrome/browser/search_engines/template_url.h" |
34 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 34 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
35 #include "chrome/browser/search_engines/template_url_service_observer.h" | 35 #include "chrome/browser/search_engines/template_url_service_observer.h" |
36 #include "chrome/browser/search_engines/util.h" | 36 #include "chrome/browser/search_engines/util.h" |
37 #include "chrome/browser/sync/api/sync_change.h" | 37 #include "chrome/browser/sync/api/sync_change.h" |
| 38 #include "chrome/browser/webdata/web_data_service_factory.h" |
38 #include "chrome/common/chrome_notification_types.h" | 39 #include "chrome/common/chrome_notification_types.h" |
39 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
40 #include "chrome/common/env_vars.h" | 41 #include "chrome/common/env_vars.h" |
41 #include "chrome/common/extensions/extension.h" | 42 #include "chrome/common/extensions/extension.h" |
42 #include "chrome/common/guid.h" | 43 #include "chrome/common/guid.h" |
43 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
44 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
45 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
46 #include "net/base/net_util.h" | 47 #include "net/base/net_util.h" |
47 #include "sync/protocol/search_engine_specifics.pb.h" | 48 #include "sync/protocol/search_engine_specifics.pb.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 508 } |
508 | 509 |
509 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) { | 510 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) { |
510 model_observers_.RemoveObserver(observer); | 511 model_observers_.RemoveObserver(observer); |
511 } | 512 } |
512 | 513 |
513 void TemplateURLService::Load() { | 514 void TemplateURLService::Load() { |
514 if (loaded_ || load_handle_) | 515 if (loaded_ || load_handle_) |
515 return; | 516 return; |
516 | 517 |
517 if (!service_.get()) | 518 if (!service_.get()) { |
518 service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); | 519 service_ = WebDataServiceFactory::GetForProfile(profile_, |
| 520 Profile::EXPLICIT_ACCESS); |
| 521 } |
519 | 522 |
520 if (service_.get()) { | 523 if (service_.get()) { |
521 load_handle_ = service_->GetKeywords(this); | 524 load_handle_ = service_->GetKeywords(this); |
522 } else { | 525 } else { |
523 ChangeToLoadedState(); | 526 ChangeToLoadedState(); |
524 NotifyLoaded(); | 527 NotifyLoaded(); |
525 } | 528 } |
526 } | 529 } |
527 | 530 |
528 void TemplateURLService::OnWebDataServiceRequestDone( | 531 void TemplateURLService::OnWebDataServiceRequestDone( |
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 // TODO(mpcomplete): If we allow editing extension keywords, then those | 1973 // TODO(mpcomplete): If we allow editing extension keywords, then those |
1971 // should be persisted to disk and synced. | 1974 // should be persisted to disk and synced. |
1972 if (template_url->sync_guid().empty() && | 1975 if (template_url->sync_guid().empty() && |
1973 !template_url->IsExtensionKeyword()) { | 1976 !template_url->IsExtensionKeyword()) { |
1974 template_url->data_.sync_guid = guid::GenerateGUID(); | 1977 template_url->data_.sync_guid = guid::GenerateGUID(); |
1975 if (service_.get()) | 1978 if (service_.get()) |
1976 service_->UpdateKeyword(*template_url); | 1979 service_->UpdateKeyword(*template_url); |
1977 } | 1980 } |
1978 } | 1981 } |
1979 } | 1982 } |
OLD | NEW |