| 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/ui_interface.h" | 7 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 8 #include "chrome/browser/android/vr_shell/vr_shell.h" | 8 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 9 #include "chrome/browser/ssl/security_state_tab_helper.h" | 9 #include "chrome/browser/ssl/security_state_tab_helper.h" |
| 10 #include "components/security_state/core/security_state.h" | 10 #include "components/security_state/core/security_state.h" |
| 11 #include "content/public/browser/navigation_handle.h" | 11 #include "content/public/browser/navigation_handle.h" |
| 12 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/public/browser/render_widget_host.h" | 13 #include "content/public/browser/render_widget_host.h" |
| 14 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
| 15 | 15 |
| 16 namespace vr_shell { | 16 namespace vr_shell { |
| 17 | 17 |
| 18 VrWebContentsObserver::VrWebContentsObserver(content::WebContents* web_contents, | 18 VrWebContentsObserver::VrWebContentsObserver(content::WebContents* web_contents, |
| 19 UiInterface* ui_interface, | 19 UiInterface* ui_interface, |
| 20 VrShell* vr_shell) | 20 VrShell* vr_shell) |
| 21 : WebContentsObserver(web_contents), | 21 : WebContentsObserver(web_contents), |
| 22 ui_interface_(ui_interface), | 22 ui_interface_(ui_interface), |
| 23 vr_shell_(vr_shell) { | 23 vr_shell_(vr_shell) { |
| 24 ui_interface_->SetURL(web_contents->GetVisibleURL()); | 24 ui_interface_->SetURL(web_contents->GetVisibleURL()); |
| 25 SetSecurityLevel(); | 25 DidChangeVisibleSecurityState(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 VrWebContentsObserver::~VrWebContentsObserver() {} | 28 VrWebContentsObserver::~VrWebContentsObserver() {} |
| 29 | 29 |
| 30 void VrWebContentsObserver::SetUiInterface(UiInterface* ui_interface) { | 30 void VrWebContentsObserver::SetUiInterface(UiInterface* ui_interface) { |
| 31 ui_interface_ = ui_interface; | 31 ui_interface_ = ui_interface; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void VrWebContentsObserver::DidStartLoading() { | 34 void VrWebContentsObserver::DidStartLoading() { |
| 35 ui_interface_->SetLoading(true); | 35 ui_interface_->SetLoading(true); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 void VrWebContentsObserver::DidFinishNavigation( | 56 void VrWebContentsObserver::DidFinishNavigation( |
| 57 content::NavigationHandle* navigation_handle) { | 57 content::NavigationHandle* navigation_handle) { |
| 58 if (navigation_handle->IsInMainFrame()) { | 58 if (navigation_handle->IsInMainFrame()) { |
| 59 ui_interface_->SetURL(navigation_handle->GetURL()); | 59 ui_interface_->SetURL(navigation_handle->GetURL()); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 // TODO(cjgrant): We care about security level, not style. Refactor | 63 void VrWebContentsObserver::DidChangeVisibleSecurityState() { |
| 64 // WebContentsObserver (or equivalent) to expose more general security | |
| 65 // information, so we can stop abusing this callback. | |
| 66 void VrWebContentsObserver::SecurityStyleChanged( | |
| 67 blink::WebSecurityStyle security_style, | |
| 68 const content::SecurityStyleExplanations& explanations) { | |
| 69 SetSecurityLevel(); | |
| 70 } | |
| 71 | |
| 72 void VrWebContentsObserver::SetSecurityLevel() { | |
| 73 const auto* helper = SecurityStateTabHelper::FromWebContents(web_contents()); | 64 const auto* helper = SecurityStateTabHelper::FromWebContents(web_contents()); |
| 74 DCHECK(helper); | 65 DCHECK(helper); |
| 75 security_state::SecurityInfo security_info; | 66 security_state::SecurityInfo security_info; |
| 76 helper->GetSecurityInfo(&security_info); | 67 helper->GetSecurityInfo(&security_info); |
| 77 ui_interface_->SetSecurityLevel(security_info.security_level); | 68 ui_interface_->SetSecurityLevel(security_info.security_level); |
| 78 } | 69 } |
| 79 | 70 |
| 80 void VrWebContentsObserver::DidToggleFullscreenModeForTab( | 71 void VrWebContentsObserver::DidToggleFullscreenModeForTab( |
| 81 bool entered_fullscreen, bool will_cause_resize) { | 72 bool entered_fullscreen, bool will_cause_resize) { |
| 82 ui_interface_->SetFullscreen(entered_fullscreen); | 73 ui_interface_->SetFullscreen(entered_fullscreen); |
| 83 } | 74 } |
| 84 | 75 |
| 85 void VrWebContentsObserver::WebContentsDestroyed() { | 76 void VrWebContentsObserver::WebContentsDestroyed() { |
| 86 vr_shell_->ContentWebContentsDestroyedOnUI(); | 77 vr_shell_->ContentWebContentsDestroyedOnUI(); |
| 87 } | 78 } |
| 88 | 79 |
| 89 void VrWebContentsObserver::WasHidden() { | 80 void VrWebContentsObserver::WasHidden() { |
| 90 vr_shell_->ContentWasHiddenOnUI(); | 81 vr_shell_->ContentWasHiddenOnUI(); |
| 91 } | 82 } |
| 92 | 83 |
| 93 void VrWebContentsObserver::RenderViewHostChanged( | 84 void VrWebContentsObserver::RenderViewHostChanged( |
| 94 content::RenderViewHost* old_host, | 85 content::RenderViewHost* old_host, |
| 95 content::RenderViewHost* new_host) { | 86 content::RenderViewHost* new_host) { |
| 96 new_host->GetWidget()->GetView()->SetShowingOverscrollGlow(false); | 87 new_host->GetWidget()->GetView()->SetShowingOverscrollGlow(false); |
| 97 } | 88 } |
| 98 | 89 |
| 99 } // namespace vr_shell | 90 } // namespace vr_shell |
| OLD | NEW |