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

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

Issue 2536223002: Omnibox improvements and fixes. (Closed)
Patch Set: Separate omnibox icon selection from webVR warning toggle. 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/ssl/security_state_tab_helper.h"
9 #include "components/security_state/core/security_state.h"
8 #include "content/public/browser/navigation_handle.h" 10 #include "content/public/browser/navigation_handle.h"
9 11
10 namespace vr_shell { 12 namespace vr_shell {
11 13
12 VrWebContentsObserver::VrWebContentsObserver(content::WebContents* web_contents, 14 VrWebContentsObserver::VrWebContentsObserver(content::WebContents* web_contents,
13 UiInterface* ui_interface) 15 UiInterface* ui_interface)
14 : WebContentsObserver(web_contents), 16 : WebContentsObserver(web_contents),
15 ui_interface_(ui_interface) {} 17 ui_interface_(ui_interface) {
18 ui_interface_->SetURL(web_contents->GetVisibleURL());
19 SetSecurityLevel();
20 }
16 21
17 VrWebContentsObserver::~VrWebContentsObserver() {} 22 VrWebContentsObserver::~VrWebContentsObserver() {}
18 23
19 void VrWebContentsObserver::SetUiInterface(UiInterface* ui_interface) { 24 void VrWebContentsObserver::SetUiInterface(UiInterface* ui_interface) {
20 ui_interface_ = ui_interface; 25 ui_interface_ = ui_interface;
21 } 26 }
22 27
23 void VrWebContentsObserver::DidStartLoading() { 28 void VrWebContentsObserver::DidStartLoading() {
24 ui_interface_->SetLoading(true); 29 ui_interface_->SetLoading(true);
25 } 30 }
26 31
27 void VrWebContentsObserver::DidStopLoading() { 32 void VrWebContentsObserver::DidStopLoading() {
28 ui_interface_->SetLoading(false); 33 ui_interface_->SetLoading(false);
29 } 34 }
30 35
31 void VrWebContentsObserver::DidStartNavigation( 36 void VrWebContentsObserver::DidStartNavigation(
32 content::NavigationHandle* navigation_handle) { 37 content::NavigationHandle* navigation_handle) {
33 ui_interface_->SetURL(navigation_handle->GetURL()); 38 if (navigation_handle->IsInMainFrame()) {
39 ui_interface_->SetURL(navigation_handle->GetURL());
40 SetSecurityLevel();
41 }
34 } 42 }
35 43
36 void VrWebContentsObserver::DidRedirectNavigation( 44 void VrWebContentsObserver::DidRedirectNavigation(
37 content::NavigationHandle* navigation_handle) { 45 content::NavigationHandle* navigation_handle) {
38 ui_interface_->SetURL(navigation_handle->GetURL()); 46 if (navigation_handle->IsInMainFrame()) {
47 ui_interface_->SetURL(navigation_handle->GetURL());
48 SetSecurityLevel();
49 }
39 } 50 }
40 51
41 void VrWebContentsObserver::DidFinishNavigation( 52 void VrWebContentsObserver::DidFinishNavigation(
42 content::NavigationHandle* navigation_handle) { 53 content::NavigationHandle* navigation_handle) {
43 ui_interface_->SetURL(navigation_handle->GetURL()); 54 if (navigation_handle->IsInMainFrame()) {
55 ui_interface_->SetURL(navigation_handle->GetURL());
56 SetSecurityLevel();
57 }
58 }
59
60 void VrWebContentsObserver::SetSecurityLevel() {
61 const auto* helper = SecurityStateTabHelper::FromWebContents(web_contents());
62 CHECK(helper);
bshe 2016/12/01 15:32:46 Perhaps a DCHECK here so the code is not in produc
cjgrant 2016/12/01 21:21:51 The last time we discussed CHECK/DCHECK, we settle
bshe 2016/12/02 14:21:36 My understanding is that it is better to use DCHEC
cjgrant 2016/12/02 15:39:50 Done.
63 security_state::SecurityInfo security_info;
64 helper->GetSecurityInfo(&security_info);
65 ui_interface_->SetSecurityLevel(security_info.security_level);
44 } 66 }
45 67
46 void VrWebContentsObserver::DidToggleFullscreenModeForTab( 68 void VrWebContentsObserver::DidToggleFullscreenModeForTab(
47 bool entered_fullscreen, bool will_cause_resize) { 69 bool entered_fullscreen, bool will_cause_resize) {
48 // TODO(amp): Use will_cause_resize to signal ui of pending size changes. 70 // TODO(amp): Use will_cause_resize to signal ui of pending size changes.
49 int mode = ui_interface_->GetMode(); 71 int mode = ui_interface_->GetMode();
50 if (entered_fullscreen && mode == UiInterface::Mode::STANDARD) { 72 if (entered_fullscreen && mode == UiInterface::Mode::STANDARD) {
51 ui_interface_->SetMode(UiInterface::Mode::CINEMA); 73 ui_interface_->SetMode(UiInterface::Mode::CINEMA);
52 } 74 }
53 if (!entered_fullscreen && mode == UiInterface::Mode::CINEMA) { 75 if (!entered_fullscreen && mode == UiInterface::Mode::CINEMA) {
54 ui_interface_->SetMode(UiInterface::Mode::STANDARD); 76 ui_interface_->SetMode(UiInterface::Mode::STANDARD);
55 } 77 }
56 } 78 }
57 79
58 } // namespace vr_shell 80 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_web_contents_observer.h ('k') | chrome/browser/resources/vr_shell/vr_shell_ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698