OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "ios/chrome/browser/ui/first_run/static_file_view_controller.h" | 5 #include "ios/chrome/browser/ui/first_run/static_file_view_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 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
11 #import "ios/chrome/browser/ui/icons/chrome_icon.h" | |
11 #import "ios/chrome/browser/ui/material_components/utils.h" | 12 #import "ios/chrome/browser/ui/material_components/utils.h" |
12 #include "ios/chrome/browser/ui/rtl_geometry.h" | 13 #include "ios/chrome/browser/ui/rtl_geometry.h" |
13 #import "ios/third_party/material_components_ios/src/components/AppBar/src/Mater ialAppBar.h" | 14 #import "ios/third_party/material_components_ios/src/components/AppBar/src/Mater ialAppBar.h" |
14 #import "ios/third_party/material_components_ios/src/components/FlexibleHeader/s rc/MaterialFlexibleHeader.h" | 15 #import "ios/third_party/material_components_ios/src/components/FlexibleHeader/s rc/MaterialFlexibleHeader.h" |
15 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h" | 16 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h" |
16 #import "ios/web/public/web_view_creation_util.h" | 17 #import "ios/web/public/web_view_creation_util.h" |
17 | 18 |
18 #if !defined(__has_feature) || !__has_feature(objc_arc) | 19 #if !defined(__has_feature) || !__has_feature(objc_arc) |
19 #error "This file requires ARC support." | 20 #error "This file requires ARC support." |
20 #endif | 21 #endif |
21 | 22 |
22 @interface StaticFileViewController ()<UIScrollViewDelegate> { | 23 @interface StaticFileViewController ()<UIScrollViewDelegate> { |
23 ios::ChromeBrowserState* _browserState; // weak | 24 ios::ChromeBrowserState* _browserState; // weak |
24 NSURL* _URL; | 25 NSURL* _URL; |
25 // YES if the header has been configured for RTL. | 26 // YES if the header has been configured for RTL. |
26 BOOL _headerLaidOutForRTL; | 27 BOOL _headerLaidOutForRTL; |
27 // The web view used to display the static content. | 28 // The web view used to display the static content. |
28 WKWebView* _webView; | 29 WKWebView* _webView; |
29 // The header. | 30 // The header. |
30 MDCAppBar* _appBar; | 31 MDCAppBar* _appBar; |
31 } | 32 } |
32 | 33 |
kkhorimoto
2017/03/29 20:48:18
Can we add |-back| to this class's private interfa
lpromero
2017/03/30 12:53:48
Done.
| |
33 @end | 34 @end |
34 | 35 |
35 @implementation StaticFileViewController | 36 @implementation StaticFileViewController |
36 | 37 |
37 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState | 38 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState |
38 URL:(NSURL*)URL { | 39 URL:(NSURL*)URL { |
39 DCHECK(browserState); | 40 DCHECK(browserState); |
40 DCHECK(URL); | 41 DCHECK(URL); |
41 self = [super init]; | 42 self = [super init]; |
42 if (self) { | 43 if (self) { |
(...skipping 23 matching lines...) Expand all Loading... | |
66 [_webView setBackgroundColor:[UIColor whiteColor]]; | 67 [_webView setBackgroundColor:[UIColor whiteColor]]; |
67 [self.view addSubview:_webView]; | 68 [self.view addSubview:_webView]; |
68 | 69 |
69 ConfigureAppBarWithCardStyle(_appBar); | 70 ConfigureAppBarWithCardStyle(_appBar); |
70 [_appBar headerViewController].headerView.trackingScrollView = | 71 [_appBar headerViewController].headerView.trackingScrollView = |
71 [_webView scrollView]; | 72 [_webView scrollView]; |
72 [_webView scrollView].delegate = [_appBar headerViewController]; | 73 [_webView scrollView].delegate = [_appBar headerViewController]; |
73 | 74 |
74 // Add the app bar at the end. | 75 // Add the app bar at the end. |
75 [_appBar addSubviewsToParent]; | 76 [_appBar addSubviewsToParent]; |
77 | |
78 // Create a custom Back bar button item, as Material Navigation Bar deprecated | |
79 // the back arrow with a shaft. | |
80 self.navigationItem.leftBarButtonItem = | |
81 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] | |
82 target:self | |
83 action:@selector(back)]; | |
84 } | |
85 | |
86 #pragma mark - Actions | |
87 | |
88 - (void)back { | |
89 [self.navigationController popViewControllerAnimated:YES]; | |
76 } | 90 } |
77 | 91 |
78 @end | 92 @end |
OLD | NEW |