| 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/vr_web_contents_observer.h" | 5 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/android/vr_shell/toolbar_helper.h" |
| 7 #include "chrome/browser/android/vr_shell/ui_interface.h" | 8 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 8 #include "chrome/browser/android/vr_shell/vr_shell.h" | 9 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 9 #include "chrome/browser/ssl/security_state_tab_helper.h" | |
| 10 #include "components/security_state/core/security_state.h" | |
| 11 #include "content/public/browser/navigation_handle.h" | |
| 12 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/public/browser/render_widget_host.h" | 11 #include "content/public/browser/render_widget_host.h" |
| 14 #include "content/public/browser/render_widget_host_view.h" | 12 #include "content/public/browser/render_widget_host_view.h" |
| 15 | 13 |
| 16 namespace vr_shell { | 14 namespace vr_shell { |
| 17 | 15 |
| 18 VrWebContentsObserver::VrWebContentsObserver(content::WebContents* web_contents, | 16 VrWebContentsObserver::VrWebContentsObserver(content::WebContents* web_contents, |
| 17 VrShell* vr_shell, |
| 19 UiInterface* ui_interface, | 18 UiInterface* ui_interface, |
| 20 VrShell* vr_shell) | 19 ToolbarHelper* toolbar) |
| 21 : WebContentsObserver(web_contents), | 20 : WebContentsObserver(web_contents), |
| 21 vr_shell_(vr_shell), |
| 22 ui_interface_(ui_interface), | 22 ui_interface_(ui_interface), |
| 23 vr_shell_(vr_shell) { | 23 toolbar_(toolbar) { |
| 24 ui_interface_->SetURL(web_contents->GetVisibleURL()); | 24 toolbar_->Update(); |
| 25 DidChangeVisibleSecurityState(); | |
| 26 } | 25 } |
| 27 | 26 |
| 28 VrWebContentsObserver::~VrWebContentsObserver() {} | 27 VrWebContentsObserver::~VrWebContentsObserver() {} |
| 29 | 28 |
| 30 void VrWebContentsObserver::SetUiInterface(UiInterface* ui_interface) { | 29 void VrWebContentsObserver::SetUiInterface(UiInterface* ui_interface) { |
| 31 ui_interface_ = ui_interface; | 30 ui_interface_ = ui_interface; |
| 32 } | 31 } |
| 33 | 32 |
| 34 void VrWebContentsObserver::DidStartLoading() { | 33 void VrWebContentsObserver::DidStartLoading() { |
| 35 ui_interface_->SetLoading(true); | 34 ui_interface_->SetLoading(true); |
| 36 } | 35 } |
| 37 | 36 |
| 38 void VrWebContentsObserver::DidStopLoading() { | 37 void VrWebContentsObserver::DidStopLoading() { |
| 39 ui_interface_->SetLoading(false); | 38 ui_interface_->SetLoading(false); |
| 40 } | 39 } |
| 41 | 40 |
| 42 void VrWebContentsObserver::DidStartNavigation( | 41 void VrWebContentsObserver::DidStartNavigation( |
| 43 content::NavigationHandle* navigation_handle) { | 42 content::NavigationHandle* navigation_handle) { |
| 44 if (navigation_handle->IsInMainFrame()) { | 43 toolbar_->Update(); |
| 45 ui_interface_->SetURL(navigation_handle->GetURL()); | |
| 46 } | |
| 47 } | 44 } |
| 48 | 45 |
| 49 void VrWebContentsObserver::DidRedirectNavigation( | 46 void VrWebContentsObserver::DidRedirectNavigation( |
| 50 content::NavigationHandle* navigation_handle) { | 47 content::NavigationHandle* navigation_handle) { |
| 51 if (navigation_handle->IsInMainFrame()) { | 48 toolbar_->Update(); |
| 52 ui_interface_->SetURL(navigation_handle->GetURL()); | |
| 53 } | |
| 54 } | 49 } |
| 55 | 50 |
| 56 void VrWebContentsObserver::DidFinishNavigation( | 51 void VrWebContentsObserver::DidFinishNavigation( |
| 57 content::NavigationHandle* navigation_handle) { | 52 content::NavigationHandle* navigation_handle) { |
| 58 if (navigation_handle->IsInMainFrame()) { | 53 toolbar_->Update(); |
| 59 ui_interface_->SetURL(navigation_handle->GetURL()); | |
| 60 } | |
| 61 } | 54 } |
| 62 | 55 |
| 63 void VrWebContentsObserver::DidChangeVisibleSecurityState() { | 56 void VrWebContentsObserver::DidChangeVisibleSecurityState() { |
| 64 const auto* helper = SecurityStateTabHelper::FromWebContents(web_contents()); | 57 toolbar_->Update(); |
| 65 DCHECK(helper); | |
| 66 security_state::SecurityInfo security_info; | |
| 67 helper->GetSecurityInfo(&security_info); | |
| 68 bool malware = (security_info.malicious_content_status != | |
| 69 security_state::MALICIOUS_CONTENT_STATUS_NONE); | |
| 70 ui_interface_->SetSecurityInfo(security_info.security_level, malware); | |
| 71 } | 58 } |
| 72 | 59 |
| 73 void VrWebContentsObserver::DidToggleFullscreenModeForTab( | 60 void VrWebContentsObserver::DidToggleFullscreenModeForTab( |
| 74 bool entered_fullscreen, | 61 bool entered_fullscreen, |
| 75 bool will_cause_resize) { | 62 bool will_cause_resize) { |
| 76 vr_shell_->OnFullscreenChanged(entered_fullscreen); | 63 vr_shell_->OnFullscreenChanged(entered_fullscreen); |
| 77 } | 64 } |
| 78 | 65 |
| 79 void VrWebContentsObserver::WebContentsDestroyed() { | 66 void VrWebContentsObserver::WebContentsDestroyed() { |
| 80 vr_shell_->ContentWebContentsDestroyed(); | 67 vr_shell_->ContentWebContentsDestroyed(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 vr_shell_->ContentFrameWasResized(width_changed); | 79 vr_shell_->ContentFrameWasResized(width_changed); |
| 93 } | 80 } |
| 94 | 81 |
| 95 void VrWebContentsObserver::RenderViewHostChanged( | 82 void VrWebContentsObserver::RenderViewHostChanged( |
| 96 content::RenderViewHost* old_host, | 83 content::RenderViewHost* old_host, |
| 97 content::RenderViewHost* new_host) { | 84 content::RenderViewHost* new_host) { |
| 98 new_host->GetWidget()->GetView()->SetIsInVR(true); | 85 new_host->GetWidget()->GetView()->SetIsInVR(true); |
| 99 } | 86 } |
| 100 | 87 |
| 101 } // namespace vr_shell | 88 } // namespace vr_shell |
| OLD | NEW |