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

Side by Side Diff: ios/clean/chrome/browser/ui/toolbar/toolbar_mediator.mm

Issue 2859363002: [ios clean] Adds Progress Bar to Toolbar. (Closed)
Patch Set: Uses MDCProgressView and adds unittest. Created 3 years, 7 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 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/toolbar/toolbar_mediator.h" 5 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_mediator.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_consumer.h" 9 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_consumer.h"
10 #import "ios/web/public/navigation_manager.h" 10 #import "ios/web/public/navigation_manager.h"
(...skipping 15 matching lines...) Expand all
26 @synthesize webState = _webState; 26 @synthesize webState = _webState;
27 27
28 - (void)dealloc { 28 - (void)dealloc {
29 _webStateObserver.reset(); 29 _webStateObserver.reset();
30 _webState = nullptr; 30 _webState = nullptr;
31 } 31 }
32 32
33 #pragma mark - CRWWebStateObserver 33 #pragma mark - CRWWebStateObserver
34 34
35 - (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success { 35 - (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success {
36 const GURL& pageURL = webState->GetVisibleURL();
37 [self.consumer setCurrentPageText:base::SysUTF8ToNSString(pageURL.spec())];
38 [self.consumer 36 [self.consumer
39 setCanGoBack:self.webState->GetNavigationManager()->CanGoBack()]; 37 setCanGoBack:self.webState->GetNavigationManager()->CanGoBack()];
40 [self.consumer 38 [self.consumer
41 setCanGoForward:self.webState->GetNavigationManager()->CanGoForward()]; 39 setCanGoForward:self.webState->GetNavigationManager()->CanGoForward()];
42 } 40 }
43 41
44 - (void)webStateDidStartLoading:(web::WebState*)webState { 42 - (void)webStateDidStartLoading:(web::WebState*)webState {
45 [self.consumer setIsLoading:self.webState->IsLoading()]; 43 [self.consumer setIsLoading:self.webState->IsLoading()];
46 } 44 }
47 45
48 - (void)webStateDidStopLoading:(web::WebState*)webState { 46 - (void)webStateDidStopLoading:(web::WebState*)webState {
49 [self.consumer setIsLoading:self.webState->IsLoading()]; 47 [self.consumer setIsLoading:self.webState->IsLoading()];
50 } 48 }
51 49
50 - (void)webState:(web::WebState*)webState
51 didChangeLoadingProgress:(double)progress {
52 [self.consumer setLoadingProgress:progress];
53 }
54
52 #pragma mark - Setters 55 #pragma mark - Setters
53 56
54 - (void)setWebState:(web::WebState*)webState { 57 - (void)setWebState:(web::WebState*)webState {
55 _webState = webState; 58 _webState = webState;
56 _webStateObserver = 59 _webStateObserver =
57 base::MakeUnique<web::WebStateObserverBridge>(_webState, self); 60 base::MakeUnique<web::WebStateObserverBridge>(_webState, self);
58 if (self.consumer) { 61 if (self.consumer) {
59 [self updateConsumer]; 62 [self updateConsumer];
60 } 63 }
61 } 64 }
62 65
63 - (void)setConsumer:(id<ToolbarConsumer>)consumer { 66 - (void)setConsumer:(id<ToolbarConsumer>)consumer {
64 _consumer = consumer; 67 _consumer = consumer;
65 if (self.webState) { 68 if (self.webState) {
66 [self updateConsumer]; 69 [self updateConsumer];
67 } 70 }
68 } 71 }
69 72
70 #pragma mark - Helper methods 73 #pragma mark - Helper methods
71 74
72 // Updates the consumer to match the current WebState. 75 // Updates the consumer to match the current WebState.
73 - (void)updateConsumer { 76 - (void)updateConsumer {
74 DCHECK(self.webState); 77 DCHECK(self.webState);
75 DCHECK(self.consumer); 78 DCHECK(self.consumer);
76 const GURL& pageURL = self.webState->GetVisibleURL();
77 [self.consumer 79 [self.consumer
78 setCanGoForward:self.webState->GetNavigationManager()->CanGoForward()]; 80 setCanGoForward:self.webState->GetNavigationManager()->CanGoForward()];
79 [self.consumer 81 [self.consumer
80 setCanGoBack:self.webState->GetNavigationManager()->CanGoBack()]; 82 setCanGoBack:self.webState->GetNavigationManager()->CanGoBack()];
81 [self.consumer setCurrentPageText:base::SysUTF8ToNSString(pageURL.spec())];
82 [self.consumer setIsLoading:self.webState->IsLoading()]; 83 [self.consumer setIsLoading:self.webState->IsLoading()];
83 } 84 }
84 85
85 @end 86 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698