| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/downloads/download_manager_controller.h" | 5 #import "ios/chrome/browser/ui/downloads/download_manager_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/ios/weak_nsobject.h" | 12 #include "base/ios/weak_nsobject.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/mac/bind_objc_block.h" | 14 #include "base/mac/bind_objc_block.h" |
| 15 #include "base/mac/objc_property_releaser.h" | 15 #include "base/mac/objc_release_properties.h" |
| 16 #include "base/mac/scoped_nsobject.h" | 16 #include "base/mac/scoped_nsobject.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/metrics/histogram_macros.h" | |
| 20 #include "base/metrics/user_metrics.h" | 19 #include "base/metrics/user_metrics.h" |
| 21 #include "base/metrics/user_metrics_action.h" | 20 #include "base/metrics/user_metrics_action.h" |
| 22 #include "base/strings/sys_string_conversions.h" | 21 #include "base/strings/sys_string_conversions.h" |
| 23 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
| 24 #include "components/strings/grit/components_strings.h" | 23 #include "components/strings/grit/components_strings.h" |
| 25 #import "ios/chrome/browser/installation_notifier.h" | 24 #import "ios/chrome/browser/installation_notifier.h" |
| 26 #include "ios/chrome/browser/native_app_launcher/ios_appstore_ids.h" | 25 #include "ios/chrome/browser/native_app_launcher/ios_appstore_ids.h" |
| 27 #import "ios/chrome/browser/storekit_launcher.h" | 26 #import "ios/chrome/browser/storekit_launcher.h" |
| 28 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" | 27 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" |
| 29 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 28 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 std::unique_ptr<DownloadContentDelegate> _contentFetcherDelegate; | 380 std::unique_ptr<DownloadContentDelegate> _contentFetcherDelegate; |
| 382 base::WeakNSProtocol<id<StoreKitLauncher>> _storeKitLauncher; | 381 base::WeakNSProtocol<id<StoreKitLauncher>> _storeKitLauncher; |
| 383 base::FilePath _downloadFilePath; | 382 base::FilePath _downloadFilePath; |
| 384 base::scoped_nsobject<MDCActivityIndicator> _activityIndicator; | 383 base::scoped_nsobject<MDCActivityIndicator> _activityIndicator; |
| 385 // Set to YES when a download begins and is used to determine if the | 384 // Set to YES when a download begins and is used to determine if the |
| 386 // DownloadFileResult histogram needs to be recorded on -dealloc. | 385 // DownloadFileResult histogram needs to be recorded on -dealloc. |
| 387 BOOL _recordDownloadResultHistogram; | 386 BOOL _recordDownloadResultHistogram; |
| 388 // Set to YES when a file is downloaded and is used to determine if the | 387 // Set to YES when a file is downloaded and is used to determine if the |
| 389 // DownloadedFileAction histogram needs to be recorded on -dealloc. | 388 // DownloadedFileAction histogram needs to be recorded on -dealloc. |
| 390 BOOL _recordFileActionHistogram; | 389 BOOL _recordFileActionHistogram; |
| 391 base::mac::ObjCPropertyReleaser _propertyReleaser_DownloadManagerController; | |
| 392 } | 390 } |
| 393 | 391 |
| 394 // The container that holds the |documentIcon|, the |progressBar|, the | 392 // The container that holds the |documentIcon|, the |progressBar|, the |
| 395 // |foldIcon|, the |fileTypeLabel|, and the |timeLeftLabel|. | 393 // |foldIcon|, the |fileTypeLabel|, and the |timeLeftLabel|. |
| 396 @property(nonatomic, retain) IBOutlet UIView* documentContainer; | 394 @property(nonatomic, retain) IBOutlet UIView* documentContainer; |
| 397 | 395 |
| 398 // The progress bar that displays download progress. | 396 // The progress bar that displays download progress. |
| 399 @property(nonatomic, retain) IBOutlet UIView* progressBar; | 397 @property(nonatomic, retain) IBOutlet UIView* progressBar; |
| 400 | 398 |
| 401 // The image of the document. | 399 // The image of the document. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 @synthesize downloadStartedTime = _downloadStartedTime; | 516 @synthesize downloadStartedTime = _downloadStartedTime; |
| 519 @synthesize fractionDownloaded = _fractionDownloaded; | 517 @synthesize fractionDownloaded = _fractionDownloaded; |
| 520 @synthesize googleDriveMetadata = _googleDriveMetadata; | 518 @synthesize googleDriveMetadata = _googleDriveMetadata; |
| 521 | 519 |
| 522 - (id)initWithURL:(const GURL&)url | 520 - (id)initWithURL:(const GURL&)url |
| 523 requestContextGetter:(URLRequestContextGetter*)requestContextGetter | 521 requestContextGetter:(URLRequestContextGetter*)requestContextGetter |
| 524 storeKitLauncher:(id<StoreKitLauncher>)storeLauncher { | 522 storeKitLauncher:(id<StoreKitLauncher>)storeLauncher { |
| 525 self = [super initWithNibName:@"DownloadManagerController" url:url]; | 523 self = [super initWithNibName:@"DownloadManagerController" url:url]; |
| 526 if (self) { | 524 if (self) { |
| 527 _downloadManagerId = g_download_manager_id++; | 525 _downloadManagerId = g_download_manager_id++; |
| 528 _propertyReleaser_DownloadManagerController.Init( | |
| 529 self, [DownloadManagerController class]); | |
| 530 | |
| 531 _requestContextGetter = requestContextGetter; | 526 _requestContextGetter = requestContextGetter; |
| 532 _headFetcherDelegate.reset(new DownloadHeadDelegate(self)); | 527 _headFetcherDelegate.reset(new DownloadHeadDelegate(self)); |
| 533 _contentFetcherDelegate.reset(new DownloadContentDelegate(self)); | 528 _contentFetcherDelegate.reset(new DownloadContentDelegate(self)); |
| 534 _downloadFilePath = base::FilePath(); | 529 _downloadFilePath = base::FilePath(); |
| 535 _storeKitLauncher.reset(storeLauncher); | 530 _storeKitLauncher.reset(storeLauncher); |
| 536 | 531 |
| 537 [_documentContainer | 532 [_documentContainer |
| 538 setBackgroundColor:UIColorFromRGB(kUndownloadedDocumentColor)]; | 533 setBackgroundColor:UIColorFromRGB(kUndownloadedDocumentColor)]; |
| 539 | 534 |
| 540 _isFileTypeLabelCentered = YES; | 535 _isFileTypeLabelCentered = YES; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 })); | 617 })); |
| 623 } | 618 } |
| 624 if (_recordDownloadResultHistogram) { | 619 if (_recordDownloadResultHistogram) { |
| 625 UMA_HISTOGRAM_ENUMERATION(kUMADownloadFileResult, DOWNLOAD_OTHER, | 620 UMA_HISTOGRAM_ENUMERATION(kUMADownloadFileResult, DOWNLOAD_OTHER, |
| 626 DOWNLOAD_FILE_RESULT_COUNT); | 621 DOWNLOAD_FILE_RESULT_COUNT); |
| 627 } | 622 } |
| 628 if (_recordFileActionHistogram) { | 623 if (_recordFileActionHistogram) { |
| 629 UMA_HISTOGRAM_ENUMERATION(kUMADownloadedFileAction, NO_ACTION, | 624 UMA_HISTOGRAM_ENUMERATION(kUMADownloadedFileAction, NO_ACTION, |
| 630 DOWNLOADED_FILE_ACTION_COUNT); | 625 DOWNLOADED_FILE_ACTION_COUNT); |
| 631 } | 626 } |
| 627 base::mac::ReleaseProperties(self); |
| 632 [super dealloc]; | 628 [super dealloc]; |
| 633 } | 629 } |
| 634 | 630 |
| 635 #pragma mark - Layout constraints | 631 #pragma mark - Layout constraints |
| 636 | 632 |
| 637 - (void)initConstraints { | 633 - (void)initConstraints { |
| 638 // Document Container | 634 // Document Container |
| 639 NSLayoutConstraint* portraitDocumentContainerWidth = | 635 NSLayoutConstraint* portraitDocumentContainerWidth = |
| 640 [_documentContainer.widthAnchor | 636 [_documentContainer.widthAnchor |
| 641 constraintEqualToConstant:kDocumentContainerWidthPortrait]; | 637 constraintEqualToConstant:kDocumentContainerWidthPortrait]; |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 | 1633 |
| 1638 #pragma mark - CRWNativeContent | 1634 #pragma mark - CRWNativeContent |
| 1639 | 1635 |
| 1640 - (void)close { | 1636 - (void)close { |
| 1641 // Makes sure that all outstanding network requests are shut down before | 1637 // Makes sure that all outstanding network requests are shut down before |
| 1642 // this controller is closed. | 1638 // this controller is closed. |
| 1643 _fetcher.reset(); | 1639 _fetcher.reset(); |
| 1644 } | 1640 } |
| 1645 | 1641 |
| 1646 @end | 1642 @end |
| OLD | NEW |