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