Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: ios/chrome/browser/ui/external_file_controller.mm

Issue 2804703002: [ObjC ARC] Converts ios/chrome/browser/ui:ui_internal_arc to ARC. (Closed)
Patch Set: comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/external_file_controller.h" 5 #import "ios/chrome/browser/ui/external_file_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #import "base/mac/scoped_nsobject.h"
11 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
12 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
13 #import "ios/chrome/browser/tabs/tab_model.h" 12 #import "ios/chrome/browser/tabs/tab_model.h"
14 #import "ios/web/public/web_view_creation_util.h" 13 #import "ios/web/public/web_view_creation_util.h"
15 14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
16 namespace { 19 namespace {
17 20
18 // The path relative to the <Application_Home>/Documents/ directory where the 21 // The path relative to the <Application_Home>/Documents/ directory where the
19 // files received from other applications are saved. 22 // files received from other applications are saved.
20 NSString* const kInboxPath = @"Inbox"; 23 NSString* const kInboxPath = @"Inbox";
21 24
22 // Conversion factor to turn number of days to number of seconds. 25 // Conversion factor to turn number of days to number of seconds.
23 const CFTimeInterval kSecondsPerDay = 60 * 60 * 24; 26 const CFTimeInterval kSecondsPerDay = 60 * 60 * 24;
24 27
25 } // namespace 28 } // namespace
26 29
27 @interface ExternalFileController () 30 @interface ExternalFileController ()
28 // Returns the path to the Inbox directory. 31 // Returns the path to the Inbox directory.
29 + (NSString*)inboxDirectoryPath; 32 + (NSString*)inboxDirectoryPath;
30 @end 33 @end
31 34
32 @implementation ExternalFileController { 35 @implementation ExternalFileController {
33 base::scoped_nsobject<WKWebView> _webView; 36 WKWebView* _webView;
34 } 37 }
35 38
36 - (instancetype)initWithURL:(const GURL&)URL 39 - (instancetype)initWithURL:(const GURL&)URL
37 browserState:(web::BrowserState*)browserState { 40 browserState:(web::BrowserState*)browserState {
38 self = [super initWithURL:URL]; 41 self = [super initWithURL:URL];
39 if (self) { 42 if (self) {
40 _webView.reset([web::BuildWKWebView(CGRectZero, browserState) retain]); 43 _webView = web::BuildWKWebView(CGRectZero, browserState);
41 [_webView setBackgroundColor:[UIColor whiteColor]]; 44 [_webView setBackgroundColor:[UIColor whiteColor]];
42 [_webView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | 45 [_webView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth |
43 UIViewAutoresizingFlexibleHeight)]; 46 UIViewAutoresizingFlexibleHeight)];
44 [_webView setUserInteractionEnabled:YES]; 47 [_webView setUserInteractionEnabled:YES];
45 base::scoped_nsobject<UIView> view( 48 UIView* view = [[UIView alloc] initWithFrame:CGRectZero];
46 [[UIView alloc] initWithFrame:CGRectZero]);
47 self.view = view; 49 self.view = view;
48 [self.view addSubview:_webView]; 50 [self.view addSubview:_webView];
49 [self.view setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | 51 [self.view setAutoresizingMask:(UIViewAutoresizingFlexibleWidth |
50 UIViewAutoresizingFlexibleHeight)]; 52 UIViewAutoresizingFlexibleHeight)];
51 NSString* filePath = [ExternalFileController pathForExternalFileURL:URL]; 53 NSString* filePath = [ExternalFileController pathForExternalFileURL:URL];
52 DCHECK([[NSFileManager defaultManager] fileExistsAtPath:filePath]); 54 DCHECK([[NSFileManager defaultManager] fileExistsAtPath:filePath]);
53 // TODO(cgrigoruta): Currently only PDFs are supported. Change it to support 55 // TODO(cgrigoruta): Currently only PDFs are supported. Change it to support
54 // other file types as well. 56 // other file types as well.
55 NSURL* fileURL = [NSURL fileURLWithPath:filePath]; 57 NSURL* fileURL = [NSURL fileURLWithPath:filePath];
56 DCHECK(fileURL); 58 DCHECK(fileURL);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (error) { 111 if (error) {
110 DLOG(ERROR) << "Failed to remove file " << filePath << ": " 112 DLOG(ERROR) << "Failed to remove file " << filePath << ": "
111 << base::SysNSStringToUTF8([error description]); 113 << base::SysNSStringToUTF8([error description]);
112 continue; 114 continue;
113 } 115 }
114 } 116 }
115 } 117 }
116 118
117 - (void)dealloc { 119 - (void)dealloc {
118 [_webView removeFromSuperview]; 120 [_webView removeFromSuperview];
119 [super dealloc];
120 } 121 }
121 122
122 @end 123 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/chrome_web_view_factory.mm ('k') | ios/chrome/browser/ui/external_file_remover.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698