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

Side by Side Diff: chrome/browser/webdata/web_data_service_factory.cc

Issue 12780012: Move UI dependency from WebDataService to WebDataServiceFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing 'explicit' on constructor, fix win unit test. Created 7 years, 9 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/webdata/web_data_service_factory.h" 5 #include "chrome/browser/webdata/web_data_service_factory.h"
6 6
7 #include "base/bind.h"
7 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
8 #include "chrome/browser/profiles/profile_dependency_manager.h" 9 #include "chrome/browser/profiles/profile_dependency_manager.h"
10 #include "chrome/browser/ui/profile_error_dialog.h"
9 #include "chrome/browser/webdata/autofill_web_data_service_impl.h" 11 #include "chrome/browser/webdata/autofill_web_data_service_impl.h"
10 #include "chrome/common/chrome_constants.h" 12 #include "chrome/common/chrome_constants.h"
13 #include "grit/chromium_strings.h"
14 #include "grit/generated_resources.h"
15
16 namespace {
17
18 // Callback to show error dialog on profile load error.
19 void ProfileErrorCallback(sql::InitStatus status) {
20 ShowProfileErrorDialog(
21 (status == sql::INIT_FAILURE) ?
22 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR);
23 }
24
25 } // namespace
11 26
12 WebDataServiceWrapper::WebDataServiceWrapper() {} 27 WebDataServiceWrapper::WebDataServiceWrapper() {}
13 28
14 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { 29 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) {
15 base::FilePath path = profile->GetPath(); 30 base::FilePath path = profile->GetPath();
16 path = path.Append(chrome::kWebDataFilename); 31 path = path.Append(chrome::kWebDataFilename);
17 web_data_service_ = new WebDataService(); 32 web_data_service_ = new WebDataService(base::Bind(&ProfileErrorCallback));
18 web_data_service_->Init(path); 33 web_data_service_->Init(path);
19 } 34 }
20 35
21 WebDataServiceWrapper::~WebDataServiceWrapper() { 36 WebDataServiceWrapper::~WebDataServiceWrapper() {
22 } 37 }
23 38
24 void WebDataServiceWrapper::Shutdown() { 39 void WebDataServiceWrapper::Shutdown() {
25 web_data_service_->ShutdownOnUIThread(); 40 web_data_service_->ShutdownOnUIThread();
26 web_data_service_ = NULL; 41 web_data_service_ = NULL;
27 } 42 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 123 }
109 124
110 ProfileKeyedService* 125 ProfileKeyedService*
111 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const { 126 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const {
112 return new WebDataServiceWrapper(profile); 127 return new WebDataServiceWrapper(profile);
113 } 128 }
114 129
115 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { 130 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
116 return true; 131 return true;
117 } 132 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service_base.cc ('k') | chrome/browser/webdata/web_data_service_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698