0

Move ServiceAccessType into //components/keyed_service

The ServiceAccessType is only used when interacting with
KeyedServiceFactories so move it into the keyed_service
components.

Turn the enumeration into a "class enum" so that the value
names don't leak into the global namespace.

Fix client code and add missing #include after changing the
chrome/browser/profiles/profile.h #include into forward
declaration in the KeyedServiceFactories headers.

Usage of the enumeration was fixed using tools/git/mffr.py.

BUG=419366

Review URL: https://codereview.chromium.org/839193002

Cr-Commit-Position: refs/heads/master@{#310979}
This commit is contained in:
sdefresne
2015-01-10 02:10:04 -08:00
committed by Commit bot
parent 6fd7d48e8d
commit e9ea3c2ead
132 changed files with 428 additions and 419 deletions
chrome
browser
android
autocomplete
autofill
bookmarks
browsing_data
custom_home_pages_table_model.cc
download
extensions
favicon
history
importer
jumplist_win.cc
notifications
password_manager
predictors
prerender
profile_resetter
profiles
safe_browsing
search_engines
signin
ssl
supervised_user
sync
ui
webdata
test
components

@@ -116,7 +116,7 @@ jboolean FaviconHelper::GetLocalFaviconImageForURL(
return false;
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS);
profile, ServiceAccessType::EXPLICIT_ACCESS);
DCHECK(favicon_service);
if (!favicon_service)
return false;
@@ -152,7 +152,7 @@ void FaviconHelper::GetLargestRawFaviconForUrl(
return;
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS);
profile, ServiceAccessType::EXPLICIT_ACCESS);
DCHECK(favicon_service);
if (!favicon_service)
return;

@@ -1168,13 +1168,13 @@ ChromeBrowserProvider::ChromeBrowserProvider(JNIEnv* env, jobject obj)
bookmark_model_ = BookmarkModelFactory::GetForProfile(profile_);
top_sites_ = profile_->GetTopSites();
favicon_service_ = FaviconServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS),
profile_, ServiceAccessType::EXPLICIT_ACCESS),
service_.reset(new AndroidHistoryProviderService(profile_));
// Registers the notifications we are interested.
bookmark_model_->AddObserver(this);
history_service_observer_.Add(
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS));
history_service_observer_.Add(HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS));
notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
content::NotificationService::AllSources());
notification_registrar_.Add(this,

@@ -18,6 +18,7 @@
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/web_application_info.h"
@@ -385,7 +386,7 @@ void ShortcutHelper::AddShortcutUsingFavicon() {
icon_types.push_back(favicon_base::TOUCH_PRECOMPOSED_ICON |
favicon_base::TOUCH_ICON);
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS);
profile, ServiceAccessType::EXPLICIT_ACCESS);
// Using favicon if its size is not smaller than platform required size,
// otherwise using the largest icon among all avaliable icons.

@@ -129,9 +129,8 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MAYBE_Autocomplete) {
WaitForTemplateURLServiceToLoad();
// The results depend on the history backend being loaded. Make sure it is
// loaded so that the autocomplete results are consistent.
ui_test_utils::WaitForHistoryToLoad(
HistoryServiceFactory::GetForProfile(browser()->profile(),
Profile::EXPLICIT_ACCESS));
ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS));
LocationBar* location_bar = GetLocationBar();
OmniboxView* omnibox_view = location_bar->GetOmniboxView();

@@ -66,15 +66,16 @@ void ChromeAutocompleteProviderClient::Classify(
}
history::URLDatabase* ChromeAutocompleteProviderClient::InMemoryDatabase() {
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
return history_service ? history_service->InMemoryDatabase() : NULL;
}
void ChromeAutocompleteProviderClient::DeleteMatchingURLsForKeywordFromHistory(
history::KeywordID keyword_id,
const base::string16& term) {
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)
HistoryServiceFactory::GetForProfile(profile_,
ServiceAccessType::EXPLICIT_ACCESS)
->DeleteMatchingURLsForKeyword(keyword_id, term);
}

@@ -24,8 +24,8 @@ void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) {
DCHECK(profile_);
DCHECK(match.deletable);
HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* const history_service = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
// Delete the underlying URL along with all its visits from the history DB.
// The resulting HISTORY_URLS_DELETED notification will also cause all caches

@@ -116,8 +116,8 @@ void HistoryQuickProvider::DoAutocomplete() {
autocomplete_input_.parts().path.is_nonempty());
if (can_have_url_what_you_typed_match_first) {
HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(profile_,
Profile::EXPLICIT_ACCESS);
HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
// We expect HistoryService to be available. In case it's not,
// (e.g., due to Profile corruption) we let HistoryQuick provider
// completions (which may be available because it's a different
@@ -292,8 +292,8 @@ history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() {
if (index_for_testing_.get())
return index_for_testing_.get();
HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* const history_service = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (!history_service)
return NULL;

@@ -129,10 +129,9 @@ class HistoryQuickProviderTest : public testing::Test {
Profile* profile = static_cast<Profile*>(context);
return new TemplateURLService(
profile->GetPrefs(), make_scoped_ptr(new SearchTermsData), NULL,
scoped_ptr<TemplateURLServiceClient>(
new ChromeTemplateURLServiceClient(
HistoryServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS))),
scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient(
HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS))),
NULL, NULL, base::Closure());
}
@@ -186,9 +185,8 @@ void HistoryQuickProviderTest::SetUp() {
bookmarks::test::WaitForBookmarkModelToLoad(
BookmarkModelFactory::GetForProfile(profile_.get()));
profile_->BlockUntilHistoryIndexIsRefreshed();
history_service_ =
HistoryServiceFactory::GetForProfile(profile_.get(),
Profile::EXPLICIT_ACCESS);
history_service_ = HistoryServiceFactory::GetForProfile(
profile_.get(), ServiceAccessType::EXPLICIT_ACCESS);
EXPECT_TRUE(history_service_);
provider_ = new HistoryQuickProvider(profile_.get());
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(

@@ -528,8 +528,8 @@ void HistoryURLProvider::Start(const AutocompleteInput& input,
// We'll need the history service to run both passes, so try to obtain it.
if (!profile_)
return;
HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* const history_service = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (!history_service)
return;

@@ -175,10 +175,9 @@ class HistoryURLProviderTest : public testing::Test,
Profile* profile = static_cast<Profile*>(context);
return new TemplateURLService(
profile->GetPrefs(), make_scoped_ptr(new SearchTermsData), NULL,
scoped_ptr<TemplateURLServiceClient>(
new ChromeTemplateURLServiceClient(
HistoryServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS))),
scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient(
HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS))),
NULL, NULL, base::Closure());
}
@@ -259,7 +258,7 @@ bool HistoryURLProviderTest::SetUpImpl(bool no_db) {
}
profile_->GetPrefs()->SetString(prefs::kAcceptLanguages, "en-US,en,ko");
history_service_ = HistoryServiceFactory::GetForProfile(
profile_.get(), Profile::EXPLICIT_ACCESS);
profile_.get(), ServiceAccessType::EXPLICIT_ACCESS);
autocomplete_ = new HistoryURLProvider(this, profile_.get());
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(

@@ -441,9 +441,8 @@ void SearchProviderTest::QueryForInputAndWaitForFetcherResponses(
GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url,
base::string16 term,
int visit_count) {
HistoryService* history =
HistoryServiceFactory::GetForProfile(&profile_,
Profile::EXPLICIT_ACCESS);
HistoryService* history = HistoryServiceFactory::GetForProfile(
&profile_, ServiceAccessType::EXPLICIT_ACCESS);
GURL search(t_url->url_ref().ReplaceSearchTerms(
TemplateURLRef::SearchTermsArgs(term),
TemplateURLServiceFactory::GetForProfile(
@@ -739,9 +738,11 @@ TEST_F(SearchProviderTest, DontAutocompleteURLLikeTerms) {
ASCIIToUTF16("docs.google.com"), 1);
// Add the term as a url.
HistoryServiceFactory::GetForProfile(&profile_, Profile::EXPLICIT_ACCESS)->
AddPageWithDetails(GURL("http://docs.google.com"), base::string16(), 1, 1,
base::Time::Now(), false, history::SOURCE_BROWSED);
HistoryServiceFactory::GetForProfile(&profile_,
ServiceAccessType::EXPLICIT_ACCESS)
->AddPageWithDetails(GURL("http://docs.google.com"), base::string16(), 1,
1, base::Time::Now(), false,
history::SOURCE_BROWSED);
profile_.BlockUntilHistoryProcessesPendingRequests();
AutocompleteMatch wyt_match;

@@ -109,8 +109,8 @@ void ShortcutsProvider::DeleteMatch(const AutocompleteMatch& match) {
// Delete the match from the history DB. This will eventually result in a
// second call to DeleteShortcutsWithURL(), which is harmless.
HistoryService* const history_service =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* const history_service = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
DCHECK(history_service);
history_service->DeleteURL(url);
}

@@ -44,7 +44,7 @@ KeyedService* PersonalDataManagerFactory::BuildServiceInstanceFor(
PersonalDataManager* service =
new PersonalDataManager(g_browser_process->GetApplicationLocale());
service->Init(WebDataServiceFactory::GetAutofillWebDataForProfile(
profile, Profile::EXPLICIT_ACCESS),
profile, ServiceAccessType::EXPLICIT_ACCESS),
profile->GetPrefs(),
profile->IsOffTheRecord());
return service;

@@ -458,7 +458,7 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() {
URLFaviconMap::const_iterator iter = favicons_map_->find(url);
if (favicons_map_->end() == iter) {
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
favicon_service->GetRawFaviconForPageURL(
GURL(url),
favicon_base::FAVICON,

@@ -196,12 +196,12 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
const BookmarkNode* f1 = model->AddFolder(
model->bookmark_bar_node(), 0, f1_title);
model->AddURLWithCreationTimeAndMetaInfo(f1, 0, url1_title, url1, t1, NULL);
HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)->
AddPage(url1, base::Time::Now(), history::SOURCE_BROWSED);
FaviconServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)
->SetFavicons(url1,
url1_favicon,
favicon_base::FAVICON,
HistoryServiceFactory::GetForProfile(&profile,
ServiceAccessType::EXPLICIT_ACCESS)
->AddPage(url1, base::Time::Now(), history::SOURCE_BROWSED);
FaviconServiceFactory::GetForProfile(&profile,
ServiceAccessType::EXPLICIT_ACCESS)
->SetFavicons(url1, url1_favicon, favicon_base::FAVICON,
gfx::Image::CreateFrom1xBitmap(bitmap));
const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title);
model->AddURLWithCreationTimeAndMetaInfo(f2, 0, url2_title, url2, t2, NULL);
@@ -234,7 +234,8 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
run_loop.Run();
// Clear favicon so that it would be read from file.
FaviconServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)
FaviconServiceFactory::GetForProfile(&profile,
ServiceAccessType::EXPLICIT_ACCESS)
->SetFavicons(url1, url1_favicon, favicon_base::FAVICON, gfx::Image());
// Read the bookmarks back in.

@@ -102,8 +102,8 @@ ChromeBookmarkClient::GetFaviconImageForPageURL(
favicon_base::IconType type,
const favicon_base::FaviconImageCallback& callback,
base::CancelableTaskTracker* tracker) {
FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (!favicon_service)
return base::CancelableTaskTracker::kBadTaskId;
if (type == favicon_base::FAVICON) {

@@ -281,7 +281,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
if ((remove_mask & REMOVE_HISTORY) && may_delete_history) {
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (history_service) {
std::set<GURL> restrict_urls;
if (!remove_origin_.is_empty())
@@ -383,7 +383,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
// history, so clear them as well.
scoped_refptr<autofill::AutofillWebDataService> web_data_service =
WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (web_data_service.get()) {
waiting_for_clear_autofill_origin_urls_ = true;
web_data_service->RemoveOriginURLsModifiedBetween(
@@ -544,8 +544,8 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
if (remove_mask & REMOVE_PASSWORDS) {
content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords"));
password_manager::PasswordStore* password_store =
PasswordStoreFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)
.get();
PasswordStoreFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
if (password_store)
password_store->RemoveLoginsCreatedBetween(delete_begin_, delete_end_);
@@ -555,7 +555,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill"));
scoped_refptr<autofill::AutofillWebDataService> web_data_service =
WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (web_data_service.get()) {
waiting_for_clear_form_ = true;

@@ -383,7 +383,7 @@ class RemoveHistoryTester {
if (!profile->CreateHistoryService(true, false))
return false;
history_service_ = HistoryServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS);
profile, ServiceAccessType::EXPLICIT_ACCESS);
return true;
}

@@ -220,8 +220,8 @@ void CustomHomePagesTableModel::SetObserver(ui::TableModelObserver* observer) {
}
void CustomHomePagesTableModel::LoadTitle(Entry* entry) {
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (history_service) {
entry->task_id = history_service->QueryURL(
entry->url,

@@ -251,7 +251,7 @@ class DownloadsHistoryDataCollector {
bool WaitForDownloadInfo(
scoped_ptr<std::vector<history::DownloadRow> >* results) {
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
DCHECK(hs);
hs->QueryDownloads(
base::Bind(&DownloadsHistoryDataCollector::OnQueryDownloadsComplete,
@@ -1894,10 +1894,11 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, PRE_DownloadTest_History) {
HistoryObserver observer(browser()->profile());
DownloadAndWait(browser(), download_url);
observer.WaitForStored();
HistoryServiceFactory::GetForProfile(
browser()->profile(), Profile::IMPLICIT_ACCESS)->FlushForTest(
base::Bind(&base::MessageLoop::Quit,
base::Unretained(base::MessageLoop::current()->current())));
HistoryServiceFactory::GetForProfile(browser()->profile(),
ServiceAccessType::IMPLICIT_ACCESS)
->FlushForTest(base::Bind(
&base::MessageLoop::Quit,
base::Unretained(base::MessageLoop::current()->current())));
content::RunMessageLoop();
}

@@ -57,7 +57,7 @@ ChromeDownloadManagerDelegate* DownloadService::GetDownloadManagerDelegate() {
if (!profile_->IsOffTheRecord()) {
HistoryService* history = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
history->GetNextDownloadId(
manager_delegate_->GetDownloadIdReceiverCallback());
download_history_.reset(new DownloadHistory(

@@ -7,6 +7,7 @@
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
// static

@@ -592,7 +592,7 @@ DownloadTargetDeterminer::Result
// HistoryServiceFactory redirects incognito profiles to on-record
// profiles. There's no history for on-record profiles in unit_tests.
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::EXPLICIT_ACCESS);
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
if (history_service && download_->GetReferrerUrl().is_valid()) {
history_service->GetVisibleVisitCountToHost(

@@ -1088,8 +1088,8 @@ TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_VisitedReferrer) {
// midnight.
base::Time time_of_visit(
base::Time::Now().LocalMidnight() - base::TimeDelta::FromSeconds(10));
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile(), Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile(), ServiceAccessType::EXPLICIT_ACCESS);
ASSERT_TRUE(history_service);
history_service->AddPage(url, time_of_visit, history::SOURCE_BROWSED);

@@ -226,8 +226,8 @@ void BrowserContextKeyedAPIFactory<HistoryAPI>::DeclareFactoryDependencies() {
void HistoryAPI::OnListenerAdded(const EventListenerInfo& details) {
Profile* profile = Profile::FromBrowserContext(browser_context_);
history_event_router_.reset(new HistoryEventRouter(
profile,
HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS)));
profile, HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS)));
EventRouter::Get(browser_context_)->UnregisterObserver(this);
}
@@ -294,7 +294,7 @@ bool HistoryGetVisitsFunction::RunAsyncImpl() {
return false;
HistoryService* hs = HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::EXPLICIT_ACCESS);
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
hs->QueryURL(url,
true, // Retrieve full history of a URL.
base::Bind(&HistoryGetVisitsFunction::QueryComplete,
@@ -339,7 +339,7 @@ bool HistorySearchFunction::RunAsyncImpl() {
options.max_count = *params->query.max_results;
HistoryService* hs = HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::EXPLICIT_ACCESS);
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
hs->QueryHistory(search_text,
options,
base::Bind(&HistorySearchFunction::SearchComplete,
@@ -373,7 +373,7 @@ bool HistoryAddUrlFunction::RunAsync() {
return false;
HistoryService* hs = HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::EXPLICIT_ACCESS);
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
hs->AddPage(url, base::Time::Now(), history::SOURCE_EXTENSION);
SendResponse(true);
@@ -392,7 +392,7 @@ bool HistoryDeleteUrlFunction::RunAsync() {
return false;
HistoryService* hs = HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::EXPLICIT_ACCESS);
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
hs->DeleteURL(url);
// Also clean out from the activity log. If the activity log testing flag is
@@ -421,7 +421,7 @@ bool HistoryDeleteRangeFunction::RunAsyncImpl() {
std::set<GURL> restrict_urls;
HistoryService* hs = HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::EXPLICIT_ACCESS);
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
hs->ExpireHistoryBetween(
restrict_urls,
start_time,
@@ -451,7 +451,7 @@ bool HistoryDeleteAllFunction::RunAsyncImpl() {
std::set<GURL> restrict_urls;
HistoryService* hs = HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::EXPLICIT_ACCESS);
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
hs->ExpireHistoryBetween(
restrict_urls,
base::Time(), // Unbounded beginning...

@@ -246,7 +246,7 @@ ChromeManagementAPIDelegate::GenerateAppForLinkFunctionDelegate(
const std::string& title,
const GURL& launch_url) const {
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
Profile::FromBrowserContext(context), Profile::EXPLICIT_ACCESS);
Profile::FromBrowserContext(context), ServiceAccessType::EXPLICIT_ACCESS);
DCHECK(favicon_service);
ChromeAppForLinkDelegate* delegate = new ChromeAppForLinkDelegate;

@@ -17,8 +17,8 @@ ChromeFaviconClient::~ChromeFaviconClient() {
}
FaviconService* ChromeFaviconClient::GetFaviconService() {
return FaviconServiceFactory::GetForProfile(profile_,
Profile::EXPLICIT_ACCESS);
return FaviconServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
}
bool ChromeFaviconClient::IsBookmarked(const GURL& url) {

@@ -1517,7 +1517,7 @@ TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) {
profile, BuildHistoryService);
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile, Profile::IMPLICIT_ACCESS);
profile, ServiceAccessType::IMPLICIT_ACCESS);
FaviconTabHelper::CreateForWebContents(web_contents());
FaviconTabHelper* favicon_tab_helper =

@@ -78,9 +78,9 @@ std::vector<int> GetPixelSizesForFaviconScales(int size_in_dip) {
} // namespace
FaviconService::FaviconService(Profile* profile, FaviconClient* favicon_client)
: history_service_(
HistoryServiceFactory::GetForProfile(profile,
Profile::EXPLICIT_ACCESS)),
: history_service_(HistoryServiceFactory::GetForProfile(
profile,
ServiceAccessType::EXPLICIT_ACCESS)),
profile_(profile),
favicon_client_(favicon_client) {
}

@@ -10,15 +10,16 @@
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
// static
FaviconService* FaviconServiceFactory::GetForProfile(
Profile* profile, Profile::ServiceAccessType sat) {
FaviconService* FaviconServiceFactory::GetForProfile(Profile* profile,
ServiceAccessType sat) {
if (!profile->IsOffTheRecord()) {
return static_cast<FaviconService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
} else if (sat == Profile::EXPLICIT_ACCESS) {
} else if (sat == ServiceAccessType::EXPLICIT_ACCESS) {
// Profile must be OffTheRecord in this case.
return static_cast<FaviconService*>(
GetInstance()->GetServiceForBrowserContext(

@@ -6,13 +6,13 @@
#define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_FACTORY_H_
#include "base/memory/singleton.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/service_access_type.h"
template <typename T> struct DefaultSingletonTraits;
class Profile;
class FaviconService;
class Profile;
// Singleton that owns all FaviconService and associates them with
// Profiles.
@@ -20,8 +20,7 @@ class FaviconServiceFactory : public BrowserContextKeyedServiceFactory {
public:
// |access| defines what the caller plans to do with the service. See
// the ServiceAccessType definition in profile.h.
static FaviconService* GetForProfile(Profile* profile,
Profile::ServiceAccessType sat);
static FaviconService* GetForProfile(Profile* profile, ServiceAccessType sat);
static FaviconServiceFactory* GetInstance();

@@ -119,13 +119,13 @@ void FaviconTabHelper::SaveFavicon() {
// Make sure the page is in history, otherwise adding the favicon does
// nothing.
HistoryService* history = HistoryServiceFactory::GetForProfile(
profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
if (!history)
return;
history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle());
FaviconService* service = FaviconServiceFactory::GetForProfile(
profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
if (!service)
return;
const FaviconStatus& favicon(entry->GetFavicon());
@@ -147,7 +147,7 @@ void FaviconTabHelper::RemoveObserver(FaviconTabHelperObserver* observer) {
int FaviconTabHelper::StartDownload(const GURL& url, int max_image_size) {
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
if (favicon_service && favicon_service->WasUnableToDownloadFavicon(url)) {
DVLOG(1) << "Skip Failed FavIcon: " << url;
return 0;
@@ -231,7 +231,7 @@ void FaviconTabHelper::DidStartNavigationToPendingEntry(
if (reload_type != NavigationController::NO_RELOAD &&
!profile_->IsOffTheRecord()) {
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile_, Profile::IMPLICIT_ACCESS);
profile_, ServiceAccessType::IMPLICIT_ACCESS);
if (favicon_service) {
favicon_service->SetFaviconOutOfDateForPage(url);
if (reload_type == NavigationController::RELOAD_IGNORING_CACHE)
@@ -294,7 +294,7 @@ void FaviconTabHelper::DidDownloadFavicon(
if (bitmaps.empty() && http_status_code == 404) {
DVLOG(1) << "Failed to Download Favicon:" << image_url;
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS);
profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
if (favicon_service)
favicon_service->UnableToDownloadFavicon(image_url);
}

@@ -28,8 +28,8 @@ AndroidHistoryProviderService::QueryHistoryAndBookmarks(
const std::string& sort_order,
const QueryCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -56,8 +56,8 @@ AndroidHistoryProviderService::UpdateHistoryAndBookmarks(
const std::vector<base::string16>& selection_args,
const UpdateCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -82,8 +82,8 @@ AndroidHistoryProviderService::DeleteHistoryAndBookmarks(
const std::vector<base::string16>& selection_args,
const DeleteCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -106,8 +106,8 @@ AndroidHistoryProviderService::InsertHistoryAndBookmark(
const history::HistoryAndBookmarkRow& values,
const InsertCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -130,8 +130,8 @@ AndroidHistoryProviderService::DeleteHistory(
const std::vector<base::string16>& selection_args,
const DeleteCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -156,8 +156,8 @@ AndroidHistoryProviderService::MoveStatement(
int destination,
const MoveStatementCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -178,8 +178,8 @@ AndroidHistoryProviderService::MoveStatement(
void AndroidHistoryProviderService::CloseStatement(
history::AndroidStatement* statement) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
hs->ScheduleAndForget(HistoryService::PRIORITY_NORMAL,
&HistoryBackend::CloseStatement, statement);
@@ -193,8 +193,8 @@ AndroidHistoryProviderService::InsertSearchTerm(
const history::SearchRow& row,
const InsertCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -217,8 +217,8 @@ AndroidHistoryProviderService::UpdateSearchTerms(
const std::vector<base::string16>& selection_args,
const UpdateCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -243,8 +243,8 @@ AndroidHistoryProviderService::DeleteSearchTerms(
const std::vector<base::string16>& selection_args,
const DeleteCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -270,8 +270,8 @@ AndroidHistoryProviderService::QuerySearchTerms(
const std::string& sort_order,
const QueryCallback& callback,
base::CancelableTaskTracker* tracker) {
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
DCHECK(hs->thread_) << "History service being called after cleanup";
DCHECK(hs->thread_checker_.CalledOnValidThread());
@@ -296,8 +296,8 @@ AndroidHistoryProviderService::GetLargestRawFaviconForID(
favicon_base::FaviconID favicon_id,
const favicon_base::FaviconRawBitmapCallback& callback,
base::CancelableTaskTracker* tracker) {
FaviconService* fs =
FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
FaviconService* fs = FaviconServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
DCHECK(fs);
return fs->GetLargestRawFaviconForID(favicon_id, callback, tracker);
}

@@ -68,8 +68,8 @@ class SQLiteCursorTest : public testing::Test,
testing_profile_->CreateFaviconService();
ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false));
service_.reset(new AndroidHistoryProviderService(testing_profile_));
hs_ = HistoryServiceFactory::GetForProfile(testing_profile_,
Profile::EXPLICIT_ACCESS);
hs_ = HistoryServiceFactory::GetForProfile(
testing_profile_, ServiceAccessType::EXPLICIT_ACCESS);
}
virtual void TearDown() override {

@@ -86,9 +86,8 @@ class HistoryBrowserTest : public InProcessBrowserTest {
void WaitForHistoryBackendToRun() {
base::CancelableTaskTracker task_tracker;
scoped_ptr<history::HistoryDBTask> task(new WaitForHistoryTask());
HistoryService* history =
HistoryServiceFactory::GetForProfile(GetProfile(),
Profile::EXPLICIT_ACCESS);
HistoryService* history = HistoryServiceFactory::GetForProfile(
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
history->HistoryService::ScheduleDBTask(task.Pass(), &task_tracker);
content::RunMessageLoop();
}
@@ -120,12 +119,12 @@ IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabled) {
EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::EXPLICIT_ACCESS));
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::IMPLICIT_ACCESS));
GetProfile(), ServiceAccessType::IMPLICIT_ACCESS));
ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
browser()->profile(), Profile::EXPLICIT_ACCESS));
browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS));
ExpectEmptyHistory();
ui_test_utils::NavigateToURL(browser(), GetTestUrl());
@@ -143,12 +142,12 @@ IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryDisabled) {
GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, true);
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::EXPLICIT_ACCESS));
GetProfile(), ServiceAccessType::EXPLICIT_ACCESS));
EXPECT_FALSE(HistoryServiceFactory::GetForProfile(
GetProfile(), Profile::IMPLICIT_ACCESS));
GetProfile(), ServiceAccessType::IMPLICIT_ACCESS));
ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
browser()->profile(), Profile::EXPLICIT_ACCESS));
browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS));
ExpectEmptyHistory();
ui_test_utils::NavigateToURL(browser(), GetTestUrl());
@@ -162,7 +161,7 @@ IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabledThenDisabled) {
EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled));
ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
browser()->profile(), Profile::EXPLICIT_ACCESS));
browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS));
ui_test_utils::NavigateToURL(browser(), GetTestUrl());
WaitForHistoryBackendToRun();
@@ -192,7 +191,7 @@ IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryDisabledThenEnabled) {
GetPrefs()->SetBoolean(prefs::kSavingBrowserHistoryDisabled, true);
ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
browser()->profile(), Profile::EXPLICIT_ACCESS));
browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS));
ExpectEmptyHistory();
ui_test_utils::NavigateToURL(browser(), GetTestUrl());

@@ -12,16 +12,18 @@
#include "chrome/browser/history/chrome_history_client_factory.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/core/service_access_type.h"
// static
HistoryService* HistoryServiceFactory::GetForProfile(
Profile* profile, Profile::ServiceAccessType sat) {
HistoryService* HistoryServiceFactory::GetForProfile(Profile* profile,
ServiceAccessType sat) {
// If saving history is disabled, only allow explicit access.
if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
sat != Profile::EXPLICIT_ACCESS)
sat != ServiceAccessType::EXPLICIT_ACCESS)
return NULL;
return static_cast<HistoryService*>(
@@ -29,12 +31,12 @@ HistoryService* HistoryServiceFactory::GetForProfile(
}
// static
HistoryService*
HistoryServiceFactory::GetForProfileIfExists(
Profile* profile, Profile::ServiceAccessType sat) {
HistoryService* HistoryServiceFactory::GetForProfileIfExists(
Profile* profile,
ServiceAccessType sat) {
// If saving history is disabled, only allow explicit access.
if (profile->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
sat != Profile::EXPLICIT_ACCESS)
sat != ServiceAccessType::EXPLICIT_ACCESS)
return NULL;
return static_cast<HistoryService*>(

@@ -6,20 +6,20 @@
#define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_FACTORY_H_
#include "base/memory/singleton.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/service_access_type.h"
class HistoryService;
class Profile;
// Singleton that owns all HistoryService and associates them with
// Profiles.
class HistoryServiceFactory : public BrowserContextKeyedServiceFactory {
public:
static HistoryService* GetForProfile(
Profile* profile, Profile::ServiceAccessType sat);
static HistoryService* GetForProfile(Profile* profile, ServiceAccessType sat);
static HistoryService* GetForProfileIfExists(
Profile* profile, Profile::ServiceAccessType sat);
static HistoryService* GetForProfileIfExists(Profile* profile,
ServiceAccessType sat);
static HistoryService* GetForProfileWithoutCreating(
Profile* profile);

@@ -142,8 +142,8 @@ HistoryService* HistoryTabHelper::GetHistoryService() {
if (profile->IsOffTheRecord())
return NULL;
return HistoryServiceFactory::GetForProfile(profile,
Profile::IMPLICIT_ACCESS);
return HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::IMPLICIT_ACCESS);
}
void HistoryTabHelper::WebContentsDestroyed() {
@@ -153,8 +153,8 @@ void HistoryTabHelper::WebContentsDestroyed() {
if (profile->IsOffTheRecord())
return;
HistoryService* hs =
HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::IMPLICIT_ACCESS);
if (hs) {
NavigationEntry* entry = tab->GetController().GetLastCommittedEntry();
if (entry) {

@@ -310,9 +310,8 @@ void InMemoryURLIndex::OnCacheLoadDone(
// Restoring from the History DB -----------------------------------------------
void InMemoryURLIndex::ScheduleRebuildFromHistory() {
HistoryService* service =
HistoryServiceFactory::GetForProfile(profile_,
Profile::EXPLICIT_ACCESS);
HistoryService* service = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
service->ScheduleDBTask(
scoped_ptr<history::HistoryDBTask>(
new InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask(

@@ -208,7 +208,7 @@ void InMemoryURLIndexTest::SetUp() {
profile_.BlockUntilHistoryProcessesPendingRequests();
profile_.BlockUntilHistoryIndexIsRefreshed();
history_service_ = HistoryServiceFactory::GetForProfile(
&profile_, Profile::EXPLICIT_ACCESS);
&profile_, ServiceAccessType::EXPLICIT_ACCESS);
ASSERT_TRUE(history_service_);
HistoryBackend* backend = history_service_->history_backend_.get();
history_database_ = backend->db();

@@ -38,9 +38,8 @@ class RedirectTest : public InProcessBrowserTest {
RedirectTest() {}
std::vector<GURL> GetRedirects(const GURL& url) {
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(browser()->profile(),
Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS);
// Schedule a history query for redirects. The response will be sent
// asynchronously from the callback the history system uses to notify us

@@ -450,7 +450,7 @@ base::CancelableTaskTracker::TaskId TopSitesImpl::StartQueryForMostVisited() {
return base::CancelableTaskTracker::kBadTaskId;
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
// |hs| may be null during unit tests.
if (hs) {
return hs->QueryMostVisitedURLs(

@@ -240,8 +240,8 @@ class TopSitesImplTest : public HistoryUnitTestBase {
}
TestingProfile* profile() {return profile_.get();}
HistoryService* history_service() {
return HistoryServiceFactory::GetForProfile(profile_.get(),
Profile::EXPLICIT_ACCESS);
return HistoryServiceFactory::GetForProfile(
profile_.get(), ServiceAccessType::EXPLICIT_ACCESS);
}
MostVisitedURLList GetPrepopulatePages() {

@@ -87,20 +87,21 @@ bool ProfileWriter::TemplateURLServiceIsLoaded() const {
void ProfileWriter::AddPasswordForm(const autofill::PasswordForm& form) {
PasswordStoreFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS)->AddLogin(form);
profile_, ServiceAccessType::EXPLICIT_ACCESS)->AddLogin(form);
}
#if defined(OS_WIN)
void ProfileWriter::AddIE7PasswordInfo(const IE7PasswordInfo& info) {
WebDataServiceFactory::GetPasswordWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS)->AddIE7Login(info);
profile_, ServiceAccessType::EXPLICIT_ACCESS)->AddIE7Login(info);
}
#endif
void ProfileWriter::AddHistoryPage(const history::URLRows& page,
history::VisitSource visit_source) {
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)->
AddPagesWithDetails(page, visit_source);
HistoryServiceFactory::GetForProfile(profile_,
ServiceAccessType::EXPLICIT_ACCESS)
->AddPagesWithDetails(page, visit_source);
}
void ProfileWriter::AddHomepage(const GURL& home_page) {
@@ -233,8 +234,9 @@ void ProfileWriter::AddBookmarks(
void ProfileWriter::AddFavicons(
const std::vector<ImportedFaviconUsage>& favicons) {
FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)->
SetImportedFavicons(favicons);
FaviconServiceFactory::GetForProfile(profile_,
ServiceAccessType::EXPLICIT_ACCESS)
->SetImportedFavicons(favicons);
}
typedef std::map<std::string, TemplateURL*> HostPathMap;
@@ -335,7 +337,7 @@ void ProfileWriter::AddAutofillFormDataEntries(
const std::vector<autofill::AutofillEntry>& autofill_entries) {
scoped_refptr<autofill::AutofillWebDataService> web_data_service =
WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (web_data_service.get())
web_data_service->UpdateAutofillEntries(autofill_entries);
}

@@ -91,9 +91,8 @@ class ProfileWriterTest : public testing::Test {
}
void VerifyHistoryCount(Profile* profile) {
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile,
Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
history::QueryOptions options;
base::CancelableTaskTracker history_task_tracker;
history_service->QueryHistory(

@@ -468,8 +468,8 @@ void JumpList::StartLoadingFavicon() {
return;
}
FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
task_id_ = favicon_service->GetFaviconImageForPageURL(
url,
base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this)),

@@ -243,8 +243,8 @@ void MessageCenterSettingsController::GetNotifierList(
ContentSettingsForOneType settings;
DesktopNotificationProfileUtil::GetNotificationsSettings(profile, &settings);
FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
favicon_tracker_.reset(new base::CancelableTaskTracker());
patterns_.clear();
for (ContentSettingsForOneType::const_iterator iter = settings.begin();

@@ -266,9 +266,10 @@ password_manager::PasswordStore*
ChromePasswordManagerClient::GetPasswordStore() {
// Always use EXPLICIT_ACCESS as the password manager checks IsOffTheRecord
// itself when it shouldn't access the PasswordStore.
// TODO(gcasto): Is is safe to change this to Profile::IMPLICIT_ACCESS?
return PasswordStoreFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)
.get();
// TODO(gcasto): Is is safe to change this to
// ServiceAccessType::IMPLICIT_ACCESS?
return PasswordStoreFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
}
base::FieldTrial::Probability

@@ -17,6 +17,7 @@
#include "chrome/browser/password_manager/chrome_password_manager_client.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/password_manager/test_password_store_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/login/login_prompt.h"
#include "chrome/browser/ui/login/login_prompt_test_utils.h"
@@ -1071,8 +1072,8 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) {
password_manager::TestPasswordStore* password_store =
static_cast<password_manager::TestPasswordStore*>(
PasswordStoreFactory::GetForProfile(browser()->profile(),
Profile::IMPLICIT_ACCESS).get());
PasswordStoreFactory::GetForProfile(
browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
EXPECT_TRUE(password_store->IsEmpty());
@@ -1162,8 +1163,8 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoLastLoadGoodLastLoad) {
password_manager::TestPasswordStore* password_store =
static_cast<password_manager::TestPasswordStore*>(
PasswordStoreFactory::GetForProfile(browser()->profile(),
Profile::IMPLICIT_ACCESS).get());
PasswordStoreFactory::GetForProfile(
browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
EXPECT_TRUE(password_store->IsEmpty());
// Navigate to a page requiring HTTP auth. Wait for the tab to get the correct
@@ -1288,8 +1289,8 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
PromptWhenPasswordFormWithoutUsernameFieldSubmitted) {
password_manager::TestPasswordStore* password_store =
static_cast<password_manager::TestPasswordStore*>(
PasswordStoreFactory::GetForProfile(browser()->profile(),
Profile::IMPLICIT_ACCESS).get());
PasswordStoreFactory::GetForProfile(
browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
EXPECT_TRUE(password_store->IsEmpty());
@@ -1318,8 +1319,8 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
AutofillSuggetionsForPasswordFormWithoutUsernameField) {
password_manager::TestPasswordStore* password_store =
static_cast<password_manager::TestPasswordStore*>(
PasswordStoreFactory::GetForProfile(browser()->profile(),
Profile::IMPLICIT_ACCESS).get());
PasswordStoreFactory::GetForProfile(
browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
EXPECT_TRUE(password_store->IsEmpty());

@@ -11,6 +11,7 @@
#include "chrome/browser/password_manager/password_manager_util.h"
#include "chrome/browser/password_manager/sync_metrics.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/sync_start_util.h"
#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_constants.h"
@@ -89,8 +90,8 @@ void PasswordStoreService::Shutdown() {
// static
scoped_refptr<PasswordStore> PasswordStoreFactory::GetForProfile(
Profile* profile,
Profile::ServiceAccessType sat) {
if (sat == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) {
ServiceAccessType sat) {
if (sat == ServiceAccessType::IMPLICIT_ACCESS && profile->IsOffTheRecord()) {
NOTREACHED() << "This profile is OffTheRecord";
return NULL;
}
@@ -171,7 +172,7 @@ KeyedService* PasswordStoreFactory::BuildServiceInstanceFor(
db_thread_runner,
login_db.release(),
WebDataServiceFactory::GetPasswordWebDataForProfile(
profile, Profile::EXPLICIT_ACCESS));
profile, ServiceAccessType::EXPLICIT_ACCESS));
#elif defined(OS_MACOSX)
crypto::AppleKeychain* keychain =
base::CommandLine::ForCurrentProcess()->HasSwitch(

@@ -7,9 +7,9 @@
#include "base/basictypes.h"
#include "base/memory/singleton.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/keyed_service/core/service_access_type.h"
class Profile;
@@ -50,7 +50,7 @@ class PasswordStoreFactory : public BrowserContextKeyedServiceFactory {
public:
static scoped_refptr<password_manager::PasswordStore> GetForProfile(
Profile* profile,
Profile::ServiceAccessType set);
ServiceAccessType set);
static PasswordStoreFactory* GetInstance();

@@ -82,7 +82,7 @@ AutocompleteActionPredictor::AutocompleteActionPredictor(Profile* profile)
// Request the in-memory database from the history to force it to load so
// it's available as soon as possible.
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (history_service)
history_service->InMemoryDatabase();
@@ -463,8 +463,8 @@ void AutocompleteActionPredictor::CreateCaches(
}
// If the history service is ready, delete any old or invalid entries.
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (!TryDeleteOldEntries(history_service)) {
// Wait for the notification that the history service is ready and the URL
// DB is loaded.

@@ -127,9 +127,8 @@ class AutocompleteActionPredictorTest : public testing::Test {
}
history::URLID AddRowToHistory(const TestUrlInfo& test_row) {
HistoryService* history =
HistoryServiceFactory::GetForProfile(profile_.get(),
Profile::EXPLICIT_ACCESS);
HistoryService* history = HistoryServiceFactory::GetForProfile(
profile_.get(), ServiceAccessType::EXPLICIT_ACCESS);
CHECK(history);
history::URLDatabase* url_db = history->InMemoryDatabase();
CHECK(url_db);
@@ -189,9 +188,8 @@ class AutocompleteActionPredictorTest : public testing::Test {
void DeleteOldIdsFromCaches(
std::vector<AutocompleteActionPredictorTable::Row::Id>* id_list) {
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile_.get(),
Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_.get(), ServiceAccessType::EXPLICIT_ACCESS);
ASSERT_TRUE(history_service);
history::URLDatabase* url_db = history_service->InMemoryDatabase();

@@ -605,7 +605,7 @@ void ResourcePrefetchPredictor::OnNavigationComplete(
// Kick off history lookup to determine if we should record the URL.
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
DCHECK(history_service);
history_service->ScheduleDBTask(
scoped_ptr<history::HistoryDBTask>(
@@ -1347,8 +1347,8 @@ void ResourcePrefetchPredictor::OnHistoryServiceLoaded(
void ResourcePrefetchPredictor::ConnectToHistoryService() {
// Register for HistoryServiceLoading if it is not ready.
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (!history_service)
return;
if (history_service->BackendLoaded()) {

@@ -79,7 +79,7 @@ class ResourcePrefetchPredictorTest : public testing::Test {
protected:
void AddUrlToHistory(const std::string& url, int visit_count) {
HistoryServiceFactory::GetForProfile(profile_.get(),
Profile::EXPLICIT_ACCESS)->
ServiceAccessType::EXPLICIT_ACCESS)->
AddPageWithDetails(
GURL(url),
base::string16(),
@@ -186,8 +186,8 @@ void ResourcePrefetchPredictorTest::SetUp() {
ASSERT_TRUE(profile_->CreateHistoryService(true, false));
profile_->BlockUntilHistoryProcessesPendingRequests();
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile_.get(),
Profile::EXPLICIT_ACCESS));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
profile_.get(), ServiceAccessType::EXPLICIT_ACCESS));
// Initialize the predictor with empty data.
ResetPredictor();
EXPECT_EQ(predictor_->initialization_state_,

@@ -1357,7 +1357,7 @@ PrerenderHandle* PrerenderManager::AddPrerender(
// Query the history to see if the URL being prerendered has ever been
// visited before.
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (history_service) {
history_service->QueryURL(
url,

@@ -151,7 +151,7 @@ KeyedService* ProfileResetterTest::CreateTemplateURLService(
profile->GetPrefs(),
scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)),
WebDataServiceFactory::GetKeywordWebDataForProfile(
profile, Profile::EXPLICIT_ACCESS),
profile, ServiceAccessType::EXPLICIT_ACCESS),
scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure());
}

@@ -74,31 +74,6 @@ class PrefRegistrySyncable;
// http://dev.chromium.org/developers/design-documents/profile-architecture
class Profile : public content::BrowserContext {
public:
// Profile services are accessed with the following parameter. This parameter
// defines what the caller plans to do with the service.
// The caller is responsible for not performing any operation that would
// result in persistent implicit records while using an OffTheRecord profile.
// This flag allows the profile to perform an additional check.
//
// It also gives us an opportunity to perform further checks in the future. We
// could, for example, return an history service that only allow some specific
// methods.
enum ServiceAccessType {
// The caller plans to perform a read or write that takes place as a result
// of the user input. Use this flag when the operation you are doing can be
// performed while incognito. (ex: creating a bookmark)
//
// Since EXPLICIT_ACCESS means "as a result of a user action", this request
// always succeeds.
EXPLICIT_ACCESS,
// The caller plans to call a method that will permanently change some data
// in the profile, as part of Chrome's implicit data logging. Use this flag
// when you are about to perform an operation which is incompatible with the
// incognito mode.
IMPLICIT_ACCESS
};
enum CreateStatus {
// Profile services were not created due to a local error (e.g., disk full).
CREATE_STATUS_LOCAL_FAIL,

@@ -1154,8 +1154,8 @@ void ProfileManager::FinishDeletingProfile(const base::FilePath& profile_dir) {
ProfileMetrics::LogProfileDelete(profile_is_signed_in);
// Some platforms store passwords in keychains. They should be removed.
scoped_refptr<password_manager::PasswordStore> password_store =
PasswordStoreFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS)
.get();
PasswordStoreFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS).get();
if (password_store.get()) {
password_store->RemoveLoginsCreatedBetween(base::Time(),
base::Time::Max());

@@ -420,8 +420,8 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, DeletePasswords) {
form.blacklisted_by_user = false;
scoped_refptr<password_manager::PasswordStore> password_store =
PasswordStoreFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS)
.get();
PasswordStoreFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS).get();
ASSERT_TRUE(password_store.get());
password_store->AddLogin(form);

@@ -263,15 +263,15 @@ TEST_F(ProfileManagerTest, CreateAndUseTwoProfiles) {
// Force lazy-init of some profile services to simulate use.
ASSERT_TRUE(profile1->CreateHistoryService(true, false));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile1,
Profile::EXPLICIT_ACCESS));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
profile1, ServiceAccessType::EXPLICIT_ACCESS));
profile1->CreateBookmarkModel(true);
EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile1));
profile2->CreateBookmarkModel(true);
EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile2));
ASSERT_TRUE(profile2->CreateHistoryService(true, false));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile2,
Profile::EXPLICIT_ACCESS));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
profile2, ServiceAccessType::EXPLICIT_ACCESS));
// Make sure any pending tasks run before we destroy the profiles.
base::RunLoop().RunUntilIdle();

@@ -458,8 +458,8 @@ bool BrowserFeatureExtractor::GetHistoryService(HistoryService** history) {
*history = NULL;
if (tab_ && tab_->GetBrowserContext()) {
Profile* profile = Profile::FromBrowserContext(tab_->GetBrowserContext());
*history = HistoryServiceFactory::GetForProfile(profile,
Profile::EXPLICIT_ACCESS);
*history = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
if (*history) {
return true;
}

@@ -103,8 +103,8 @@ class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness {
}
HistoryService* history_service() {
return HistoryServiceFactory::GetForProfile(profile(),
Profile::EXPLICIT_ACCESS);
return HistoryServiceFactory::GetForProfile(
profile(), ServiceAccessType::EXPLICIT_ACCESS);
}
void SetRedirectChain(const std::vector<GURL>& redirect_chain,

@@ -23,6 +23,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/binary_feature_extractor.h"
#include "chrome/browser/safe_browsing/download_feedback_service.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
@@ -676,8 +677,8 @@ class DownloadProtectionService::CheckClientDownloadRequest
}
Profile* profile = Profile::FromBrowserContext(item_->GetBrowserContext());
HistoryService* history =
HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
HistoryService* history = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
if (!history) {
SendRequest();
return;

@@ -1549,7 +1549,8 @@ TEST_F(DownloadProtectionServiceTest,
redirects.push_back(GURL("http://tab.com/ref1"));
redirects.push_back(GURL("http://tab.com/ref2"));
redirects.push_back(tab_url);
HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)
HistoryServiceFactory::GetForProfile(&profile,
ServiceAccessType::EXPLICIT_ACCESS)
->AddPage(tab_url,
base::Time::Now(),
reinterpret_cast<history::ContextID>(1),

@@ -227,8 +227,8 @@ void LastDownloadFinder::OnMetadataQuery(
} else {
// Search history since no metadata was found.
iter->second = WAITING_FOR_HISTORY;
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::IMPLICIT_ACCESS);
// No history service is returned for profiles that do not save history.
if (!history_service) {
RemoveProfileAndReportIfDone(iter);
@@ -324,7 +324,7 @@ void LastDownloadFinder::OnHistoryServiceLoaded(
HistoryService* history_service) {
for (const auto& pair : profile_states_) {
HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
pair.first, Profile::EXPLICIT_ACCESS);
pair.first, ServiceAccessType::EXPLICIT_ACCESS);
if (hs == history_service) {
// Start the query in the history service if the finder was waiting for
// the service to load.

@@ -74,8 +74,8 @@ class LastDownloadFinderTest : public testing::Test {
// download to its history.
void CreateProfileWithDownload() {
TestingProfile* profile = CreateProfile(SAFE_BROWSING_OPT_IN);
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
history_service->CreateDownload(
CreateTestDownloadRow(),
base::Bind(&LastDownloadFinderTest::OnDownloadCreated,
@@ -162,8 +162,8 @@ class LastDownloadFinderTest : public testing::Test {
void AddDownload(Profile* profile, const history::DownloadRow& download) {
base::RunLoop run_loop;
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
history_service->CreateDownload(
download,
base::Bind(&LastDownloadFinderTest::ContinueOnDownloadCreated,
@@ -183,7 +183,8 @@ class LastDownloadFinderTest : public testing::Test {
// dtor must be run.
void FlushHistoryBackend(Profile* profile) {
base::RunLoop run_loop;
HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS)
HistoryServiceFactory::GetForProfile(profile,
ServiceAccessType::EXPLICIT_ACCESS)
->FlushForTest(run_loop.QuitClosure());
run_loop.Run();
// Then make sure anything bounced back to the main thread has been handled.

@@ -89,7 +89,7 @@ void MalwareDetailsRedirectsCollector::GetRedirects(const GURL& url) {
}
HistoryService* history = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (!history) {
AllDone();
return;

@@ -215,8 +215,8 @@ class MalwareDetailsTest : public ChromeRenderViewHostTestHarness {
}
HistoryService* history_service() {
return HistoryServiceFactory::GetForProfile(profile(),
Profile::EXPLICIT_ACCESS);
return HistoryServiceFactory::GetForProfile(
profile(), ServiceAccessType::EXPLICIT_ACCESS);
}
protected:

@@ -192,8 +192,8 @@ SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
RecordUserDecision(PROCEEDING_DISABLED);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
Profile::FromBrowserContext(web_contents->GetBrowserContext()),
Profile::EXPLICIT_ACCESS);
Profile::FromBrowserContext(web_contents->GetBrowserContext()),
ServiceAccessType::EXPLICIT_ACCESS);
if (history_service) {
history_service->GetVisibleVisitCountToHost(
request_url(),

@@ -12,6 +12,7 @@
#include "chrome/browser/google/google_url_tracker_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/rlz/rlz.h"
#include "chrome/browser/search_engines/chrome_template_url_service_client.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
@@ -49,10 +50,10 @@ KeyedService* TemplateURLServiceFactory::BuildInstanceFor(
profile->GetPrefs(),
scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)),
WebDataServiceFactory::GetKeywordWebDataForProfile(
profile, Profile::EXPLICIT_ACCESS),
profile, ServiceAccessType::EXPLICIT_ACCESS),
scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient(
HistoryServiceFactory::GetForProfile(profile,
Profile::EXPLICIT_ACCESS))),
HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS))),
GoogleURLTrackerFactory::GetForProfile(profile),
g_browser_process->rappor_service(),
dsp_change_callback);

@@ -114,11 +114,10 @@ void TemplateURLServiceTestUtil::ResetModel(bool verify_load) {
model_.reset(new TemplateURLService(
profile()->GetPrefs(), scoped_ptr<SearchTermsData>(search_terms_data_),
web_data_service_.get(),
scoped_ptr<TemplateURLServiceClient>(
new TestingTemplateURLServiceClient(
HistoryServiceFactory::GetForProfileIfExists(
profile(), Profile::EXPLICIT_ACCESS),
&search_term_)),
scoped_ptr<TemplateURLServiceClient>(new TestingTemplateURLServiceClient(
HistoryServiceFactory::GetForProfileIfExists(
profile(), ServiceAccessType::EXPLICIT_ACCESS),
&search_term_)),
NULL, NULL, base::Closure()));
model()->AddObserver(this);
changed_count_ = 0;

@@ -120,7 +120,7 @@ PrefService* ChromeSigninClient::GetPrefs() { return profile_->GetPrefs(); }
scoped_refptr<TokenWebData> ChromeSigninClient::GetDatabase() {
return WebDataServiceFactory::GetTokenWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
}
bool ChromeSigninClient::CanRevokeCredentials() {

@@ -350,7 +350,7 @@ SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents,
if (internal_)
RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS);
profile, ServiceAccessType::EXPLICIT_ACCESS);
if (history_service) {
history_service->GetVisibleVisitCountToHost(
request_url,

@@ -268,7 +268,7 @@ IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
// Query the history entry.
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
browser()->profile(), Profile::EXPLICIT_ACCESS);
browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS);
history::QueryOptions options;
history::QueryResults results;
QueryHistory(history_service, "", options, &results);

@@ -235,8 +235,8 @@ void SupervisedUserNavigationObserver::OnRequestBlockedInternal(
// Add the entry to the history database.
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::IMPLICIT_ACCESS);
// |history_service| is null if saving history is disabled.
if (history_service)

@@ -63,7 +63,7 @@ bool AutofillDataTypeController::StartModels() {
autofill::AutofillWebDataService* web_data_service =
WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS).get();
profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
if (!web_data_service)
return false;

@@ -192,10 +192,9 @@ class SyncAutofillDataTypeControllerTest : public testing::Test {
// immediately try to start association and fail (due to missing DB
// thread).
TEST_F(SyncAutofillDataTypeControllerTest, StartWDSReady) {
FakeWebDataService* web_db =
static_cast<FakeWebDataService*>(
WebDataServiceFactory::GetAutofillWebDataForProfile(
&profile_, Profile::EXPLICIT_ACCESS).get());
FakeWebDataService* web_db = static_cast<FakeWebDataService*>(
WebDataServiceFactory::GetAutofillWebDataForProfile(
&profile_, ServiceAccessType::EXPLICIT_ACCESS).get());
web_db->LoadDatabase();
autofill_dtc_->LoadModels(
base::Bind(&SyncAutofillDataTypeControllerTest::OnLoadFinished,
@@ -228,7 +227,7 @@ TEST_F(SyncAutofillDataTypeControllerTest, StartWDSNotReady) {
FakeWebDataService* web_db = static_cast<FakeWebDataService*>(
WebDataServiceFactory::GetAutofillWebDataForProfile(
&profile_, Profile::EXPLICIT_ACCESS).get());
&profile_, ServiceAccessType::EXPLICIT_ACCESS).get());
web_db->LoadDatabase();
autofill_dtc_->StartAssociating(

@@ -54,7 +54,7 @@ void AutofillProfileDataTypeController::OnPersonalDataChanged() {
personal_data_->RemoveObserver(this);
autofill::AutofillWebDataService* web_data_service =
WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS).get();
profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
if (!web_data_service)
return;
@@ -92,7 +92,7 @@ bool AutofillProfileDataTypeController::StartModels() {
autofill::AutofillWebDataService* web_data_service =
WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS).get();
profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
if (!web_data_service)
return false;

@@ -870,10 +870,10 @@ void BookmarkChangeProcessor::ApplyBookmarkFavicon(
Profile* profile,
const GURL& icon_url,
const scoped_refptr<base::RefCountedMemory>& bitmap_data) {
HistoryService* history =
HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
HistoryService* history = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
history->AddPageNoVisitForBookmark(bookmark_node->url(),
bookmark_node->GetTitle());

@@ -47,7 +47,7 @@ bool BookmarkDataTypeController::StartModels() {
BookmarkModelFactory::GetForProfile(profile_);
bookmark_model_observer_.Add(bookmark_model);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
history_service_observer_.Add(history_service);
return false;
}
@@ -95,7 +95,7 @@ bool BookmarkDataTypeController::DependentsLoaded() {
return false;
HistoryService* history = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (!history || !history->BackendLoaded())
return false;

@@ -434,8 +434,8 @@ void FaviconCache::OnPageFaviconUpdated(const GURL& page_url) {
page_task_map_[page_url] = 0; // For testing only.
return;
}
FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (!favicon_service)
return;
// TODO(zea): This appears to only fetch one favicon (best match based on

@@ -51,7 +51,7 @@ bool PasswordDataTypeController::StartModels() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(MODEL_STARTING, state());
password_store_ = PasswordStoreFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
return !!password_store_.get();
}

@@ -94,8 +94,8 @@ SyncBackendRegistrar::SyncBackendRegistrar(
// TODO(pavely): Remove ScopedTracker below once crbug.com/426272 is fixed.
tracked_objects::ScopedTracker tracker2(FROM_HERE_WITH_EXPLICIT_FUNCTION(
"426272 SyncBackendRegistrar::ctor history"));
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::IMPLICIT_ACCESS);
if (history_service) {
workers_[syncer::GROUP_HISTORY] =
new HistoryModelWorker(history_service->AsWeakPtr(), this);
@@ -107,7 +107,8 @@ SyncBackendRegistrar::SyncBackendRegistrar(
tracked_objects::ScopedTracker tracker3(FROM_HERE_WITH_EXPLICIT_FUNCTION(
"426272 SyncBackendRegistrar::ctor passwords"));
scoped_refptr<password_manager::PasswordStore> password_store =
PasswordStoreFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
PasswordStoreFactory::GetForProfile(profile,
ServiceAccessType::IMPLICIT_ACCESS);
if (password_store.get()) {
workers_[syncer::GROUP_PASSWORD] =
new PasswordModelWorker(password_store, this);

@@ -126,7 +126,7 @@ bool TypedUrlDataTypeController::PostTaskOnBackendThread(
const base::Closure& task) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
HistoryService* history = HistoryServiceFactory::GetForProfile(
profile(), Profile::IMPLICIT_ACCESS);
profile(), ServiceAccessType::IMPLICIT_ACCESS);
if (history) {
history->ScheduleDBTask(
scoped_ptr<history::HistoryDBTask>(

@@ -163,7 +163,7 @@ ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
command_line_(command_line),
web_data_service_(WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_,
Profile::EXPLICIT_ACCESS)),
ServiceAccessType::EXPLICIT_ACCESS)),
sync_service_url_(sync_service_url),
token_service_(token_service),
url_request_context_getter_(url_request_context_getter),
@@ -502,9 +502,8 @@ base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl::
GetThemeSyncableService()->AsWeakPtr();
#endif
case syncer::HISTORY_DELETE_DIRECTIVES: {
HistoryService* history =
HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
HistoryService* history = HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
return history ? history->AsWeakPtr() : base::WeakPtr<HistoryService>();
}
#if defined(ENABLE_SPELLCHECK)
@@ -550,8 +549,8 @@ base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl::
case syncer::PASSWORDS: {
#if defined(PASSWORD_MANAGER_ENABLE_SYNC)
scoped_refptr<password_manager::PasswordStore> password_store =
PasswordStoreFactory::GetForProfile(profile_,
Profile::EXPLICIT_ACCESS);
PasswordStoreFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
return password_store.get() ? password_store->GetPasswordSyncableService()
: base::WeakPtr<syncer::SyncableService>();
#else

@@ -183,7 +183,8 @@ void ClearBrowsingData(BrowsingDataRemover::Observer* observer,
BrowsingDataHelper::ALL);
scoped_refptr<password_manager::PasswordStore> password =
PasswordStoreFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
PasswordStoreFactory::GetForProfile(profile,
ServiceAccessType::EXPLICIT_ACCESS);
password->RemoveLoginsSyncedBetween(start, end);
}

@@ -497,7 +497,7 @@ class ProfileSyncServiceAutofillTest
personal_data_manager_->Init(
WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS),
profile_, ServiceAccessType::EXPLICIT_ACCESS),
profile_->GetPrefs(),
profile_->IsOffTheRecord());

@@ -58,8 +58,8 @@ NotificationServiceSessionsRouter::NotificationServiceSessionsRouter(
registrar_.Add(this,
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
content::NotificationService::AllBrowserContextsAndSources());
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
HistoryService* history_service = HistoryServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
if (history_service) {
favicon_changed_subscription_ = history_service->AddFaviconChangedCallback(
base::Bind(&NotificationServiceSessionsRouter::OnFaviconChanged,

@@ -167,7 +167,7 @@ AutofillProfile CreateAutofillProfile(ProfileType type) {
scoped_refptr<AutofillWebDataService> GetWebDataService(int index) {
return WebDataServiceFactory::GetAutofillWebDataForProfile(
test()->GetProfile(index), Profile::EXPLICIT_ACCESS);
test()->GetProfile(index), ServiceAccessType::EXPLICIT_ACCESS);
}
PersonalDataManager* GetPersonalDataManager(int index) {

@@ -230,9 +230,8 @@ void SetFaviconImpl(Profile* profile,
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
FaviconChangeObserver observer(model, node);
FaviconService* favicon_service =
FaviconServiceFactory::GetForProfile(profile,
Profile::EXPLICIT_ACCESS);
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
if (favicon_source == bookmarks_helper::FROM_UI) {
favicon_service->SetFavicons(
node->url(), icon_url, favicon_base::FAVICON, image);

@@ -134,12 +134,13 @@ bool SetDecryptionPassphrase(int index, const std::string& passphrase) {
PasswordStore* GetPasswordStore(int index) {
return PasswordStoreFactory::GetForProfile(test()->GetProfile(index),
Profile::IMPLICIT_ACCESS).get();
ServiceAccessType::IMPLICIT_ACCESS)
.get();
}
PasswordStore* GetVerifierPasswordStore() {
return PasswordStoreFactory::GetForProfile(test()->verifier(),
Profile::IMPLICIT_ACCESS).get();
return PasswordStoreFactory::GetForProfile(
test()->verifier(), ServiceAccessType::IMPLICIT_ACCESS).get();
}
bool ProfileContainsSamePasswordFormsAsVerifier(int index) {

@@ -397,7 +397,7 @@ bool SyncTest::SetupClients() {
bookmarks::test::WaitForBookmarkModelToLoad(
BookmarkModelFactory::GetForProfile(verifier()));
ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
verifier(), Profile::EXPLICIT_ACCESS));
verifier(), ServiceAccessType::EXPLICIT_ACCESS));
ui_test_utils::WaitForTemplateURLServiceToLoad(
TemplateURLServiceFactory::GetForProfile(verifier()));
return (verifier_ != NULL);
@@ -457,7 +457,7 @@ void SyncTest::InitializeInstance(int index) {
bookmarks::test::WaitForBookmarkModelToLoad(
BookmarkModelFactory::GetForProfile(GetProfile(index)));
ui_test_utils::WaitForHistoryToLoad(HistoryServiceFactory::GetForProfile(
GetProfile(index), Profile::EXPLICIT_ACCESS));
GetProfile(index), ServiceAccessType::EXPLICIT_ACCESS));
ui_test_utils::WaitForTemplateURLServiceToLoad(
TemplateURLServiceFactory::GetForProfile(GetProfile(index)));
}

@@ -285,13 +285,9 @@ void AddUrlToHistoryWithTimestamp(int index,
source,
timestamp);
if (test()->use_verifier())
AddToHistory(
HistoryServiceFactory::GetForProfile(test()->verifier(),
Profile::IMPLICIT_ACCESS),
url,
transition,
source,
timestamp);
AddToHistory(HistoryServiceFactory::GetForProfile(
test()->verifier(), ServiceAccessType::IMPLICIT_ACCESS),
url, transition, source, timestamp);
// Wait until the AddPage() request has completed so we know the change has
// filtered down to the sync observers (don't need to wait for the
@@ -303,9 +299,8 @@ void DeleteUrlFromHistory(int index, const GURL& url) {
HistoryServiceFactory::GetForProfileWithoutCreating(
test()->GetProfile(index))->DeleteURL(url);
if (test()->use_verifier())
HistoryServiceFactory::GetForProfile(test()->verifier(),
Profile::IMPLICIT_ACCESS)->
DeleteURL(url);
HistoryServiceFactory::GetForProfile(
test()->verifier(), ServiceAccessType::IMPLICIT_ACCESS)->DeleteURL(url);
WaitForHistoryDBThread(index);
}
@@ -314,8 +309,8 @@ void DeleteUrlsFromHistory(int index, const std::vector<GURL>& urls) {
test()->GetProfile(index))->DeleteURLsForTest(urls);
if (test()->use_verifier())
HistoryServiceFactory::GetForProfile(test()->verifier(),
Profile::IMPLICIT_ACCESS)->
DeleteURLsForTest(urls);
ServiceAccessType::IMPLICIT_ACCESS)
->DeleteURLsForTest(urls);
WaitForHistoryDBThread(index);
}
@@ -375,9 +370,8 @@ bool CheckURLRowsAreEqual(
}
bool CheckAllProfilesHaveSameURLsAsVerifier() {
HistoryService* verifier_service =
HistoryServiceFactory::GetForProfile(test()->verifier(),
Profile::IMPLICIT_ACCESS);
HistoryService* verifier_service = HistoryServiceFactory::GetForProfile(
test()->verifier(), ServiceAccessType::IMPLICIT_ACCESS);
history::URLRows verifier_urls =
GetTypedUrlsFromHistoryService(verifier_service);
for (int i = 0; i < test()->num_clients(); ++i) {

@@ -41,7 +41,7 @@ void NavigationPopup::FetchFaviconForUrl(JNIEnv* env,
jstring jurl) {
Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile();
FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS);
profile, ServiceAccessType::EXPLICIT_ACCESS);
if (!favicon_service)
return;
GURL url(base::android::ConvertJavaStringToUTF16(env, jurl));

@@ -276,12 +276,11 @@ class TestAutofillDialogController
}
void Init(content::BrowserContext* browser_context) {
test_manager_.Init(
WebDataServiceFactory::GetAutofillWebDataForProfile(
Profile::FromBrowserContext(browser_context),
Profile::EXPLICIT_ACCESS),
user_prefs::UserPrefs::Get(browser_context),
browser_context->IsOffTheRecord());
test_manager_.Init(WebDataServiceFactory::GetAutofillWebDataForProfile(
Profile::FromBrowserContext(browser_context),
ServiceAccessType::EXPLICIT_ACCESS),
user_prefs::UserPrefs::Get(browser_context),
browser_context->IsOffTheRecord());
}
TestAutofillDialogView* GetView() {

@@ -91,7 +91,7 @@ scoped_refptr<AutofillWebDataService> ChromeAutofillClient::GetDatabase() {
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
return WebDataServiceFactory::GetAutofillWebDataForProfile(
profile, Profile::EXPLICIT_ACCESS);
profile, ServiceAccessType::EXPLICIT_ACCESS);
}
PrefService* ChromeAutofillClient::GetPrefs() {

@@ -74,7 +74,7 @@ HistoryMenuBridge::HistoryMenuBridge(Profile* profile)
// may not be ready when the Bridge is created. If this happens, register
// for a notification that tells us the HistoryService is ready.
HistoryService* hs = HistoryServiceFactory::GetForProfile(
profile_, Profile::EXPLICIT_ACCESS);
profile_, ServiceAccessType::EXPLICIT_ACCESS);
if (hs) {
history_service_observer_.Add(hs);
if (hs->BackendLoaded()) {
@@ -432,8 +432,8 @@ HistoryMenuBridge::HistoryItem* HistoryMenuBridge::HistoryItemForTab(
}
void HistoryMenuBridge::GetFaviconForHistoryItem(HistoryItem* item) {
FaviconService* service =
FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
FaviconService* service = FaviconServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
base::CancelableTaskTracker::TaskId task_id =
service->GetFaviconImageForPageURL(
item->url,

@@ -63,8 +63,8 @@ class ManagePasswordItemViewControllerTest
password_manager::MockPasswordStore* mockStore() {
password_manager::PasswordStore* store =
PasswordStoreFactory::GetForProfile(profile(), Profile::EXPLICIT_ACCESS)
.get();
PasswordStoreFactory::GetForProfile(
profile(), ServiceAccessType::EXPLICIT_ACCESS).get();
password_manager::MockPasswordStore* mockStore =
static_cast<password_manager::MockPasswordStore*>(store);
return mockStore;

@@ -187,10 +187,11 @@ class FindInPageControllerTest : public InProcessBrowserTest {
}
void FlushHistoryService() {
HistoryServiceFactory::GetForProfile(
browser()->profile(), Profile::IMPLICIT_ACCESS)->FlushForTest(
base::Bind(&base::MessageLoop::Quit,
base::Unretained(base::MessageLoop::current()->current())));
HistoryServiceFactory::GetForProfile(browser()->profile(),
ServiceAccessType::IMPLICIT_ACCESS)
->FlushForTest(base::Bind(
&base::MessageLoop::Quit,
base::Unretained(base::MessageLoop::current()->current())));
content::RunMessageLoop();
}
};

Some files were not shown because too many files have changed in this diff Show More