OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/contents/blimp_navigation_controller_impl.h" | 5 #include "blimp/client/core/contents/blimp_navigation_controller_impl.h" |
6 | 6 |
7 #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h" | 7 #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h" |
8 | 8 |
9 namespace { | |
10 // TODO(shaktisahu): NavigationFeature currently needs a tab_id. Remove this | |
11 // later when it is fully integrated with BlimpClientContext. | |
12 const int kDummyTabId = 0; | |
13 } // namespace | |
14 | |
15 namespace blimp { | 9 namespace blimp { |
16 namespace client { | 10 namespace client { |
17 | 11 |
18 BlimpNavigationControllerImpl::BlimpNavigationControllerImpl( | 12 BlimpNavigationControllerImpl::BlimpNavigationControllerImpl( |
| 13 int blimp_contents_id, |
19 BlimpNavigationControllerDelegate* delegate, | 14 BlimpNavigationControllerDelegate* delegate, |
20 NavigationFeature* feature) | 15 NavigationFeature* feature) |
21 : navigation_feature_(feature), delegate_(delegate) { | 16 : blimp_contents_id_(blimp_contents_id), |
| 17 navigation_feature_(feature), |
| 18 delegate_(delegate) { |
22 if (navigation_feature_) | 19 if (navigation_feature_) |
23 navigation_feature_->SetDelegate(kDummyTabId, this); | 20 navigation_feature_->SetDelegate(blimp_contents_id_, this); |
24 } | 21 } |
25 | 22 |
26 BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() { | 23 BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() { |
27 if (navigation_feature_) | 24 if (navigation_feature_) |
28 navigation_feature_->RemoveDelegate(kDummyTabId); | 25 navigation_feature_->RemoveDelegate(blimp_contents_id_); |
29 } | 26 } |
30 | 27 |
31 void BlimpNavigationControllerImpl::LoadURL(const GURL& url) { | 28 void BlimpNavigationControllerImpl::LoadURL(const GURL& url) { |
32 current_url_ = url; | 29 current_url_ = url; |
33 navigation_feature_->NavigateToUrlText(kDummyTabId, current_url_.spec()); | 30 navigation_feature_->NavigateToUrlText(blimp_contents_id_, |
| 31 current_url_.spec()); |
34 } | 32 } |
35 | 33 |
36 void BlimpNavigationControllerImpl::Reload() { | 34 void BlimpNavigationControllerImpl::Reload() { |
37 navigation_feature_->Reload(kDummyTabId); | 35 navigation_feature_->Reload(blimp_contents_id_); |
38 } | 36 } |
39 | 37 |
40 bool BlimpNavigationControllerImpl::CanGoBack() const { | 38 bool BlimpNavigationControllerImpl::CanGoBack() const { |
41 NOTIMPLEMENTED(); | 39 NOTIMPLEMENTED(); |
42 return true; | 40 return true; |
43 } | 41 } |
44 | 42 |
45 bool BlimpNavigationControllerImpl::CanGoForward() const { | 43 bool BlimpNavigationControllerImpl::CanGoForward() const { |
46 NOTIMPLEMENTED(); | 44 NOTIMPLEMENTED(); |
47 return true; | 45 return true; |
48 } | 46 } |
49 | 47 |
50 void BlimpNavigationControllerImpl::GoBack() { | 48 void BlimpNavigationControllerImpl::GoBack() { |
51 navigation_feature_->GoBack(kDummyTabId); | 49 navigation_feature_->GoBack(blimp_contents_id_); |
52 } | 50 } |
53 | 51 |
54 void BlimpNavigationControllerImpl::GoForward() { | 52 void BlimpNavigationControllerImpl::GoForward() { |
55 navigation_feature_->GoForward(kDummyTabId); | 53 navigation_feature_->GoForward(blimp_contents_id_); |
56 } | 54 } |
57 | 55 |
58 const GURL& BlimpNavigationControllerImpl::GetURL() { | 56 const GURL& BlimpNavigationControllerImpl::GetURL() { |
59 return current_url_; | 57 return current_url_; |
60 } | 58 } |
61 | 59 |
62 const std::string& BlimpNavigationControllerImpl::GetTitle() { | 60 const std::string& BlimpNavigationControllerImpl::GetTitle() { |
63 return current_title_; | 61 return current_title_; |
64 } | 62 } |
65 | 63 |
(...skipping 18 matching lines...) Expand all Loading... |
84 delegate_->OnLoadingStateChanged(loading); | 82 delegate_->OnLoadingStateChanged(loading); |
85 } | 83 } |
86 | 84 |
87 void BlimpNavigationControllerImpl::OnPageLoadStatusUpdate(int tab_id, | 85 void BlimpNavigationControllerImpl::OnPageLoadStatusUpdate(int tab_id, |
88 bool completed) { | 86 bool completed) { |
89 delegate_->OnNavigationStateChanged(); | 87 delegate_->OnNavigationStateChanged(); |
90 } | 88 } |
91 | 89 |
92 } // namespace client | 90 } // namespace client |
93 } // namespace blimp | 91 } // namespace blimp |
OLD | NEW |