| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mandoline/ui/browser/navigator_host_impl.h" | 5 #include "mandoline/ui/browser/navigator_host_impl.h" |
| 6 | 6 |
| 7 #include "mandoline/ui/browser/browser.h" | 7 #include "mandoline/ui/browser/browser.h" |
| 8 | 8 |
| 9 namespace mandoline { | 9 namespace mandoline { |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 void NavigatorHostImpl::DidNavigateLocally(const mojo::String& url) { | 23 void NavigatorHostImpl::DidNavigateLocally(const mojo::String& url) { |
| 24 RecordNavigation(url); | 24 RecordNavigation(url); |
| 25 // TODO(abarth): Do something interesting. | 25 // TODO(abarth): Do something interesting. |
| 26 } | 26 } |
| 27 | 27 |
| 28 void NavigatorHostImpl::RequestNavigate(mojo::Target target, | 28 void NavigatorHostImpl::RequestNavigate(mojo::Target target, |
| 29 mojo::URLRequestPtr request) { | 29 mojo::URLRequestPtr request) { |
| 30 // The Browser sets up default services including navigation. | 30 // The Browser sets up default services including navigation. |
| 31 browser_->ReplaceContentWithURL(request->url); | 31 browser_->ReplaceContentWithRequest(request.Pass()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void NavigatorHostImpl::RequestNavigateHistory(int32_t delta) { | 34 void NavigatorHostImpl::RequestNavigateHistory(int32_t delta) { |
| 35 if (history_.empty()) | 35 if (history_.empty()) |
| 36 return; | 36 return; |
| 37 current_index_ = | 37 current_index_ = |
| 38 std::max(0, std::min(current_index_ + delta, | 38 std::max(0, std::min(current_index_ + delta, |
| 39 static_cast<int32_t>(history_.size()) - 1)); | 39 static_cast<int32_t>(history_.size()) - 1)); |
| 40 browser_->ReplaceContentWithURL(history_[current_index_]); | 40 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 41 request->url = mojo::String::From(history_[current_index_]); |
| 42 browser_->ReplaceContentWithRequest(request.Pass()); |
| 41 } | 43 } |
| 42 | 44 |
| 43 void NavigatorHostImpl::RecordNavigation(const std::string& url) { | 45 void NavigatorHostImpl::RecordNavigation(const std::string& url) { |
| 44 if (current_index_ >= 0 && history_[current_index_] == url) { | 46 if (current_index_ >= 0 && history_[current_index_] == url) { |
| 45 // This is a navigation to the current entry, ignore. | 47 // This is a navigation to the current entry, ignore. |
| 46 return; | 48 return; |
| 47 } | 49 } |
| 48 | 50 |
| 49 history_.erase(history_.begin() + (current_index_ + 1), history_.end()); | 51 history_.erase(history_.begin() + (current_index_ + 1), history_.end()); |
| 50 history_.push_back(url); | 52 history_.push_back(url); |
| 51 ++current_index_; | 53 ++current_index_; |
| 52 } | 54 } |
| 53 | 55 |
| 54 } // namespace mandoline | 56 } // namespace mandoline |
| OLD | NEW |