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

Side by Side Diff: chrome/browser/bookmarks/bookmark_model_factory.cc

Issue 1233673002: Fix componentization of chrome/browser/bookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
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/bookmarks/bookmark_model_factory.h" 5 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/deferred_sequenced_task_runner.h" 8 #include "base/deferred_sequenced_task_runner.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
13 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" 13 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
14 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" 14 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h"
15 #include "chrome/browser/profiles/incognito_helpers.h" 15 #include "chrome/browser/profiles/incognito_helpers.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/undo/bookmark_undo_service_factory.h" 17 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "components/bookmarks/browser/bookmark_model.h" 20 #include "components/bookmarks/browser/bookmark_model.h"
21 #include "components/bookmarks/browser/startup_task_runner_service.h" 21 #include "components/bookmarks/browser/startup_task_runner_service.h"
22 #include "components/bookmarks/common/bookmark_pref_names.h" 22 #include "components/bookmarks/common/bookmark_pref_names.h"
23 #include "components/keyed_service/content/browser_context_dependency_manager.h" 23 #include "components/keyed_service/content/browser_context_dependency_manager.h"
24 #include "components/pref_registry/pref_registry_syncable.h"
25 #include "components/undo/bookmark_undo_service.h" 24 #include "components/undo/bookmark_undo_service.h"
26 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
27 26
28 using bookmarks::BookmarkModel; 27 using bookmarks::BookmarkModel;
29 28
30 // static 29 // static
31 BookmarkModel* BookmarkModelFactory::GetForProfile(Profile* profile) { 30 BookmarkModel* BookmarkModelFactory::GetForProfile(Profile* profile) {
32 return static_cast<BookmarkModel*>( 31 return static_cast<BookmarkModel*>(
33 GetInstance()->GetServiceForBrowserContext(profile, true)); 32 GetInstance()->GetServiceForBrowserContext(profile, true));
34 } 33 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 base::CommandLine::ForCurrentProcess()->HasSwitch( 75 base::CommandLine::ForCurrentProcess()->HasSwitch(
77 switches::kEnableBookmarkUndo); 76 switches::kEnableBookmarkUndo);
78 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) 77 #endif // !defined(OS_IOS) && !defined(OS_ANDROID)
79 if (register_bookmark_undo_service_as_observer) 78 if (register_bookmark_undo_service_as_observer)
80 BookmarkUndoServiceFactory::GetForProfile(profile)->Start(bookmark_model); 79 BookmarkUndoServiceFactory::GetForProfile(profile)->Start(bookmark_model);
81 return bookmark_model; 80 return bookmark_model;
82 } 81 }
83 82
84 void BookmarkModelFactory::RegisterProfilePrefs( 83 void BookmarkModelFactory::RegisterProfilePrefs(
85 user_prefs::PrefRegistrySyncable* registry) { 84 user_prefs::PrefRegistrySyncable* registry) {
86 // Don't sync this, as otherwise, due to a limitation in sync, it 85 BookmarkModel::RegisterProfilePrefs(registry);
87 // will cause a deadlock (see http://crbug.com/97955). If we truly
88 // want to sync the expanded state of folders, it should be part of
89 // bookmark sync itself (i.e., a property of the sync folder nodes).
90 registry->RegisterListPref(bookmarks::prefs::kBookmarkEditorExpandedNodes,
91 new base::ListValue);
92 registry->RegisterListPref(bookmarks::prefs::kManagedBookmarks);
93 registry->RegisterListPref(bookmarks::prefs::kSupervisedBookmarks);
94 } 86 }
95 87
96 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( 88 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse(
97 content::BrowserContext* context) const { 89 content::BrowserContext* context) const {
98 return chrome::GetBrowserContextRedirectedInIncognito(context); 90 return chrome::GetBrowserContextRedirectedInIncognito(context);
99 } 91 }
100 92
101 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { 93 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const {
102 return true; 94 return true;
103 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698