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

Side by Side Diff: ios/chrome/browser/ui/first_run/static_file_view_controller.mm

Issue 2590473002: Upstream Chrome on iOS source code [5/11]. (Closed)
Patch Set: Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/ui/first_run/static_file_view_controller.h"
6
7 #include <WebKit/WebKit.h>
8
9 #include "base/logging.h"
10 #include "base/mac/scoped_nsobject.h"
11 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
12 #import "ios/chrome/browser/ui/material_components/utils.h"
13 #include "ios/chrome/browser/ui/rtl_geometry.h"
14 #import "ios/third_party/material_components_ios/src/components/AppBar/src/Mater ialAppBar.h"
15 #import "ios/third_party/material_components_ios/src/components/FlexibleHeader/s rc/MaterialFlexibleHeader.h"
16 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h"
17 #import "ios/web/public/web_view_creation_util.h"
18
19 @interface StaticFileViewController ()<UIScrollViewDelegate> {
20 ios::ChromeBrowserState* _browserState; // weak
21 base::scoped_nsobject<NSURL> _URL;
22 // YES if the header has been configured for RTL.
23 BOOL _headerLaidOutForRTL;
24 // The web view used to display the static content.
25 base::scoped_nsobject<WKWebView> _webView;
26 // The header.
27 base::scoped_nsobject<MDCAppBar> _appBar;
28 }
29
30 @end
31
32 @implementation StaticFileViewController
33
34 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
35 URL:(NSURL*)URL {
36 DCHECK(browserState);
37 DCHECK(URL);
38 self = [super init];
39 if (self) {
40 _appBar.reset([[MDCAppBar alloc] init]);
41 [self addChildViewController:[_appBar headerViewController]];
42 _browserState = browserState;
43 _URL.reset([URL retain]);
44 }
45 return self;
46 }
47
48 - (void)dealloc {
49 [_webView scrollView].delegate = nil;
50 [super dealloc];
51 }
52
53 #pragma mark - UIViewController
54
55 - (void)viewDidLoad {
56 [super viewDidLoad];
57
58 _webView.reset([web::BuildWKWebView(self.view.bounds, _browserState) retain]);
59 [_webView setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
60 UIViewAutoresizingFlexibleHeight];
61
62 // Loads terms of service into the web view.
63 [_webView loadRequest:[NSURLRequest requestWithURL:_URL]];
64 [_webView setBackgroundColor:[UIColor whiteColor]];
65 [self.view addSubview:_webView];
66
67 ConfigureAppBarWithCardStyle(_appBar);
68 [_appBar headerViewController].headerView.trackingScrollView =
69 [_webView scrollView];
70 [_webView scrollView].delegate = [_appBar headerViewController];
71
72 // Add the app bar at the end.
73 [_appBar addSubviewsToParent];
74 }
75
76 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698