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

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

Issue 2562503002: Generalize WebContentsObserver::SecurityStyleChanged (Closed)
Patch Set: Created 4 years 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/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 12
13 namespace vr_shell { 13 namespace vr_shell {
14 14
15 VrWebContentsObserver::VrWebContentsObserver(content::WebContents* web_contents, 15 VrWebContentsObserver::VrWebContentsObserver(content::WebContents* web_contents,
16 UiInterface* ui_interface, 16 UiInterface* ui_interface,
17 VrShell* vr_shell) 17 VrShell* vr_shell)
18 : WebContentsObserver(web_contents), 18 : WebContentsObserver(web_contents),
19 ui_interface_(ui_interface), 19 ui_interface_(ui_interface),
20 vr_shell_(vr_shell) { 20 vr_shell_(vr_shell) {
21 ui_interface_->SetURL(web_contents->GetVisibleURL()); 21 ui_interface_->SetURL(web_contents->GetVisibleURL());
22 SetSecurityLevel(); 22 DidChangeVisibleSecurityState();
23 } 23 }
24 24
25 VrWebContentsObserver::~VrWebContentsObserver() {} 25 VrWebContentsObserver::~VrWebContentsObserver() {}
26 26
27 void VrWebContentsObserver::SetUiInterface(UiInterface* ui_interface) { 27 void VrWebContentsObserver::SetUiInterface(UiInterface* ui_interface) {
28 ui_interface_ = ui_interface; 28 ui_interface_ = ui_interface;
29 } 29 }
30 30
31 void VrWebContentsObserver::DidStartLoading() { 31 void VrWebContentsObserver::DidStartLoading() {
32 ui_interface_->SetLoading(true); 32 ui_interface_->SetLoading(true);
33 } 33 }
34 34
35 void VrWebContentsObserver::DidStopLoading() { 35 void VrWebContentsObserver::DidStopLoading() {
36 ui_interface_->SetLoading(false); 36 ui_interface_->SetLoading(false);
37 } 37 }
38 38
39 void VrWebContentsObserver::DidStartNavigation( 39 void VrWebContentsObserver::DidStartNavigation(
40 content::NavigationHandle* navigation_handle) { 40 content::NavigationHandle* navigation_handle) {
41 if (navigation_handle->IsInMainFrame()) { 41 if (navigation_handle->IsInMainFrame()) {
42 ui_interface_->SetURL(navigation_handle->GetURL()); 42 ui_interface_->SetURL(navigation_handle->GetURL());
43 SetSecurityLevel();
44 } 43 }
45 } 44 }
46 45
47 void VrWebContentsObserver::DidRedirectNavigation( 46 void VrWebContentsObserver::DidRedirectNavigation(
48 content::NavigationHandle* navigation_handle) { 47 content::NavigationHandle* navigation_handle) {
49 if (navigation_handle->IsInMainFrame()) { 48 if (navigation_handle->IsInMainFrame()) {
50 ui_interface_->SetURL(navigation_handle->GetURL()); 49 ui_interface_->SetURL(navigation_handle->GetURL());
51 SetSecurityLevel();
52 } 50 }
53 } 51 }
54 52
55 void VrWebContentsObserver::DidFinishNavigation( 53 void VrWebContentsObserver::DidFinishNavigation(
56 content::NavigationHandle* navigation_handle) { 54 content::NavigationHandle* navigation_handle) {
57 if (navigation_handle->IsInMainFrame()) { 55 if (navigation_handle->IsInMainFrame()) {
58 ui_interface_->SetURL(navigation_handle->GetURL()); 56 ui_interface_->SetURL(navigation_handle->GetURL());
59 SetSecurityLevel();
60 } 57 }
61 } 58 }
62 59
63 void VrWebContentsObserver::SetSecurityLevel() { 60 void VrWebContentsObserver::DidChangeVisibleSecurityState() {
64 const auto* helper = SecurityStateTabHelper::FromWebContents(web_contents()); 61 const auto* helper = SecurityStateTabHelper::FromWebContents(web_contents());
65 DCHECK(helper); 62 DCHECK(helper);
66 security_state::SecurityInfo security_info; 63 security_state::SecurityInfo security_info;
67 helper->GetSecurityInfo(&security_info); 64 helper->GetSecurityInfo(&security_info);
68 ui_interface_->SetSecurityLevel(security_info.security_level); 65 ui_interface_->SetSecurityLevel(security_info.security_level);
69 } 66 }
70 67
71 void VrWebContentsObserver::DidToggleFullscreenModeForTab( 68 void VrWebContentsObserver::DidToggleFullscreenModeForTab(
72 bool entered_fullscreen, bool will_cause_resize) { 69 bool entered_fullscreen, bool will_cause_resize) {
73 ui_interface_->SetFullscreen(entered_fullscreen); 70 ui_interface_->SetFullscreen(entered_fullscreen);
74 } 71 }
75 72
76 void VrWebContentsObserver::WebContentsDestroyed() { 73 void VrWebContentsObserver::WebContentsDestroyed() {
77 vr_shell_->ContentWebContentsDestroyedOnUI(); 74 vr_shell_->ContentWebContentsDestroyedOnUI();
78 } 75 }
79 76
80 void VrWebContentsObserver::WasHidden() { 77 void VrWebContentsObserver::WasHidden() {
81 vr_shell_->ContentWasHiddenOnUI(); 78 vr_shell_->ContentWasHiddenOnUI();
82 } 79 }
83 80
84 } // namespace vr_shell 81 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698