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/desktop_ui/browser_window.h" | 5 #include "mandoline/ui/desktop_ui/browser_window.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 break; | 227 break; |
228 default: | 228 default: |
229 NOTREACHED(); | 229 NOTREACHED(); |
230 break; | 230 break; |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 //////////////////////////////////////////////////////////////////////////////// | 234 //////////////////////////////////////////////////////////////////////////////// |
235 // BrowserWindow, web_view::mojom::WebViewClient implementation: | 235 // BrowserWindow, web_view::mojom::WebViewClient implementation: |
236 | 236 |
237 void BrowserWindow::TopLevelNavigate(mojo::URLRequestPtr request) { | 237 void BrowserWindow::TopLevelNavigateRequest(mojo::URLRequestPtr request) { |
238 Embed(request.Pass()); | 238 Embed(request.Pass()); |
239 } | 239 } |
240 | 240 |
| 241 void BrowserWindow::TopLevelNavigationStarted(const mojo::String& url) { |
| 242 GURL gurl(url); |
| 243 bool changed = current_url_ != gurl; |
| 244 current_url_ = gurl; |
| 245 if (changed) |
| 246 toolbar_view_->SetOmniboxText(base::UTF8ToUTF16(current_url_.spec())); |
| 247 } |
| 248 |
241 void BrowserWindow::LoadingStateChanged(bool is_loading, double progress) { | 249 void BrowserWindow::LoadingStateChanged(bool is_loading, double progress) { |
242 progress_bar_->SetIsLoading(is_loading); | 250 progress_bar_->SetIsLoading(is_loading); |
243 progress_bar_->SetProgress(progress); | 251 progress_bar_->SetProgress(progress); |
244 } | 252 } |
245 | 253 |
246 void BrowserWindow::BackForwardChanged( | 254 void BrowserWindow::BackForwardChanged( |
247 web_view::mojom::ButtonState back_button, | 255 web_view::mojom::ButtonState back_button, |
248 web_view::mojom::ButtonState forward_button) { | 256 web_view::mojom::ButtonState forward_button) { |
249 toolbar_view_->SetBackForwardEnabled( | 257 toolbar_view_->SetBackForwardEnabled( |
250 back_button == web_view::mojom::ButtonState::BUTTON_STATE_ENABLED, | 258 back_button == web_view::mojom::ButtonState::BUTTON_STATE_ENABLED, |
(...skipping 10 matching lines...) Expand all Loading... |
261 | 269 |
262 //////////////////////////////////////////////////////////////////////////////// | 270 //////////////////////////////////////////////////////////////////////////////// |
263 // BrowserWindow, ViewEmbedder implementation: | 271 // BrowserWindow, ViewEmbedder implementation: |
264 | 272 |
265 void BrowserWindow::Embed(mojo::URLRequestPtr request) { | 273 void BrowserWindow::Embed(mojo::URLRequestPtr request) { |
266 const std::string string_url = request->url.To<std::string>(); | 274 const std::string string_url = request->url.To<std::string>(); |
267 if (string_url == "mojo:omnibox") { | 275 if (string_url == "mojo:omnibox") { |
268 EmbedOmnibox(); | 276 EmbedOmnibox(); |
269 return; | 277 return; |
270 } | 278 } |
271 | |
272 GURL gurl(string_url); | |
273 bool changed = current_url_ != gurl; | |
274 current_url_ = gurl; | |
275 if (changed) | |
276 toolbar_view_->SetOmniboxText(base::UTF8ToUTF16(current_url_.spec())); | |
277 | |
278 web_view_.web_view()->LoadRequest(request.Pass()); | 279 web_view_.web_view()->LoadRequest(request.Pass()); |
279 } | 280 } |
280 | 281 |
281 //////////////////////////////////////////////////////////////////////////////// | 282 //////////////////////////////////////////////////////////////////////////////// |
282 // BrowserWindow, mojo::InterfaceFactory<ViewEmbedder> implementation: | 283 // BrowserWindow, mojo::InterfaceFactory<ViewEmbedder> implementation: |
283 | 284 |
284 void BrowserWindow::Create(mojo::ApplicationConnection* connection, | 285 void BrowserWindow::Create(mojo::ApplicationConnection* connection, |
285 mojo::InterfaceRequest<ViewEmbedder> request) { | 286 mojo::InterfaceRequest<ViewEmbedder> request) { |
286 view_embedder_bindings_.AddBinding(this, request.Pass()); | 287 view_embedder_bindings_.AddBinding(this, request.Pass()); |
287 } | 288 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 omnibox_view_->Embed(view_tree_client.Pass()); | 362 omnibox_view_->Embed(view_tree_client.Pass()); |
362 | 363 |
363 // TODO(beng): This should be handled sufficiently by | 364 // TODO(beng): This should be handled sufficiently by |
364 // OmniboxImpl::ShowWindow() but unfortunately view manager policy | 365 // OmniboxImpl::ShowWindow() but unfortunately view manager policy |
365 // currently prevents the embedded app from changing window z for | 366 // currently prevents the embedded app from changing window z for |
366 // its own window. | 367 // its own window. |
367 omnibox_view_->MoveToFront(); | 368 omnibox_view_->MoveToFront(); |
368 } | 369 } |
369 | 370 |
370 } // namespace mandoline | 371 } // namespace mandoline |
OLD | NEW |