bookmark_model_factory.h revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_FACTORY_H_
6#define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_FACTORY_H_
7
8#include "base/basictypes.h"
9#include "base/compiler_specific.h"
10#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
11
12template <typename T> struct DefaultSingletonTraits;
13
14class BookmarkModel;
15class ChromeBookmarkClient;
16class Profile;
17
18// Singleton that owns all BookmarkModel and associates them with Profiles.
19class BookmarkModelFactory : public BrowserContextKeyedServiceFactory {
20 public:
21  static BookmarkModel* GetForProfile(Profile* profile);
22
23  static BookmarkModel* GetForProfileIfExists(Profile* profile);
24
25  static ChromeBookmarkClient* GetChromeBookmarkClientForProfile(
26      Profile* profile);
27
28  static BookmarkModelFactory* GetInstance();
29
30 private:
31  friend struct DefaultSingletonTraits<BookmarkModelFactory>;
32
33  BookmarkModelFactory();
34  virtual ~BookmarkModelFactory();
35
36  // BrowserContextKeyedServiceFactory:
37  virtual KeyedService* BuildServiceInstanceFor(
38      content::BrowserContext* context) const OVERRIDE;
39  virtual void RegisterProfilePrefs(
40      user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
41  virtual content::BrowserContext* GetBrowserContextToUse(
42      content::BrowserContext* context) const OVERRIDE;
43  virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
44
45  DISALLOW_COPY_AND_ASSIGN(BookmarkModelFactory);
46};
47
48#endif  // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_FACTORY_H_
49