 Chromium Code Reviews
 Chromium Code Reviews Issue 1899433002:
  Update flags used by offline pages and bookmarks  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1899433002:
  Update flags used by offline pages and bookmarks  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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/values.h" | 10 #include "base/values.h" | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 } | 52 } | 
| 53 | 53 | 
| 54 BookmarkModelFactory::BookmarkModelFactory() | 54 BookmarkModelFactory::BookmarkModelFactory() | 
| 55 : BrowserContextKeyedServiceFactory( | 55 : BrowserContextKeyedServiceFactory( | 
| 56 "BookmarkModel", | 56 "BookmarkModel", | 
| 57 BrowserContextDependencyManager::GetInstance()) { | 57 BrowserContextDependencyManager::GetInstance()) { | 
| 58 DependsOn(BookmarkUndoServiceFactory::GetInstance()); | 58 DependsOn(BookmarkUndoServiceFactory::GetInstance()); | 
| 59 DependsOn(ManagedBookmarkServiceFactory::GetInstance()); | 59 DependsOn(ManagedBookmarkServiceFactory::GetInstance()); | 
| 60 DependsOn(StartupTaskRunnerServiceFactory::GetInstance()); | 60 DependsOn(StartupTaskRunnerServiceFactory::GetInstance()); | 
| 61 #if BUILDFLAG(ANDROID_JAVA_UI) | 61 #if BUILDFLAG(ANDROID_JAVA_UI) | 
| 62 if (offline_pages::IsOfflinePagesEnabled()) | 62 if (offline_pages::IsOfflineBookmarksEnabled()) | 
| 
fgorski
2016/04/18 17:09:37
Same idea as above. (And applies below)
 
jianli
2016/04/18 21:17:00
Done.
 | |
| 63 DependsOn(offline_pages::OfflinePageModelFactory::GetInstance()); | 63 DependsOn(offline_pages::OfflinePageModelFactory::GetInstance()); | 
| 64 #endif | 64 #endif | 
| 65 } | 65 } | 
| 66 | 66 | 
| 67 BookmarkModelFactory::~BookmarkModelFactory() { | 67 BookmarkModelFactory::~BookmarkModelFactory() { | 
| 68 } | 68 } | 
| 69 | 69 | 
| 70 KeyedService* BookmarkModelFactory::BuildServiceInstanceFor( | 70 KeyedService* BookmarkModelFactory::BuildServiceInstanceFor( | 
| 71 content::BrowserContext* context) const { | 71 content::BrowserContext* context) const { | 
| 72 Profile* profile = Profile::FromBrowserContext(context); | 72 Profile* profile = Profile::FromBrowserContext(context); | 
| 73 BookmarkModel* bookmark_model = | 73 BookmarkModel* bookmark_model = | 
| 74 new BookmarkModel(make_scoped_ptr(new ChromeBookmarkClient( | 74 new BookmarkModel(make_scoped_ptr(new ChromeBookmarkClient( | 
| 75 profile, ManagedBookmarkServiceFactory::GetForProfile(profile)))); | 75 profile, ManagedBookmarkServiceFactory::GetForProfile(profile)))); | 
| 76 bookmark_model->Load(profile->GetPrefs(), | 76 bookmark_model->Load(profile->GetPrefs(), | 
| 77 profile->GetPath(), | 77 profile->GetPath(), | 
| 78 StartupTaskRunnerServiceFactory::GetForProfile(profile) | 78 StartupTaskRunnerServiceFactory::GetForProfile(profile) | 
| 79 ->GetBookmarkTaskRunner(), | 79 ->GetBookmarkTaskRunner(), | 
| 80 content::BrowserThread::GetMessageLoopProxyForThread( | 80 content::BrowserThread::GetMessageLoopProxyForThread( | 
| 81 content::BrowserThread::UI)); | 81 content::BrowserThread::UI)); | 
| 82 bool register_bookmark_undo_service_as_observer = true; | 82 bool register_bookmark_undo_service_as_observer = true; | 
| 83 #if !BUILDFLAG(ANDROID_JAVA_UI) | 83 #if !BUILDFLAG(ANDROID_JAVA_UI) | 
| 84 register_bookmark_undo_service_as_observer = | 84 register_bookmark_undo_service_as_observer = | 
| 85 base::CommandLine::ForCurrentProcess()->HasSwitch( | 85 base::CommandLine::ForCurrentProcess()->HasSwitch( | 
| 86 switches::kEnableBookmarkUndo); | 86 switches::kEnableBookmarkUndo); | 
| 87 #endif // !BUILDFLAG(ANDROID_JAVA_UI) | 87 #endif // !BUILDFLAG(ANDROID_JAVA_UI) | 
| 88 if (register_bookmark_undo_service_as_observer) | 88 if (register_bookmark_undo_service_as_observer) | 
| 89 BookmarkUndoServiceFactory::GetForProfile(profile)->Start(bookmark_model); | 89 BookmarkUndoServiceFactory::GetForProfile(profile)->Start(bookmark_model); | 
| 90 | 90 | 
| 91 #if BUILDFLAG(ANDROID_JAVA_UI) | 91 #if BUILDFLAG(ANDROID_JAVA_UI) | 
| 92 if (offline_pages::IsOfflinePagesEnabled()) { | 92 if (offline_pages::IsOfflineBookmarksEnabled()) { | 
| 93 // This observer will delete itself when BookmarkModelDeleted is called. | 93 // This observer will delete itself when BookmarkModelDeleted is called. | 
| 94 bookmark_model->AddObserver(new offline_pages::OfflinePageBookmarkBridge( | 94 bookmark_model->AddObserver(new offline_pages::OfflinePageBookmarkBridge( | 
| 95 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile), | 95 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile), | 
| 96 bookmark_model)); | 96 bookmark_model)); | 
| 97 } | 97 } | 
| 98 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 98 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 
| 99 | 99 | 
| 100 return bookmark_model; | 100 return bookmark_model; | 
| 101 } | 101 } | 
| 102 | 102 | 
| 103 void BookmarkModelFactory::RegisterProfilePrefs( | 103 void BookmarkModelFactory::RegisterProfilePrefs( | 
| 104 user_prefs::PrefRegistrySyncable* registry) { | 104 user_prefs::PrefRegistrySyncable* registry) { | 
| 105 bookmarks::RegisterProfilePrefs(registry); | 105 bookmarks::RegisterProfilePrefs(registry); | 
| 106 } | 106 } | 
| 107 | 107 | 
| 108 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( | 108 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( | 
| 109 content::BrowserContext* context) const { | 109 content::BrowserContext* context) const { | 
| 110 return chrome::GetBrowserContextRedirectedInIncognito(context); | 110 return chrome::GetBrowserContextRedirectedInIncognito(context); | 
| 111 } | 111 } | 
| 112 | 112 | 
| 113 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { | 113 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { | 
| 114 return true; | 114 return true; | 
| 115 } | 115 } | 
| OLD | NEW |