Chromium Code Reviews| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 BrowserWindow* CreateBrowserWindow(Browser* browser) { | 234 BrowserWindow* CreateBrowserWindow(Browser* browser) { |
| 235 return BrowserWindow::CreateBrowserWindow(browser); | 235 return BrowserWindow::CreateBrowserWindow(browser); |
| 236 } | 236 } |
| 237 | 237 |
| 238 // Is the fast tab unload experiment enabled? | 238 // Is the fast tab unload experiment enabled? |
| 239 bool IsFastTabUnloadEnabled() { | 239 bool IsFastTabUnloadEnabled() { |
| 240 return CommandLine::ForCurrentProcess()->HasSwitch( | 240 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 241 switches::kEnableFastUnload); | 241 switches::kEnableFastUnload); |
| 242 } | 242 } |
| 243 | 243 |
| 244 const char kChromeUIScheme[] = "chrome"; | |
| 245 | |
| 244 } // namespace | 246 } // namespace |
| 245 | 247 |
| 246 //////////////////////////////////////////////////////////////////////////////// | 248 //////////////////////////////////////////////////////////////////////////////// |
| 247 // Browser, CreateParams: | 249 // Browser, CreateParams: |
| 248 | 250 |
| 249 Browser::CreateParams::CreateParams(Profile* profile, | 251 Browser::CreateParams::CreateParams(Profile* profile, |
| 250 chrome::HostDesktopType host_desktop_type) | 252 chrome::HostDesktopType host_desktop_type) |
| 251 : type(TYPE_TABBED), | 253 : type(TYPE_TABBED), |
| 252 profile(profile), | 254 profile(profile), |
| 253 host_desktop_type(host_desktop_type), | 255 host_desktop_type(host_desktop_type), |
| (...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2157 for (size_t i = 0; i < interstitial_observers_.size(); i++) { | 2159 for (size_t i = 0; i < interstitial_observers_.size(); i++) { |
| 2158 if (interstitial_observers_[i]->web_contents() != contents) | 2160 if (interstitial_observers_[i]->web_contents() != contents) |
| 2159 continue; | 2161 continue; |
| 2160 | 2162 |
| 2161 delete interstitial_observers_[i]; | 2163 delete interstitial_observers_[i]; |
| 2162 interstitial_observers_.erase(interstitial_observers_.begin() + i); | 2164 interstitial_observers_.erase(interstitial_observers_.begin() + i); |
| 2163 return; | 2165 return; |
| 2164 } | 2166 } |
| 2165 } | 2167 } |
| 2166 | 2168 |
| 2169 bool Browser::ShowLocationBar() const { | |
|
Ben Goodger (Google)
2014/03/03 18:55:16
Here's a question... can settings shown in a popup
stevenjb
2014/03/03 23:45:24
I am reluctant to use APP_TYPE_HOST for something
stevenjb
2014/03/06 23:51:56
OK, so I looked through the code and did some expe
| |
| 2170 if (!is_app()) { | |
| 2171 // Hide the URL for singleton settings windows | |
| 2172 if (!is_type_tabbed() && | |
| 2173 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2174 ::switches::kEnableSettingsWindow)) { | |
| 2175 WebContents* web_contents = tab_strip_model_->GetWebContentsAt(0); | |
| 2176 if (web_contents) { | |
| 2177 GURL url(web_contents->GetURL()); | |
| 2178 if (url.SchemeIs(kChromeUIScheme) && | |
| 2179 url.spec().find(chrome::kChromeUISettingsURL) == 0) { | |
| 2180 return false; | |
| 2181 } | |
| 2182 } | |
| 2183 } | |
| 2184 // Otherwise always show the location bar for non app browsers. | |
| 2185 return true; | |
| 2186 } | |
| 2187 | |
| 2188 // Normally apps do not show a location bar. | |
| 2189 if (app_type() != APP_TYPE_HOST || | |
| 2190 app_name() == DevToolsWindow::kDevToolsApp || | |
| 2191 !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2192 switches::kEnableStreamlinedHostedApps)) | |
| 2193 return false; | |
| 2194 | |
| 2195 // If kEnableStreamlinedHostedApps is true, hide the locaiton bar for non | |
| 2196 // legacy packaged apps. | |
|
stevenjb
2014/03/06 23:51:56
Actually, this comment is wrong. We want to -show-
| |
| 2197 ExtensionService* service = | |
| 2198 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
| 2199 if (!service) | |
| 2200 return false; // Assume app is non-legacy. | |
|
calamity
2014/03/05 02:38:11
Non-legacy apps would get a location bar. I don't
stevenjb
2014/03/06 23:51:56
Restored the existing logic.
| |
| 2201 | |
| 2202 const extensions::Extension* extension = service->GetInstalledExtension( | |
| 2203 web_app::GetExtensionIdFromApplicationName(app_name())); | |
| 2204 return (!extension || !extension->is_legacy_packaged_app()); | |
| 2205 } | |
| 2206 | |
| 2167 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, | 2207 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, |
| 2168 bool check_fullscreen) const { | 2208 bool check_fullscreen) const { |
| 2169 bool hide_ui_for_fullscreen = check_fullscreen && ShouldHideUIForFullscreen(); | 2209 bool hide_ui_for_fullscreen = check_fullscreen && ShouldHideUIForFullscreen(); |
| 2170 | 2210 |
| 2171 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; | 2211 unsigned int features = FEATURE_INFOBAR | FEATURE_DOWNLOADSHELF; |
| 2172 | 2212 |
| 2173 if (is_type_tabbed()) | 2213 if (is_type_tabbed()) |
| 2174 features |= FEATURE_BOOKMARKBAR; | 2214 features |= FEATURE_BOOKMARKBAR; |
| 2175 | 2215 |
| 2176 if (!hide_ui_for_fullscreen) { | 2216 if (!hide_ui_for_fullscreen) { |
| 2177 if (!is_type_tabbed()) | 2217 if (!is_type_tabbed()) |
| 2178 features |= FEATURE_TITLEBAR; | 2218 features |= FEATURE_TITLEBAR; |
| 2179 | 2219 |
| 2180 if (is_type_tabbed()) | 2220 if (is_type_tabbed()) |
| 2181 features |= FEATURE_TABSTRIP; | 2221 features |= FEATURE_TABSTRIP; |
| 2182 | 2222 |
| 2183 if (is_type_tabbed()) | 2223 if (is_type_tabbed()) |
| 2184 features |= FEATURE_TOOLBAR; | 2224 features |= FEATURE_TOOLBAR; |
| 2185 | 2225 |
| 2186 ExtensionService* service = | 2226 if (ShowLocationBar()) |
| 2187 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
| 2188 const extensions::Extension* extension = | |
| 2189 service ? service->GetInstalledExtension( | |
| 2190 web_app::GetExtensionIdFromApplicationName(app_name())) | |
| 2191 : NULL; | |
| 2192 | |
| 2193 if (!is_app() || (app_type() == APP_TYPE_HOST && | |
| 2194 app_name() != DevToolsWindow::kDevToolsApp && | |
| 2195 (!extension || !extension->is_legacy_packaged_app()) && | |
| 2196 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2197 switches::kEnableStreamlinedHostedApps))) { | |
| 2198 features |= FEATURE_LOCATIONBAR; | 2227 features |= FEATURE_LOCATIONBAR; |
| 2199 } | |
| 2200 } | 2228 } |
| 2201 return !!(features & feature); | 2229 return !!(features & feature); |
| 2202 } | 2230 } |
| 2203 | 2231 |
| 2204 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { | 2232 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { |
| 2205 BookmarkBar::State state; | 2233 BookmarkBar::State state; |
| 2206 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. | 2234 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. |
| 2207 if (browser_defaults::bookmarks_enabled && | 2235 if (browser_defaults::bookmarks_enabled && |
| 2208 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && | 2236 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && |
| 2209 !ShouldHideUIForFullscreen()) { | 2237 !ShouldHideUIForFullscreen()) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2322 if (contents && !allow_js_access) { | 2350 if (contents && !allow_js_access) { |
| 2323 contents->web_contents()->GetController().LoadURL( | 2351 contents->web_contents()->GetController().LoadURL( |
| 2324 target_url, | 2352 target_url, |
| 2325 content::Referrer(), | 2353 content::Referrer(), |
| 2326 content::PAGE_TRANSITION_LINK, | 2354 content::PAGE_TRANSITION_LINK, |
| 2327 std::string()); // No extra headers. | 2355 std::string()); // No extra headers. |
| 2328 } | 2356 } |
| 2329 | 2357 |
| 2330 return contents != NULL; | 2358 return contents != NULL; |
| 2331 } | 2359 } |
| OLD | NEW |