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

Side by Side Diff: services/navigation/public/cpp/view.cc

Issue 2493693003: Mojo C++ bindings: switch services/navigation mojom target to use STL types. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « services/navigation/public/cpp/view.h ('k') | services/navigation/public/interfaces/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "services/navigation/public/cpp/view.h" 5 #include "services/navigation/public/cpp/view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "services/navigation/public/cpp/view_delegate.h" 8 #include "services/navigation/public/cpp/view_delegate.h"
9 #include "services/navigation/public/cpp/view_observer.h" 9 #include "services/navigation/public/cpp/view_observer.h"
10 #include "services/ui/public/cpp/window.h" 10 #include "services/ui/public/cpp/window.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 void View::GoForward() { 49 void View::GoForward() {
50 if (can_go_forward_) 50 if (can_go_forward_)
51 view_->GoForward(); 51 view_->GoForward();
52 } 52 }
53 53
54 void View::GetBackMenuItems(std::vector<NavigationListItem>* items) { 54 void View::GetBackMenuItems(std::vector<NavigationListItem>* items) {
55 DCHECK(items); 55 DCHECK(items);
56 for (int i = navigation_list_cursor_ - 1, offset = -1; i >= 0; 56 for (int i = navigation_list_cursor_ - 1, offset = -1; i >= 0;
57 --i, --offset) { 57 --i, --offset) {
58 std::string title = navigation_list_[i]->title; 58 items->push_back(NavigationListItem(
59 items->push_back(NavigationListItem(base::UTF8ToUTF16(title), offset)); 59 base::UTF8ToUTF16(navigation_list_[i]->title), offset));
60 } 60 }
61 } 61 }
62 62
63 void View::GetForwardMenuItems(std::vector<NavigationListItem>* items) { 63 void View::GetForwardMenuItems(std::vector<NavigationListItem>* items) {
64 DCHECK(items); 64 DCHECK(items);
65 for (int i = navigation_list_cursor_ + 1, offset = 1; 65 for (int i = navigation_list_cursor_ + 1, offset = 1;
66 i < static_cast<int>(navigation_list_.size()); ++i, ++offset) { 66 i < static_cast<int>(navigation_list_.size()); ++i, ++offset) {
67 std::string title = navigation_list_[i]->title; 67 items->push_back(NavigationListItem(
68 items->push_back(NavigationListItem(base::UTF8ToUTF16(title), offset)); 68 base::UTF8ToUTF16(navigation_list_[i]->title), offset));
69 } 69 }
70 } 70 }
71 71
72 void View::Reload(bool bypass_cache) { 72 void View::Reload(bool bypass_cache) {
73 view_->Reload(bypass_cache); 73 view_->Reload(bypass_cache);
74 } 74 }
75 75
76 void View::Stop() { 76 void View::Stop() {
77 view_->Stop(); 77 view_->Stop();
78 } 78 }
(...skipping 20 matching lines...) Expand all
99 delegate_->OpenURL(this, std::move(params)); 99 delegate_->OpenURL(this, std::move(params));
100 } 100 }
101 101
102 void View::LoadingStateChanged(bool is_loading) { 102 void View::LoadingStateChanged(bool is_loading) {
103 is_loading_ = is_loading; 103 is_loading_ = is_loading;
104 for (auto& observer : observers_) 104 for (auto& observer : observers_)
105 observer.LoadingStateChanged(this); 105 observer.LoadingStateChanged(this);
106 } 106 }
107 107
108 void View::NavigationStateChanged(const GURL& url, 108 void View::NavigationStateChanged(const GURL& url,
109 const mojo::String& title, 109 const std::string& title,
110 bool can_go_back, 110 bool can_go_back,
111 bool can_go_forward) { 111 bool can_go_forward) {
112 url_ = url; 112 url_ = url;
113 title_ = base::UTF8ToUTF16(title.get()); 113 title_ = base::UTF8ToUTF16(title);
114 can_go_back_ = can_go_back; 114 can_go_back_ = can_go_back;
115 can_go_forward_ = can_go_forward; 115 can_go_forward_ = can_go_forward;
116 for (auto& observer : observers_) 116 for (auto& observer : observers_)
117 observer.NavigationStateChanged(this); 117 observer.NavigationStateChanged(this);
118 } 118 }
119 119
120 void View::LoadProgressChanged(double progress) { 120 void View::LoadProgressChanged(double progress) {
121 for (auto& observer : observers_) 121 for (auto& observer : observers_)
122 observer.LoadProgressChanged(this, progress); 122 observer.LoadProgressChanged(this, progress);
123 } 123 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (from_front) { 173 if (from_front) {
174 auto it = navigation_list_.begin() + count; 174 auto it = navigation_list_.begin() + count;
175 navigation_list_.erase(navigation_list_.begin(), it); 175 navigation_list_.erase(navigation_list_.begin(), it);
176 } else { 176 } else {
177 auto it = navigation_list_.end() - count; 177 auto it = navigation_list_.end() - count;
178 navigation_list_.erase(it, navigation_list_.end()); 178 navigation_list_.erase(it, navigation_list_.end());
179 } 179 }
180 } 180 }
181 181
182 } // namespace navigation 182 } // namespace navigation
OLDNEW
« no previous file with comments | « services/navigation/public/cpp/view.h ('k') | services/navigation/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698