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

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: 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(Profile* profile){ 27 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile){
13 base::FilePath path = profile->GetPath(); 28 base::FilePath path = profile->GetPath();
14 path = path.Append(chrome::kWebDataFilename); 29 path = path.Append(chrome::kWebDataFilename);
15 web_data_service_ = new WebDataService(); 30 web_data_service_ = new WebDataService(base::Bind(&ProfileErrorCallback));
16 web_data_service_->Init(path); 31 web_data_service_->Init(path);
17 } 32 }
18 33
19 // For testing. 34 // For testing.
20 WebDataServiceWrapper::WebDataServiceWrapper() { 35 WebDataServiceWrapper::WebDataServiceWrapper() {
21 } 36 }
22 37
23 WebDataServiceWrapper::~WebDataServiceWrapper() { 38 WebDataServiceWrapper::~WebDataServiceWrapper() {
24 web_data_service_ = NULL; 39 web_data_service_ = NULL;
25 } 40 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 125 }
111 126
112 ProfileKeyedService* 127 ProfileKeyedService*
113 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const { 128 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const {
114 return new WebDataServiceWrapper(profile); 129 return new WebDataServiceWrapper(profile);
115 } 130 }
116 131
117 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { 132 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
118 return true; 133 return true;
119 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698