OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
(...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 for (size_t i = 0; i < interstitial_observers_.size(); i++) { | 2172 for (size_t i = 0; i < interstitial_observers_.size(); i++) { |
2173 if (interstitial_observers_[i]->web_contents() != contents) | 2173 if (interstitial_observers_[i]->web_contents() != contents) |
2174 continue; | 2174 continue; |
2175 | 2175 |
2176 delete interstitial_observers_[i]; | 2176 delete interstitial_observers_[i]; |
2177 interstitial_observers_.erase(interstitial_observers_.begin() + i); | 2177 interstitial_observers_.erase(interstitial_observers_.begin() + i); |
2178 return; | 2178 return; |
2179 } | 2179 } |
2180 } | 2180 } |
2181 | 2181 |
| 2182 bool Browser::ShouldShowLocationBar() const { |
| 2183 if (!is_app()) { |
| 2184 // Hide the URL for singleton settings windows. |
| 2185 // TODO(stevenjb): We could avoid this check by setting a Browser |
| 2186 // property for "system" windows, possibly shared with hosted app windows. |
| 2187 // crbug.com/350128. |
| 2188 if (chrome::IsSettingsWindow(this)) |
| 2189 return false; |
| 2190 return true; |
| 2191 } |
| 2192 |
| 2193 // Normally apps do not show a location bar. |
| 2194 if (app_type() != APP_TYPE_HOST || |
| 2195 app_name() == DevToolsWindow::kDevToolsApp || |
| 2196 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 2197 switches::kEnableStreamlinedHostedApps)) |
| 2198 return false; |
| 2199 |
| 2200 // If kEnableStreamlinedHostedApps is true, show the locaiton bar for non |
| 2201 // legacy packaged apps. |
| 2202 ExtensionService* service = |
| 2203 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 2204 const extensions::Extension* extension = |
| 2205 service ? service->GetInstalledExtension( |
| 2206 web_app::GetExtensionIdFromApplicationName(app_name())) |
| 2207 : NULL; |
| 2208 return (!extension || !extension->is_legacy_packaged_app()); |
| 2209 } |
| 2210 |
2182 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, | 2211 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, |
2183 bool check_fullscreen) const { | 2212 bool check_fullscreen) const { |
2184 bool hide_ui_for_fullscreen = check_fullscreen && ShouldHideUIForFullscreen(); | 2213 bool hide_ui_for_fullscreen = check_fullscreen && ShouldHideUIForFullscreen(); |
2185 | 2214 |
2186 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; | 2215 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; |
2187 | 2216 |
2188 if (is_type_tabbed()) | 2217 if (is_type_tabbed()) |
2189 features |= FEATURE_BOOKMARKBAR; | 2218 features |= FEATURE_BOOKMARKBAR; |
2190 | 2219 |
2191 if (!hide_ui_for_fullscreen) { | 2220 if (!hide_ui_for_fullscreen) { |
2192 if (!is_type_tabbed()) | 2221 if (!is_type_tabbed()) |
2193 features |= FEATURE_TITLEBAR; | 2222 features |= FEATURE_TITLEBAR; |
2194 | 2223 |
2195 if (is_type_tabbed()) | 2224 if (is_type_tabbed()) |
2196 features |= FEATURE_TABSTRIP; | 2225 features |= FEATURE_TABSTRIP; |
2197 | 2226 |
2198 if (is_type_tabbed()) | 2227 if (is_type_tabbed()) |
2199 features |= FEATURE_TOOLBAR; | 2228 features |= FEATURE_TOOLBAR; |
2200 | 2229 |
2201 ExtensionService* service = | 2230 if (ShouldShowLocationBar()) |
2202 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
2203 const extensions::Extension* extension = | |
2204 service ? service->GetInstalledExtension( | |
2205 web_app::GetExtensionIdFromApplicationName(app_name())) | |
2206 : NULL; | |
2207 | |
2208 if (!is_app() || (app_type() == APP_TYPE_HOST && | |
2209 app_name() != DevToolsWindow::kDevToolsApp && | |
2210 (!extension || !extension->is_legacy_packaged_app()) && | |
2211 CommandLine::ForCurrentProcess()->HasSwitch( | |
2212 switches::kEnableStreamlinedHostedApps))) { | |
2213 features |= FEATURE_LOCATIONBAR; | 2231 features |= FEATURE_LOCATIONBAR; |
2214 } | |
2215 } | 2232 } |
2216 return !!(features & feature); | 2233 return !!(features & feature); |
2217 } | 2234 } |
2218 | 2235 |
2219 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { | 2236 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { |
2220 BookmarkBar::State state; | 2237 BookmarkBar::State state; |
2221 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. | 2238 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. |
2222 if (browser_defaults::bookmarks_enabled && | 2239 if (browser_defaults::bookmarks_enabled && |
2223 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && | 2240 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && |
2224 !ShouldHideUIForFullscreen()) { | 2241 !ShouldHideUIForFullscreen()) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2337 if (contents && !allow_js_access) { | 2354 if (contents && !allow_js_access) { |
2338 contents->web_contents()->GetController().LoadURL( | 2355 contents->web_contents()->GetController().LoadURL( |
2339 target_url, | 2356 target_url, |
2340 content::Referrer(), | 2357 content::Referrer(), |
2341 content::PAGE_TRANSITION_LINK, | 2358 content::PAGE_TRANSITION_LINK, |
2342 std::string()); // No extra headers. | 2359 std::string()); // No extra headers. |
2343 } | 2360 } |
2344 | 2361 |
2345 return contents != NULL; | 2362 return contents != NULL; |
2346 } | 2363 } |
OLD | NEW |