blob: 824baca4ddacb593b2ba7041644ca3da255ceca5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ios/chrome/browser/favicon/favicon_service_factory.h"
#include "base/memory/singleton.h"
#include "components/favicon/core/favicon_service.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/favicon/favicon_client_impl.h"
#include "ios/chrome/browser/history/history_service_factory.h"
namespace ios {
// static
favicon::FaviconService* FaviconServiceFactory::GetForBrowserState(
ios::ChromeBrowserState* browser_state,
ServiceAccessType access_type) {
if (!browser_state->IsOffTheRecord()) {
return static_cast<favicon::FaviconService*>(
GetInstance()->GetServiceForBrowserState(browser_state, true));
} else if (access_type == ServiceAccessType::EXPLICIT_ACCESS) {
return static_cast<favicon::FaviconService*>(
GetInstance()->GetServiceForBrowserState(
browser_state->GetOriginalChromeBrowserState(), true));
}
// ios::ChromeBrowserState is OffTheRecord without access.
NOTREACHED() << "ChromeBrowserState is OffTheRecord";
return nullptr;
}
// static
FaviconServiceFactory* FaviconServiceFactory::GetInstance() {
return base::Singleton<FaviconServiceFactory>::get();
}
FaviconServiceFactory::FaviconServiceFactory()
: BrowserStateKeyedServiceFactory(
"FaviconService",
BrowserStateDependencyManager::GetInstance()) {
DependsOn(ios::HistoryServiceFactory::GetInstance());
}
FaviconServiceFactory::~FaviconServiceFactory() {
}
scoped_ptr<KeyedService> FaviconServiceFactory::BuildServiceInstanceFor(
web::BrowserState* context) const {
ios::ChromeBrowserState* browser_state =
ios::ChromeBrowserState::FromBrowserState(context);
return make_scoped_ptr(new favicon::FaviconService(
make_scoped_ptr(new FaviconClientImpl(browser_state)),
ios::HistoryServiceFactory::GetForBrowserState(
browser_state, ServiceAccessType::EXPLICIT_ACCESS)));
}
} // namespace ios
|