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

Side by Side Diff: chrome/browser/android/vr_shell/ui_interface.cc

Issue 2461503002: Provide URL-related info to the VR HTML UI. (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
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 "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 9
9 namespace vr_shell { 10 namespace vr_shell {
10 11
11 UiInterface::UiInterface() { 12 UiInterface::UiInterface() {
12 SetMode(Mode::STANDARD); 13 SetMode(Mode::STANDARD);
13 } 14 }
14 15
15 UiInterface::~UiInterface() {} 16 UiInterface::~UiInterface() {}
16 17
17 void UiInterface::SetUiCommandHandler(UiCommandHandler* handler) {
18 handler_ = handler;
19 }
20
21 void UiInterface::SetMode(Mode mode) { 18 void UiInterface::SetMode(Mode mode) {
22 updates_.SetInteger("mode", static_cast<int>(mode)); 19 updates_.SetInteger("mode", static_cast<int>(mode));
23 FlushUpdates(); 20 FlushUpdates();
24 } 21 }
25 22
26 void UiInterface::SetSecureOrigin(bool secure) { 23 void UiInterface::SetSecureOrigin(bool secure) {
27 updates_.SetBoolean("secureOrigin", secure); 24 updates_.SetBoolean("secureOrigin", secure);
28 FlushUpdates(); 25 FlushUpdates();
29 } 26 }
30 27
28 void UiInterface::SetLoading(bool loading) {
29 updates_.SetBoolean("loading", loading);
30 FlushUpdates();
31 }
32
33 void UiInterface::SetURL(const GURL& url) {
34 std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue);
35 details->SetString("host", url.host());
36 details->SetString("path", url.path());
37
38 updates_.Set("url", std::move(details));
39 FlushUpdates();
40 }
41
31 void UiInterface::OnDomContentsLoaded() { 42 void UiInterface::OnDomContentsLoaded() {
32 loaded_ = true; 43 loaded_ = true;
33 #if defined(ENABLE_VR_SHELL_UI_DEV) 44 #if defined(ENABLE_VR_SHELL_UI_DEV)
34 updates_.SetBoolean("enableReloadUi", true); 45 updates_.SetBoolean("enableReloadUi", true);
35 #endif 46 #endif
36 FlushUpdates(); 47 FlushUpdates();
37 } 48 }
38 49
50 void UiInterface::SetUiCommandHandler(UiCommandHandler* handler) {
51 handler_ = handler;
bshe 2016/10/27 20:27:44 Is the diff suppose to be here? The function was d
cjgrant 2016/10/28 14:16:58 This was intentional. I'm just moving the functio
bshe 2016/10/28 14:33:14 hah. I missed the deleted function..
52 }
53
39 void UiInterface::FlushUpdates() { 54 void UiInterface::FlushUpdates() {
40 if (loaded_ && handler_) { 55 if (loaded_ && handler_) {
41 handler_->SendCommandToUi(updates_); 56 handler_->SendCommandToUi(updates_);
42 updates_.Clear(); 57 updates_.Clear();
43 } 58 }
44 } 59 }
45 60
46 } // namespace vr_shell 61 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698