Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / chrome / browser / undo / bookmark_undo_service_factory.cc
blob3f08dfcc15dfead000241f5068b2dce9124599ca
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ios/chrome/browser/undo/bookmark_undo_service_factory.h"
7 #include "base/memory/singleton.h"
8 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
9 #include "components/undo/bookmark_undo_service.h"
10 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
12 namespace ios {
14 // static
15 BookmarkUndoService* BookmarkUndoServiceFactory::GetForBrowserState(
16 ios::ChromeBrowserState* browser_state) {
17 return static_cast<BookmarkUndoService*>(
18 GetInstance()->GetServiceForBrowserState(browser_state, true));
21 // static
22 BookmarkUndoService* BookmarkUndoServiceFactory::GetForBrowserStateIfExists(
23 ios::ChromeBrowserState* browser_state) {
24 return static_cast<BookmarkUndoService*>(
25 GetInstance()->GetServiceForBrowserState(browser_state, false));
28 // static
29 BookmarkUndoServiceFactory* BookmarkUndoServiceFactory::GetInstance() {
30 return base::Singleton<BookmarkUndoServiceFactory>::get();
33 BookmarkUndoServiceFactory::BookmarkUndoServiceFactory()
34 : BrowserStateKeyedServiceFactory(
35 "BookmarkUndoService",
36 BrowserStateDependencyManager::GetInstance()) {
39 BookmarkUndoServiceFactory::~BookmarkUndoServiceFactory() {
42 scoped_ptr<KeyedService> BookmarkUndoServiceFactory::BuildServiceInstanceFor(
43 web::BrowserState* context) const {
44 return make_scoped_ptr(new BookmarkUndoService);
47 } // namespace ios