| 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/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/profiles/incognito_helpers.h" | 14 #include "chrome/browser/profiles/incognito_helpers.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/startup_task_runner_service.h" | 16 #include "chrome/browser/profiles/startup_task_runner_service.h" |
| 17 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" | 17 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" |
| 18 #include "chrome/browser/undo/bookmark_undo_service.h" | 18 #include "chrome/browser/undo/bookmark_undo_service.h" |
| 19 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 19 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "components/bookmarks/browser/bookmark_model.h" | 22 #include "components/bookmarks/browser/bookmark_model.h" |
| 23 #include "components/bookmarks/common/bookmark_pref_names.h" | 23 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 24 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 24 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 25 #include "components/omnibox/omnibox_field_trial.h" | |
| 26 #include "components/pref_registry/pref_registry_syncable.h" | 25 #include "components/pref_registry/pref_registry_syncable.h" |
| 27 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 28 | 27 |
| 29 // static | 28 // static |
| 30 BookmarkModel* BookmarkModelFactory::GetForProfile(Profile* profile) { | 29 BookmarkModel* BookmarkModelFactory::GetForProfile(Profile* profile) { |
| 31 return static_cast<BookmarkModel*>( | 30 return static_cast<BookmarkModel*>( |
| 32 GetInstance()->GetServiceForBrowserContext(profile, true)); | 31 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 33 } | 32 } |
| 34 | 33 |
| 35 // static | 34 // static |
| (...skipping 16 matching lines...) Expand all Loading... |
| 52 } | 51 } |
| 53 | 52 |
| 54 BookmarkModelFactory::~BookmarkModelFactory() { | 53 BookmarkModelFactory::~BookmarkModelFactory() { |
| 55 } | 54 } |
| 56 | 55 |
| 57 KeyedService* BookmarkModelFactory::BuildServiceInstanceFor( | 56 KeyedService* BookmarkModelFactory::BuildServiceInstanceFor( |
| 58 content::BrowserContext* context) const { | 57 content::BrowserContext* context) const { |
| 59 Profile* profile = static_cast<Profile*>(context); | 58 Profile* profile = static_cast<Profile*>(context); |
| 60 ChromeBookmarkClient* bookmark_client = | 59 ChromeBookmarkClient* bookmark_client = |
| 61 ChromeBookmarkClientFactory::GetForProfile(profile); | 60 ChromeBookmarkClientFactory::GetForProfile(profile); |
| 62 BookmarkModel* bookmark_model = new BookmarkModel( | 61 BookmarkModel* bookmark_model = new BookmarkModel(bookmark_client); |
| 63 bookmark_client, OmniboxFieldTrial::BookmarksIndexURLsValue()); | |
| 64 bookmark_client->Init(bookmark_model); | 62 bookmark_client->Init(bookmark_model); |
| 65 bookmark_model->Load(profile->GetPrefs(), | 63 bookmark_model->Load(profile->GetPrefs(), |
| 66 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | 64 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), |
| 67 profile->GetPath(), | 65 profile->GetPath(), |
| 68 StartupTaskRunnerServiceFactory::GetForProfile(profile) | 66 StartupTaskRunnerServiceFactory::GetForProfile(profile) |
| 69 ->GetBookmarkTaskRunner(), | 67 ->GetBookmarkTaskRunner(), |
| 70 content::BrowserThread::GetMessageLoopProxyForThread( | 68 content::BrowserThread::GetMessageLoopProxyForThread( |
| 71 content::BrowserThread::UI)); | 69 content::BrowserThread::UI)); |
| 72 #if !defined(OS_ANDROID) | 70 #if !defined(OS_ANDROID) |
| 73 bool register_bookmark_undo_service_as_observer = true; | 71 bool register_bookmark_undo_service_as_observer = true; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 99 } | 97 } |
| 100 | 98 |
| 101 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( | 99 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( |
| 102 content::BrowserContext* context) const { | 100 content::BrowserContext* context) const { |
| 103 return chrome::GetBrowserContextRedirectedInIncognito(context); | 101 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 104 } | 102 } |
| 105 | 103 |
| 106 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { | 104 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { |
| 107 return true; | 105 return true; |
| 108 } | 106 } |
| OLD | NEW |