| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 13 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
| 14 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 14 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
| 15 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" | 15 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" |
| 16 #include "chrome/browser/profiles/incognito_helpers.h" | 16 #include "chrome/browser/profiles/incognito_helpers.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 18 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/features.h" | |
| 21 #include "components/bookmarks/browser/bookmark_model.h" | 20 #include "components/bookmarks/browser/bookmark_model.h" |
| 22 #include "components/bookmarks/browser/bookmark_utils.h" | 21 #include "components/bookmarks/browser/bookmark_utils.h" |
| 23 #include "components/bookmarks/browser/startup_task_runner_service.h" | 22 #include "components/bookmarks/browser/startup_task_runner_service.h" |
| 24 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 23 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 25 #include "components/prefs/pref_service.h" | 24 #include "components/prefs/pref_service.h" |
| 26 #include "components/undo/bookmark_undo_service.h" | 25 #include "components/undo/bookmark_undo_service.h" |
| 27 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 28 | 27 |
| 29 using bookmarks::BookmarkModel; | 28 using bookmarks::BookmarkModel; |
| 30 | 29 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 Profile* profile = Profile::FromBrowserContext(context); | 63 Profile* profile = Profile::FromBrowserContext(context); |
| 65 BookmarkModel* bookmark_model = | 64 BookmarkModel* bookmark_model = |
| 66 new BookmarkModel(base::MakeUnique<ChromeBookmarkClient>( | 65 new BookmarkModel(base::MakeUnique<ChromeBookmarkClient>( |
| 67 profile, ManagedBookmarkServiceFactory::GetForProfile(profile))); | 66 profile, ManagedBookmarkServiceFactory::GetForProfile(profile))); |
| 68 bookmark_model->Load(profile->GetPrefs(), profile->GetPath(), | 67 bookmark_model->Load(profile->GetPrefs(), profile->GetPath(), |
| 69 StartupTaskRunnerServiceFactory::GetForProfile(profile) | 68 StartupTaskRunnerServiceFactory::GetForProfile(profile) |
| 70 ->GetBookmarkTaskRunner(), | 69 ->GetBookmarkTaskRunner(), |
| 71 content::BrowserThread::GetTaskRunnerForThread( | 70 content::BrowserThread::GetTaskRunnerForThread( |
| 72 content::BrowserThread::UI)); | 71 content::BrowserThread::UI)); |
| 73 bool register_bookmark_undo_service_as_observer = true; | 72 bool register_bookmark_undo_service_as_observer = true; |
| 74 #if !BUILDFLAG(ANDROID_JAVA_UI) | 73 #if !defined(OS_ANDROID) |
| 75 register_bookmark_undo_service_as_observer = | 74 register_bookmark_undo_service_as_observer = |
| 76 base::CommandLine::ForCurrentProcess()->HasSwitch( | 75 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 77 switches::kEnableBookmarkUndo); | 76 switches::kEnableBookmarkUndo); |
| 78 #endif // !BUILDFLAG(ANDROID_JAVA_UI) | 77 #endif // !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 | 80 |
| 82 return bookmark_model; | 81 return bookmark_model; |
| 83 } | 82 } |
| 84 | 83 |
| 85 void BookmarkModelFactory::RegisterProfilePrefs( | 84 void BookmarkModelFactory::RegisterProfilePrefs( |
| 86 user_prefs::PrefRegistrySyncable* registry) { | 85 user_prefs::PrefRegistrySyncable* registry) { |
| 87 bookmarks::RegisterProfilePrefs(registry); | 86 bookmarks::RegisterProfilePrefs(registry); |
| 88 } | 87 } |
| 89 | 88 |
| 90 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( | 89 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( |
| 91 content::BrowserContext* context) const { | 90 content::BrowserContext* context) const { |
| 92 return chrome::GetBrowserContextRedirectedInIncognito(context); | 91 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 93 } | 92 } |
| 94 | 93 |
| 95 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { | 94 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { |
| 96 return true; | 95 return true; |
| 97 } | 96 } |
| OLD | NEW |