OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_mediator.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/sys_string_conversions.h" |
| 9 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_consumer.h" |
| 10 #include "ios/web/public/web_state/web_state.h" |
| 11 #import "ios/web/public/web_state/web_state_observer_bridge.h" |
| 12 |
| 13 @interface ToolbarMediator ()<CRWWebStateObserver> |
| 14 @end |
| 15 |
| 16 @implementation ToolbarMediator { |
| 17 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; |
| 18 } |
| 19 |
| 20 @synthesize consumer = _consumer; |
| 21 @synthesize webState = _webState; |
| 22 |
| 23 - (void)dealloc { |
| 24 _webStateObserver.reset(); |
| 25 _webState = nullptr; |
| 26 } |
| 27 |
| 28 - (void)setWebState:(web::WebState*)webState { |
| 29 _webState = webState; |
| 30 _webStateObserver = |
| 31 base::MakeUnique<web::WebStateObserverBridge>(self.webState, self); |
| 32 } |
| 33 |
| 34 #pragma mark - CRWWebStateObserver |
| 35 |
| 36 - (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success { |
| 37 const GURL& pageURL = webState->GetVisibleURL(); |
| 38 [self.consumer setCurrentPageText:base::SysUTF8ToNSString(pageURL.spec())]; |
| 39 } |
| 40 |
| 41 @end |
OLD | NEW |