Chromium Code Reviews| Index: ios/chrome/browser/ui/downloads/download_manager_controller.mm |
| diff --git a/ios/chrome/browser/ui/downloads/download_manager_controller.mm b/ios/chrome/browser/ui/downloads/download_manager_controller.mm |
| index c17dc199bec39c0967ac01a5a074dacb7ef17278..9d1052efe6208d5b587e7d419d8592096c3f94f0 100644 |
| --- a/ios/chrome/browser/ui/downloads/download_manager_controller.mm |
| +++ b/ios/chrome/browser/ui/downloads/download_manager_controller.mm |
| @@ -23,7 +23,7 @@ |
| #include "components/strings/grit/components_strings.h" |
| #import "ios/chrome/browser/installation_notifier.h" |
| #include "ios/chrome/browser/native_app_launcher/ios_appstore_ids.h" |
| -#import "ios/chrome/browser/store_kit/store_kit_launcher.h" |
| +#import "ios/chrome/browser/store_kit/store_kit_tab_helper.h" |
| #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" |
| #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| #import "ios/chrome/browser/ui/network_activity_indicator_manager.h" |
| @@ -37,6 +37,8 @@ |
| #import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h" |
| #import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h" |
| #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoFontLoader.h" |
| +#include "ios/web/public/browser_state.h" |
| +#include "ios/web/public/web_state/web_state.h" |
| #include "ios/web/public/web_thread.h" |
| #include "net/base/filename_util.h" |
| #include "net/http/http_response_headers.h" |
| @@ -374,11 +376,11 @@ class DownloadContentDelegate : public URLFetcherDelegate { |
| BOOL _isFileTypeLabelCentered; |
| BOOL _isDisplayingError; |
| BOOL _didSuccessfullyFinishHeadFetch; |
| - scoped_refptr<URLRequestContextGetter> _requestContextGetter; |
| + // WebState provides access to the *TabHelper objects. |
| + web::WebState* _webState; |
| std::unique_ptr<URLFetcher> _fetcher; |
| std::unique_ptr<DownloadHeadDelegate> _headFetcherDelegate; |
| std::unique_ptr<DownloadContentDelegate> _contentFetcherDelegate; |
| - base::WeakNSProtocol<id<StoreKitLauncher>> _storeKitLauncher; |
| base::FilePath _downloadFilePath; |
| base::scoped_nsobject<MDCActivityIndicator> _activityIndicator; |
| // Set to YES when a download begins and is used to determine if the |
| @@ -518,20 +520,18 @@ class DownloadContentDelegate : public URLFetcherDelegate { |
| @synthesize fractionDownloaded = _fractionDownloaded; |
| @synthesize googleDriveMetadata = _googleDriveMetadata; |
| -- (id)initWithURL:(const GURL&)url |
| - requestContextGetter:(URLRequestContextGetter*)requestContextGetter |
| - storeKitLauncher:(id<StoreKitLauncher>)storeLauncher { |
| +- (id)initWithWebState:(web::WebState*)webState downloadURL:(const GURL&)url { |
|
sdefresne
2017/03/07 17:15:49
ditto
pkl (ping after 24h if needed)
2017/03/07 22:07:19
Done.
|
| self = [super initWithNibName:@"DownloadManagerController" url:url]; |
| if (self) { |
| _downloadManagerId = g_download_manager_id++; |
| _propertyReleaser_DownloadManagerController.Init( |
| self, [DownloadManagerController class]); |
| - _requestContextGetter = requestContextGetter; |
| + DCHECK(webState); |
| + _webState = webState; |
| _headFetcherDelegate.reset(new DownloadHeadDelegate(self)); |
| _contentFetcherDelegate.reset(new DownloadContentDelegate(self)); |
| _downloadFilePath = base::FilePath(); |
| - _storeKitLauncher.reset(storeLauncher); |
| [_documentContainer |
| setBackgroundColor:UIColorFromRGB(kUndownloadedDocumentColor)]; |
| @@ -954,7 +954,8 @@ class DownloadContentDelegate : public URLFetcherDelegate { |
| - (void)startHeadFetch { |
| _fetcher = URLFetcher::Create([self url], URLFetcher::HEAD, |
| _headFetcherDelegate.get()); |
| - _fetcher->SetRequestContext(_requestContextGetter.get()); |
| + _fetcher->SetRequestContext( |
| + _webState->GetBrowserState()->GetRequestContext()); |
| [[NetworkActivityIndicatorManager sharedInstance] |
| startNetworkTaskForGroup:[self getNetworkActivityKey]]; |
| _fetcher->Start(); |
| @@ -1265,7 +1266,8 @@ class DownloadContentDelegate : public URLFetcherDelegate { |
| _fetcher = URLFetcher::Create([self url], URLFetcher::GET, |
| _contentFetcherDelegate.get()); |
| - _fetcher->SetRequestContext(_requestContextGetter.get()); |
| + _fetcher->SetRequestContext( |
| + _webState->GetBrowserState()->GetRequestContext()); |
| base::SequencedWorkerPool::SequenceToken sequenceToken = |
| web::WebThread::GetBlockingPool()->GetSequenceToken(); |
| _fetcher->SaveResponseToFileAtPath( |
| @@ -1576,12 +1578,14 @@ class DownloadContentDelegate : public URLFetcherDelegate { |
| } |
| - (void)openGoogleDriveInAppStore { |
| - [[InstallationNotifier sharedInstance] |
| - registerForInstallationNotifications:self |
| - withSelector:@selector(hideGoogleDriveButton) |
| - forScheme:[_googleDriveMetadata anyScheme]]; |
| - |
| - [_storeKitLauncher openAppStore:[_googleDriveMetadata appId]]; |
| + StoreKitTabHelper* helper = StoreKitTabHelper::FromWebState(_webState); |
| + if (helper) { |
| + [[InstallationNotifier sharedInstance] |
| + registerForInstallationNotifications:self |
| + withSelector:@selector(hideGoogleDriveButton) |
| + forScheme:[_googleDriveMetadata anyScheme]]; |
| + helper->OpenAppStore([_googleDriveMetadata appId]); |
| + } |
| } |
| - (NSString*)getNetworkActivityKey { |