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

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

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

Powered by Google App Engine
This is Rietveld 408576698