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