| 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 "chrome/browser/android/vr_shell/ui_interface.h" | 5 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h" | 7 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h" |
| 8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 | 9 |
| 10 namespace vr_shell { | 10 namespace vr_shell { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void UiInterface::SetWebVRSecureOrigin(bool secure) { | 46 void UiInterface::SetWebVRSecureOrigin(bool secure) { |
| 47 updates_.SetBoolean("webVRSecureOrigin", secure); | 47 updates_.SetBoolean("webVRSecureOrigin", secure); |
| 48 FlushUpdates(); | 48 FlushUpdates(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void UiInterface::SetLoading(bool loading) { | 51 void UiInterface::SetLoading(bool loading) { |
| 52 updates_.SetBoolean("loading", loading); | 52 updates_.SetBoolean("loading", loading); |
| 53 FlushUpdates(); | 53 FlushUpdates(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void UiInterface::SetLoadProgress(double progress) { |
| 57 updates_.SetDouble("loadProgress", progress); |
| 58 FlushUpdates(); |
| 59 } |
| 60 |
| 56 void UiInterface::SetURL(const GURL& url) { | 61 void UiInterface::SetURL(const GURL& url) { |
| 57 std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue); | 62 std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue); |
| 58 details->SetString("host", url.host()); | 63 details->SetString("host", url.host()); |
| 59 details->SetString("path", url.path()); | 64 details->SetString("path", url.path()); |
| 60 | 65 |
| 61 updates_.Set("url", std::move(details)); | 66 updates_.Set("url", std::move(details)); |
| 62 FlushUpdates(); | 67 FlushUpdates(); |
| 63 } | 68 } |
| 64 | 69 |
| 65 void UiInterface::OnDomContentsLoaded() { | 70 void UiInterface::OnDomContentsLoaded() { |
| 66 loaded_ = true; | 71 loaded_ = true; |
| 67 #if defined(ENABLE_VR_SHELL_UI_DEV) | 72 #if defined(ENABLE_VR_SHELL_UI_DEV) |
| 68 updates_.SetBoolean("enableReloadUi", true); | 73 updates_.SetBoolean("enableReloadUi", true); |
| 69 #endif | 74 #endif |
| 70 FlushUpdates(); | 75 FlushUpdates(); |
| 71 } | 76 } |
| 72 | 77 |
| 73 void UiInterface::SetUiCommandHandler(UiCommandHandler* handler) { | 78 void UiInterface::SetUiCommandHandler(UiCommandHandler* handler) { |
| 74 handler_ = handler; | 79 handler_ = handler; |
| 75 } | 80 } |
| 76 | 81 |
| 77 void UiInterface::FlushUpdates() { | 82 void UiInterface::FlushUpdates() { |
| 78 if (loaded_ && handler_) { | 83 if (loaded_ && handler_) { |
| 79 handler_->SendCommandToUi(updates_); | 84 handler_->SendCommandToUi(updates_); |
| 80 updates_.Clear(); | 85 updates_.Clear(); |
| 81 } | 86 } |
| 82 } | 87 } |
| 83 | 88 |
| 84 } // namespace vr_shell | 89 } // namespace vr_shell |
| OLD | NEW |