OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" | 5 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" |
6 | 6 |
| 7 #include "ios/chrome/browser/chrome_url_constants.h" |
7 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_consumer.h" | 8 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_consumer.h" |
8 #import "ios/web/public/navigation_manager.h" | 9 #import "ios/web/public/navigation_manager.h" |
9 #include "ios/web/public/web_state/web_state.h" | 10 #include "ios/web/public/web_state/web_state.h" |
10 #include "ui/base/page_transition_types.h" | 11 #include "ui/base/page_transition_types.h" |
11 #include "url/gurl.h" | 12 #include "url/gurl.h" |
12 | 13 |
13 #if !defined(__has_feature) || !__has_feature(objc_arc) | 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
14 #error "This file requires ARC support." | 15 #error "This file requires ARC support." |
15 #endif | 16 #endif |
16 | 17 |
17 @implementation WebContentsMediator | 18 @implementation WebContentsMediator |
18 @synthesize webState = _webState; | 19 @synthesize webState = _webState; |
19 @synthesize consumer = _consumer; | 20 @synthesize consumer = _consumer; |
20 | 21 |
21 - (void)setWebState:(web::WebState*)webState { | 22 - (void)setWebState:(web::WebState*)webState { |
22 if (_webState) | 23 if (_webState) |
23 _webState->SetWebUsageEnabled(false); | 24 _webState->SetWebUsageEnabled(false); |
24 | 25 |
25 _webState = webState; | 26 _webState = webState; |
26 if (!self.webState) | 27 if (!self.webState) |
27 return; | 28 return; |
28 | 29 |
29 self.webState->SetWebUsageEnabled(true); | 30 self.webState->SetWebUsageEnabled(true); |
30 if (!self.webState->GetNavigationManager()->GetItemCount()) { | 31 if (!self.webState->GetNavigationManager()->GetItemCount()) { |
31 web::NavigationManager::WebLoadParams params( | 32 web::NavigationManager::WebLoadParams params((GURL(kChromeUINewTabURL))); |
32 GURL("https://dev.chromium.org/")); | |
33 params.transition_type = ui::PAGE_TRANSITION_TYPED; | 33 params.transition_type = ui::PAGE_TRANSITION_TYPED; |
34 self.webState->GetNavigationManager()->LoadURLWithParams(params); | 34 self.webState->GetNavigationManager()->LoadURLWithParams(params); |
35 } | 35 } |
36 [self.consumer contentViewDidChange:self.webState->GetView()]; | 36 [self.consumer contentViewDidChange:self.webState->GetView()]; |
37 } | 37 } |
38 | 38 |
39 - (void)setConsumer:(id<WebContentsConsumer>)consumer { | 39 - (void)setConsumer:(id<WebContentsConsumer>)consumer { |
40 _consumer = consumer; | 40 _consumer = consumer; |
41 if (self.webState) | 41 if (self.webState) |
42 [self.consumer contentViewDidChange:self.webState->GetView()]; | 42 [self.consumer contentViewDidChange:self.webState->GetView()]; |
43 } | 43 } |
44 | 44 |
45 @end | 45 @end |
OLD | NEW |