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" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 profile, OmniboxFieldTrial::BookmarksIndexURLsValue()); | 58 profile, OmniboxFieldTrial::BookmarksIndexURLsValue()); |
59 bookmark_client->model()->Load( | 59 bookmark_client->model()->Load( |
60 profile->GetPrefs(), | 60 profile->GetPrefs(), |
61 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | 61 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), |
62 profile->GetPath(), | 62 profile->GetPath(), |
63 StartupTaskRunnerServiceFactory::GetForProfile(profile) | 63 StartupTaskRunnerServiceFactory::GetForProfile(profile) |
64 ->GetBookmarkTaskRunner(), | 64 ->GetBookmarkTaskRunner(), |
65 content::BrowserThread::GetMessageLoopProxyForThread( | 65 content::BrowserThread::GetMessageLoopProxyForThread( |
66 content::BrowserThread::UI)); | 66 content::BrowserThread::UI)); |
67 #if !defined(OS_ANDROID) | 67 #if !defined(OS_ANDROID) |
68 if (CommandLine::ForCurrentProcess()->HasSwitch( | 68 bool register_bookmark_undo_service_as_observer = true; |
69 switches::kEnableBookmarkUndo)) { | 69 #if !defined(OS_IOS) |
| 70 register_bookmark_undo_service_as_observer = |
| 71 CommandLine::ForCurrentProcess()->HasSwitch( |
| 72 switches::kEnableBookmarkUndo); |
| 73 #endif // !defined(OS_IOS) |
| 74 if (register_bookmark_undo_service_as_observer) { |
70 bookmark_client->model()->AddObserver( | 75 bookmark_client->model()->AddObserver( |
71 BookmarkUndoServiceFactory::GetForProfile(profile)); | 76 BookmarkUndoServiceFactory::GetForProfile(profile)); |
72 } | 77 } |
73 #endif // !defined(OS_ANDROID) | 78 #endif // !defined(OS_ANDROID) |
74 return bookmark_client; | 79 return bookmark_client; |
75 } | 80 } |
76 | 81 |
77 void BookmarkModelFactory::RegisterProfilePrefs( | 82 void BookmarkModelFactory::RegisterProfilePrefs( |
78 user_prefs::PrefRegistrySyncable* registry) { | 83 user_prefs::PrefRegistrySyncable* registry) { |
79 // Don't sync this, as otherwise, due to a limitation in sync, it | 84 // Don't sync this, as otherwise, due to a limitation in sync, it |
80 // will cause a deadlock (see http://crbug.com/97955). If we truly | 85 // will cause a deadlock (see http://crbug.com/97955). If we truly |
81 // want to sync the expanded state of folders, it should be part of | 86 // want to sync the expanded state of folders, it should be part of |
82 // bookmark sync itself (i.e., a property of the sync folder nodes). | 87 // bookmark sync itself (i.e., a property of the sync folder nodes). |
83 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, | 88 registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes, |
84 new base::ListValue, | 89 new base::ListValue, |
85 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 90 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
86 } | 91 } |
87 | 92 |
88 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( | 93 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( |
89 content::BrowserContext* context) const { | 94 content::BrowserContext* context) const { |
90 return chrome::GetBrowserContextRedirectedInIncognito(context); | 95 return chrome::GetBrowserContextRedirectedInIncognito(context); |
91 } | 96 } |
92 | 97 |
93 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { | 98 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { |
94 return true; | 99 return true; |
95 } | 100 } |
OLD | NEW |