Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: chrome/browser/search_engines/template_url_service.cc

Issue 9949024: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-base Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 491 }
491 492
492 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) { 493 void TemplateURLService::RemoveObserver(TemplateURLServiceObserver* observer) {
493 model_observers_.RemoveObserver(observer); 494 model_observers_.RemoveObserver(observer);
494 } 495 }
495 496
496 void TemplateURLService::Load() { 497 void TemplateURLService::Load() {
497 if (loaded_ || load_handle_) 498 if (loaded_ || load_handle_)
498 return; 499 return;
499 500
500 if (!service_.get()) 501 if (!service_.get()) {
501 service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); 502 service_ = WebDataServiceFactory::GetForProfile(profile_,
503 Profile::EXPLICIT_ACCESS);
504 }
502 505
503 if (service_.get()) { 506 if (service_.get()) {
504 load_handle_ = service_->GetKeywords(this); 507 load_handle_ = service_->GetKeywords(this);
505 } else { 508 } else {
506 ChangeToLoadedState(); 509 ChangeToLoadedState();
507 NotifyLoaded(); 510 NotifyLoaded();
508 } 511 }
509 } 512 }
510 513
511 void TemplateURLService::OnWebDataServiceRequestDone( 514 void TemplateURLService::OnWebDataServiceRequestDone(
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 i != template_urls->end(); ++i) { 1917 i != template_urls->end(); ++i) {
1915 TemplateURL* template_url = *i; 1918 TemplateURL* template_url = *i;
1916 DCHECK(template_url); 1919 DCHECK(template_url);
1917 if (template_url->sync_guid().empty()) { 1920 if (template_url->sync_guid().empty()) {
1918 template_url->data_.sync_guid = guid::GenerateGUID(); 1921 template_url->data_.sync_guid = guid::GenerateGUID();
1919 if (service_.get()) 1922 if (service_.get())
1920 service_->UpdateKeyword(*template_url); 1923 service_->UpdateKeyword(*template_url);
1921 } 1924 }
1922 } 1925 }
1923 } 1926 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698