| OLD | NEW |
| 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/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 BookmarkModelFactory::~BookmarkModelFactory() { | 57 BookmarkModelFactory::~BookmarkModelFactory() { |
| 58 } | 58 } |
| 59 | 59 |
| 60 KeyedService* BookmarkModelFactory::BuildServiceInstanceFor( | 60 KeyedService* BookmarkModelFactory::BuildServiceInstanceFor( |
| 61 content::BrowserContext* context) const { | 61 content::BrowserContext* context) const { |
| 62 Profile* profile = Profile::FromBrowserContext(context); | 62 Profile* profile = Profile::FromBrowserContext(context); |
| 63 BookmarkModel* bookmark_model = | 63 BookmarkModel* bookmark_model = |
| 64 new BookmarkModel(base::WrapUnique(new ChromeBookmarkClient( | 64 new BookmarkModel(base::WrapUnique(new ChromeBookmarkClient( |
| 65 profile, ManagedBookmarkServiceFactory::GetForProfile(profile)))); | 65 profile, ManagedBookmarkServiceFactory::GetForProfile(profile)))); |
| 66 bookmark_model->Load(profile->GetPrefs(), | 66 bookmark_model->Load(profile->GetPrefs(), profile->GetPath(), |
| 67 profile->GetPath(), | |
| 68 StartupTaskRunnerServiceFactory::GetForProfile(profile) | 67 StartupTaskRunnerServiceFactory::GetForProfile(profile) |
| 69 ->GetBookmarkTaskRunner(), | 68 ->GetBookmarkTaskRunner(), |
| 70 content::BrowserThread::GetMessageLoopProxyForThread( | 69 content::BrowserThread::GetTaskRunnerForThread( |
| 71 content::BrowserThread::UI)); | 70 content::BrowserThread::UI)); |
| 72 bool register_bookmark_undo_service_as_observer = true; | 71 bool register_bookmark_undo_service_as_observer = true; |
| 73 #if !BUILDFLAG(ANDROID_JAVA_UI) | 72 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 74 register_bookmark_undo_service_as_observer = | 73 register_bookmark_undo_service_as_observer = |
| 75 base::CommandLine::ForCurrentProcess()->HasSwitch( | 74 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 76 switches::kEnableBookmarkUndo); | 75 switches::kEnableBookmarkUndo); |
| 77 #endif // !BUILDFLAG(ANDROID_JAVA_UI) | 76 #endif // !BUILDFLAG(ANDROID_JAVA_UI) |
| 78 if (register_bookmark_undo_service_as_observer) | 77 if (register_bookmark_undo_service_as_observer) |
| 79 BookmarkUndoServiceFactory::GetForProfile(profile)->Start(bookmark_model); | 78 BookmarkUndoServiceFactory::GetForProfile(profile)->Start(bookmark_model); |
| 80 | 79 |
| 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 bookmarks::RegisterProfilePrefs(registry); | 85 bookmarks::RegisterProfilePrefs(registry); |
| 87 } | 86 } |
| 88 | 87 |
| 89 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( | 88 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( |
| 90 content::BrowserContext* context) const { | 89 content::BrowserContext* context) const { |
| 91 return chrome::GetBrowserContextRedirectedInIncognito(context); | 90 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 92 } | 91 } |
| 93 | 92 |
| 94 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { | 93 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { |
| 95 return true; | 94 return true; |
| 96 } | 95 } |
| OLD | NEW |