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

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

Issue 187443008: Elim Browser::AppType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and add non trusted type test Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_browsertest.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 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } // namespace 244 } // namespace
245 245
246 //////////////////////////////////////////////////////////////////////////////// 246 ////////////////////////////////////////////////////////////////////////////////
247 // Browser, CreateParams: 247 // Browser, CreateParams:
248 248
249 Browser::CreateParams::CreateParams(Profile* profile, 249 Browser::CreateParams::CreateParams(Profile* profile,
250 chrome::HostDesktopType host_desktop_type) 250 chrome::HostDesktopType host_desktop_type)
251 : type(TYPE_TABBED), 251 : type(TYPE_TABBED),
252 profile(profile), 252 profile(profile),
253 host_desktop_type(host_desktop_type), 253 host_desktop_type(host_desktop_type),
254 app_type(APP_TYPE_HOST),
255 initial_show_state(ui::SHOW_STATE_DEFAULT), 254 initial_show_state(ui::SHOW_STATE_DEFAULT),
256 is_session_restore(false), 255 is_session_restore(false),
257 window(NULL) { 256 window(NULL) {
258 } 257 }
259 258
260 Browser::CreateParams::CreateParams(Type type, 259 Browser::CreateParams::CreateParams(Type type,
261 Profile* profile, 260 Profile* profile,
262 chrome::HostDesktopType host_desktop_type) 261 chrome::HostDesktopType host_desktop_type)
263 : type(type), 262 : type(type),
264 profile(profile), 263 profile(profile),
265 host_desktop_type(host_desktop_type), 264 host_desktop_type(host_desktop_type),
266 app_type(APP_TYPE_HOST),
267 initial_show_state(ui::SHOW_STATE_DEFAULT), 265 initial_show_state(ui::SHOW_STATE_DEFAULT),
268 is_session_restore(false), 266 is_session_restore(false),
269 window(NULL) { 267 window(NULL) {
270 } 268 }
271 269
272 // static 270 // static
273 Browser::CreateParams Browser::CreateParams::CreateForApp( 271 Browser::CreateParams Browser::CreateParams::CreateForApp(
274 Type type, 272 Type type,
275 const std::string& app_name, 273 const std::string& app_name,
276 const gfx::Rect& window_bounds, 274 const gfx::Rect& window_bounds,
277 Profile* profile, 275 Profile* profile,
278 chrome::HostDesktopType host_desktop_type) { 276 chrome::HostDesktopType host_desktop_type) {
279 DCHECK(type != TYPE_TABBED); 277 DCHECK(type != TYPE_TABBED);
280 DCHECK(!app_name.empty()); 278 DCHECK(!app_name.empty());
281 279
282 CreateParams params(type, profile, host_desktop_type); 280 CreateParams params(type, profile, host_desktop_type);
283 params.app_name = app_name; 281 params.app_name = app_name;
284 params.app_type = APP_TYPE_CHILD;
285 params.initial_bounds = window_bounds; 282 params.initial_bounds = window_bounds;
286 283
287 return params; 284 return params;
288 } 285 }
289 286
290 // static 287 // static
291 Browser::CreateParams Browser::CreateParams::CreateForDevTools( 288 Browser::CreateParams Browser::CreateParams::CreateForDevTools(
292 Profile* profile, 289 Profile* profile,
293 chrome::HostDesktopType host_desktop_type) { 290 chrome::HostDesktopType host_desktop_type) {
294 CreateParams params(TYPE_POPUP, profile, host_desktop_type); 291 CreateParams params(TYPE_POPUP, profile, host_desktop_type);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // Browser, Constructors, Creation, Showing: 323 // Browser, Constructors, Creation, Showing:
327 324
328 Browser::Browser(const CreateParams& params) 325 Browser::Browser(const CreateParams& params)
329 : type_(params.type), 326 : type_(params.type),
330 profile_(params.profile), 327 profile_(params.profile),
331 window_(NULL), 328 window_(NULL),
332 tab_strip_model_delegate_(new chrome::BrowserTabStripModelDelegate(this)), 329 tab_strip_model_delegate_(new chrome::BrowserTabStripModelDelegate(this)),
333 tab_strip_model_(new TabStripModel(tab_strip_model_delegate_.get(), 330 tab_strip_model_(new TabStripModel(tab_strip_model_delegate_.get(),
334 params.profile)), 331 params.profile)),
335 app_name_(params.app_name), 332 app_name_(params.app_name),
336 app_type_(params.app_type),
337 cancel_download_confirmation_state_(NOT_PROMPTED), 333 cancel_download_confirmation_state_(NOT_PROMPTED),
338 override_bounds_(params.initial_bounds), 334 override_bounds_(params.initial_bounds),
339 initial_show_state_(params.initial_show_state), 335 initial_show_state_(params.initial_show_state),
340 is_session_restore_(params.is_session_restore), 336 is_session_restore_(params.is_session_restore),
341 host_desktop_type_(BrowserWindow::AdjustHostDesktopType( 337 host_desktop_type_(BrowserWindow::AdjustHostDesktopType(
342 params.host_desktop_type)), 338 params.host_desktop_type)),
343 content_setting_bubble_model_delegate_( 339 content_setting_bubble_model_delegate_(
344 new BrowserContentSettingBubbleModelDelegate(this)), 340 new BrowserContentSettingBubbleModelDelegate(this)),
345 toolbar_model_delegate_(new BrowserToolbarModelDelegate(this)), 341 toolbar_model_delegate_(new BrowserToolbarModelDelegate(this)),
346 tab_restore_service_delegate_(new BrowserTabRestoreServiceDelegate(this)), 342 tab_restore_service_delegate_(new BrowserTabRestoreServiceDelegate(this)),
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 if (interstitial_observers_[i]->web_contents() != contents) 2175 if (interstitial_observers_[i]->web_contents() != contents)
2180 continue; 2176 continue;
2181 2177
2182 delete interstitial_observers_[i]; 2178 delete interstitial_observers_[i];
2183 interstitial_observers_.erase(interstitial_observers_.begin() + i); 2179 interstitial_observers_.erase(interstitial_observers_.begin() + i);
2184 return; 2180 return;
2185 } 2181 }
2186 } 2182 }
2187 2183
2188 bool Browser::ShouldShowLocationBar() const { 2184 bool Browser::ShouldShowLocationBar() const {
2189 if (!is_app()) { 2185 // Trusted apps and system windows (e.g. settings) do not show a location bar.
2190 // Hide the URL for singleton settings windows. 2186 if (type() == TYPE_TRUSTED_POPUP)
2191 // TODO(stevenjb): We could avoid this check by setting a Browser 2187 return false;
2192 // property for "system" windows, possibly shared with hosted app windows. 2188
2193 // crbug.com/350128. 2189 // Other non-app browsers always show a location bar.
2194 if (chrome::IsSettingsWindow(this)) 2190 if (!is_app())
2195 return false;
2196 return true; 2191 return true;
2192
2193 // Normally non trusted app windows do not show a location bar.
2194 if (app_name() == DevToolsWindow::kDevToolsApp ||
2195 !CommandLine::ForCurrentProcess()->HasSwitch(
2196 switches::kEnableStreamlinedHostedApps)) {
2197 return false;
2197 } 2198 }
2198 2199
2199 // Normally apps do not show a location bar.
2200 if (app_type() != APP_TYPE_HOST ||
2201 app_name() == DevToolsWindow::kDevToolsApp ||
2202 !CommandLine::ForCurrentProcess()->HasSwitch(
2203 switches::kEnableStreamlinedHostedApps))
2204 return false;
2205
2206 // If kEnableStreamlinedHostedApps is true, show the locaiton bar for non 2200 // If kEnableStreamlinedHostedApps is true, show the locaiton bar for non
2207 // legacy packaged apps. 2201 // legacy packaged apps.
2208 ExtensionService* service = 2202 ExtensionService* service =
2209 extensions::ExtensionSystem::Get(profile_)->extension_service(); 2203 extensions::ExtensionSystem::Get(profile_)->extension_service();
2210 const extensions::Extension* extension = 2204 const extensions::Extension* extension =
2211 service ? service->GetInstalledExtension( 2205 service ? service->GetInstalledExtension(
2212 web_app::GetExtensionIdFromApplicationName(app_name())) 2206 web_app::GetExtensionIdFromApplicationName(app_name()))
2213 : NULL; 2207 : NULL;
2214 return (!extension || !extension->is_legacy_packaged_app()); 2208 return (!extension || !extension->is_legacy_packaged_app());
2215 } 2209 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 if (contents && !allow_js_access) { 2354 if (contents && !allow_js_access) {
2361 contents->web_contents()->GetController().LoadURL( 2355 contents->web_contents()->GetController().LoadURL(
2362 target_url, 2356 target_url,
2363 content::Referrer(), 2357 content::Referrer(),
2364 content::PAGE_TRANSITION_LINK, 2358 content::PAGE_TRANSITION_LINK,
2365 std::string()); // No extra headers. 2359 std::string()); // No extra headers.
2366 } 2360 }
2367 2361
2368 return contents != NULL; 2362 return contents != NULL;
2369 } 2363 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698