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

Side by Side Diff: chrome/browser/ui/extensions/hosted_app_browser_controller.cc

Issue 2448943002: Refactor SecurityStateModel/Clients for simplicity and reusability. (Closed)
Patch Set: refactor -> SecurityStateTabHelper. Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ui/extensions/hosted_app_browser_controller.h" 5 #include "chrome/browser/ui/extensions/hosted_app_browser_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ssl/chrome_security_state_model_client.h" 9 #include "chrome/browser/ssl/security_state_tab_helper.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/location_bar/location_bar.h" 12 #include "chrome/browser/ui/location_bar/location_bar.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/browser/web_applications/web_app.h" 14 #include "chrome/browser/web_applications/web_app.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 16 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
17 #include "components/security_state/security_state_model.h" 17 #include "components/security_state/core/security_state_model.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "extensions/browser/extension_registry.h" 19 #include "extensions/browser/extension_registry.h"
20 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
21 #include "url/gurl.h" 21 #include "url/gurl.h"
22 22
23 namespace extensions { 23 namespace extensions {
24 24
25 namespace { 25 namespace {
26 26
27 bool IsSameOriginOrMoreSecure(const GURL& app_url, const GURL& page_url) { 27 bool IsSameOriginOrMoreSecure(const GURL& app_url, const GURL& page_url) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (!extension || !web_contents) 88 if (!extension || !web_contents)
89 return false; 89 return false;
90 90
91 if (!extension->is_hosted_app()) 91 if (!extension->is_hosted_app())
92 return false; 92 return false;
93 93
94 // Don't show a location bar until a navigation has occurred. 94 // Don't show a location bar until a navigation has occurred.
95 if (web_contents->GetLastCommittedURL().is_empty()) 95 if (web_contents->GetLastCommittedURL().is_empty())
96 return false; 96 return false;
97 97
98 const ChromeSecurityStateModelClient* model_client = 98 const SecurityStateTabHelper* helper =
99 ChromeSecurityStateModelClient::FromWebContents(web_contents); 99 SecurityStateTabHelper::FromWebContents(web_contents);
100 security_state::SecurityStateModel::SecurityInfo security_info; 100 if (helper) {
101 model_client->GetSecurityInfo(&security_info); 101 security_state::SecurityStateModel::SecurityInfo security_info;
102 if (model_client && 102 helper->GetSecurityInfo(&security_info);
103 security_info.security_level == 103 if (security_info.security_level ==
104 security_state::SecurityStateModel::DANGEROUS) 104 security_state::SecurityStateModel::DANGEROUS)
105 return true; 105 return true;
106 }
106 107
107 GURL launch_url = AppLaunchInfo::GetLaunchWebURL(extension); 108 GURL launch_url = AppLaunchInfo::GetLaunchWebURL(extension);
108 return !(IsSameOriginOrMoreSecure(launch_url, 109 return !(IsSameOriginOrMoreSecure(launch_url,
109 web_contents->GetVisibleURL()) && 110 web_contents->GetVisibleURL()) &&
110 IsSameOriginOrMoreSecure(launch_url, 111 IsSameOriginOrMoreSecure(launch_url,
111 web_contents->GetLastCommittedURL())); 112 web_contents->GetLastCommittedURL()));
112 } 113 }
113 114
114 void HostedAppBrowserController::UpdateLocationBarVisibility( 115 void HostedAppBrowserController::UpdateLocationBarVisibility(
115 bool animate) const { 116 bool animate) const {
116 if (!SupportsLocationBar()) 117 if (!SupportsLocationBar())
117 return; 118 return;
118 119
119 browser_->window()->GetLocationBar()->UpdateLocationBarVisibility( 120 browser_->window()->GetLocationBar()->UpdateLocationBarVisibility(
120 ShouldShowLocationBar(), animate); 121 ShouldShowLocationBar(), animate);
121 } 122 }
122 123
123 } // namespace extensions 124 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698