blob: f04646429eec29223dd1506b1de4e91d9c7c79e6 (
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
|
// Copyright 2014 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 "chrome/browser/extensions/updater/chrome_extension_downloader_factory.h"
#include <string>
#include "chrome/browser/google/google_brand.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "components/signin/core/browser/profile_identity_provider.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/update_client/update_query_params.h"
#include "extensions/browser/updater/extension_downloader.h"
#include "google_apis/gaia/identity_provider.h"
using extensions::ExtensionDownloader;
using extensions::ExtensionDownloaderDelegate;
using update_client::UpdateQueryParams;
scoped_ptr<ExtensionDownloader>
ChromeExtensionDownloaderFactory::CreateForRequestContext(
net::URLRequestContextGetter* request_context,
ExtensionDownloaderDelegate* delegate) {
scoped_ptr<ExtensionDownloader> downloader(
new ExtensionDownloader(delegate, request_context));
#if defined(GOOGLE_CHROME_BUILD)
std::string brand;
google_brand::GetBrand(&brand);
if (!brand.empty() && !google_brand::IsOrganic(brand))
downloader->set_brand_code(brand);
#endif // defined(GOOGLE_CHROME_BUILD)
downloader->set_manifest_query_params(
UpdateQueryParams::Get(UpdateQueryParams::CRX));
downloader->set_ping_enabled_domain("google.com");
downloader->set_enable_extra_update_metrics(
ChromeMetricsServiceAccessor::IsMetricsReportingEnabled());
return downloader.Pass();
}
scoped_ptr<ExtensionDownloader>
ChromeExtensionDownloaderFactory::CreateForProfile(
Profile* profile,
ExtensionDownloaderDelegate* delegate) {
scoped_ptr<IdentityProvider> identity_provider(new ProfileIdentityProvider(
SigninManagerFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile)));
scoped_ptr<ExtensionDownloader> downloader =
CreateForRequestContext(profile->GetRequestContext(), delegate);
downloader->SetWebstoreIdentityProvider(identity_provider.Pass());
return downloader.Pass();
}
|