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

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

Issue 1314843007: Refactor connection_security into SecurityStateModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: create SecurityStateModel for chromeos login webview Created 5 years, 3 months 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
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/connection_security.h" 9 #include "chrome/browser/ssl/security_state_model.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/host_desktop.h" 12 #include "chrome/browser/ui/host_desktop.h"
13 #include "chrome/browser/ui/location_bar/location_bar.h" 13 #include "chrome/browser/ui/location_bar/location_bar.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/browser/web_applications/web_app.h" 15 #include "chrome/browser/web_applications/web_app.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 17 #include "chrome/common/extensions/manifest_handlers/app_launch_info.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"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 bool HostedAppBrowserController::SupportsLocationBar() const { 71 bool HostedAppBrowserController::SupportsLocationBar() const {
72 return !should_use_web_app_frame(); 72 return !should_use_web_app_frame();
73 } 73 }
74 74
75 bool HostedAppBrowserController::ShouldShowLocationBar() const { 75 bool HostedAppBrowserController::ShouldShowLocationBar() const {
76 const Extension* extension = 76 const Extension* extension =
77 ExtensionRegistry::Get(browser_->profile())->GetExtensionById( 77 ExtensionRegistry::Get(browser_->profile())->GetExtensionById(
78 extension_id_, ExtensionRegistry::EVERYTHING); 78 extension_id_, ExtensionRegistry::EVERYTHING);
79 79
80 const content::WebContents* web_contents = 80 content::WebContents* web_contents =
81 browser_->tab_strip_model()->GetActiveWebContents(); 81 browser_->tab_strip_model()->GetActiveWebContents();
82 82
83 // Default to not showing the location bar if either |extension| or 83 // Default to not showing the location bar if either |extension| or
84 // |web_contents| are null. |extension| is null for the dev tools. 84 // |web_contents| are null. |extension| is null for the dev tools.
85 if (!extension || !web_contents) 85 if (!extension || !web_contents)
86 return false; 86 return false;
87 87
88 if (!extension->is_hosted_app()) 88 if (!extension->is_hosted_app())
89 return false; 89 return false;
90 90
91 // Don't show a location bar until a navigation has occurred. 91 // Don't show a location bar until a navigation has occurred.
92 if (web_contents->GetLastCommittedURL().is_empty()) 92 if (web_contents->GetLastCommittedURL().is_empty())
93 return false; 93 return false;
94 94
95 connection_security::SecurityLevel security_level = 95 SecurityStateModel* model = SecurityStateModel::FromWebContents(web_contents);
96 connection_security::GetSecurityLevelForWebContents(web_contents); 96 if (model &&
97 if (security_level == connection_security::SECURITY_ERROR) 97 model->security_info().security_level ==
98 SecurityStateModel::SECURITY_ERROR)
98 return true; 99 return true;
99 100
100 GURL launch_url = AppLaunchInfo::GetLaunchWebURL(extension); 101 GURL launch_url = AppLaunchInfo::GetLaunchWebURL(extension);
101 return !(IsSameOriginOrMoreSecure(launch_url, 102 return !(IsSameOriginOrMoreSecure(launch_url,
102 web_contents->GetVisibleURL()) && 103 web_contents->GetVisibleURL()) &&
103 IsSameOriginOrMoreSecure(launch_url, 104 IsSameOriginOrMoreSecure(launch_url,
104 web_contents->GetLastCommittedURL())); 105 web_contents->GetLastCommittedURL()));
105 } 106 }
106 107
107 void HostedAppBrowserController::UpdateLocationBarVisibility( 108 void HostedAppBrowserController::UpdateLocationBarVisibility(
108 bool animate) const { 109 bool animate) const {
109 if (!SupportsLocationBar()) 110 if (!SupportsLocationBar())
110 return; 111 return;
111 112
112 browser_->window()->GetLocationBar()->UpdateLocationBarVisibility( 113 browser_->window()->GetLocationBar()->UpdateLocationBarVisibility(
113 ShouldShowLocationBar(), animate); 114 ShouldShowLocationBar(), animate);
114 } 115 }
115 116
116 } // namespace extensions 117 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698