OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <windows.h> | 5 #include <windows.h> |
6 #include <shellapi.h> | 6 #include <shellapi.h> |
7 | 7 |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // the session service. This function gets called during initial window | 335 // the session service. This function gets called during initial window |
336 // showing, and we don't want to bring in the session service this early. | 336 // showing, and we don't want to bring in the session service this early. |
337 if (profile()->HasSessionService()) { | 337 if (profile()->HasSessionService()) { |
338 SessionService* session_service = profile()->GetSessionService(); | 338 SessionService* session_service = profile()->GetSessionService(); |
339 if (session_service) | 339 if (session_service) |
340 session_service->SetWindowBounds(session_id_, bounds, maximized); | 340 session_service->SetWindowBounds(session_id_, bounds, maximized); |
341 } | 341 } |
342 } | 342 } |
343 | 343 |
344 gfx::Rect Browser::GetSavedWindowBounds() const { | 344 gfx::Rect Browser::GetSavedWindowBounds() const { |
345 CommandLine parsed_command_line; | 345 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
346 bool record_mode = parsed_command_line.HasSwitch(switches::kRecordMode); | 346 bool record_mode = parsed_command_line.HasSwitch(switches::kRecordMode); |
347 bool playback_mode = parsed_command_line.HasSwitch(switches::kPlaybackMode); | 347 bool playback_mode = parsed_command_line.HasSwitch(switches::kPlaybackMode); |
348 if (record_mode || playback_mode) { | 348 if (record_mode || playback_mode) { |
349 // In playback/record mode we always fix the size of the browser and | 349 // In playback/record mode we always fix the size of the browser and |
350 // move it to (0,0). The reason for this is two reasons: First we want | 350 // move it to (0,0). The reason for this is two reasons: First we want |
351 // resize/moves in the playback to still work, and Second we want | 351 // resize/moves in the playback to still work, and Second we want |
352 // playbacks to work (as much as possible) on machines w/ different | 352 // playbacks to work (as much as possible) on machines w/ different |
353 // screen sizes. | 353 // screen sizes. |
354 return gfx::Rect(0, 0, 800, 600); | 354 return gfx::Rect(0, 0, 800, 600); |
355 } | 355 } |
356 | 356 |
357 gfx::Rect restored_bounds = override_bounds_; | 357 gfx::Rect restored_bounds = override_bounds_; |
358 bool maximized; | 358 bool maximized; |
359 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, | 359 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, |
360 &restored_bounds, &maximized); | 360 &restored_bounds, &maximized); |
361 return restored_bounds; | 361 return restored_bounds; |
362 } | 362 } |
363 | 363 |
364 // TODO(beng): obtain maximized state some other way so we don't need to go | 364 // TODO(beng): obtain maximized state some other way so we don't need to go |
365 // through all this hassle. | 365 // through all this hassle. |
366 bool Browser::GetSavedMaximizedState() const { | 366 bool Browser::GetSavedMaximizedState() const { |
367 if (CommandLine().HasSwitch(switches::kStartMaximized)) | 367 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) |
368 return true; | 368 return true; |
369 | 369 |
370 gfx::Rect restored_bounds; | 370 gfx::Rect restored_bounds; |
371 bool maximized = override_maximized_; | 371 bool maximized = override_maximized_; |
372 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, | 372 WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, |
373 &restored_bounds, &maximized); | 373 &restored_bounds, &maximized); |
374 return maximized; | 374 return maximized; |
375 } | 375 } |
376 | 376 |
377 SkBitmap Browser::GetCurrentPageIcon() const { | 377 SkBitmap Browser::GetCurrentPageIcon() const { |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 | 1493 |
1494 // If the URL is part of the same web site, then load it in the same | 1494 // If the URL is part of the same web site, then load it in the same |
1495 // SiteInstance (and thus the same process). This is an optimization to | 1495 // SiteInstance (and thus the same process). This is an optimization to |
1496 // reduce process overhead; it is not necessary for compatibility. (That is, | 1496 // reduce process overhead; it is not necessary for compatibility. (That is, |
1497 // the new tab will not have script connections to the previous tab, so it | 1497 // the new tab will not have script connections to the previous tab, so it |
1498 // does not need to be part of the same SiteInstance or BrowsingInstance.) | 1498 // does not need to be part of the same SiteInstance or BrowsingInstance.) |
1499 // Default to loading in a new SiteInstance and BrowsingInstance. | 1499 // Default to loading in a new SiteInstance and BrowsingInstance. |
1500 // TODO(creis): should this apply to applications? | 1500 // TODO(creis): should this apply to applications? |
1501 SiteInstance* instance = NULL; | 1501 SiteInstance* instance = NULL; |
1502 // Don't use this logic when "--process-per-tab" is specified. | 1502 // Don't use this logic when "--process-per-tab" is specified. |
1503 if (!CommandLine().HasSwitch(switches::kProcessPerTab)) { | 1503 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab)) { |
1504 if (current_tab) { | 1504 if (current_tab) { |
1505 const WebContents* const web_contents = current_tab->AsWebContents(); | 1505 const WebContents* const web_contents = current_tab->AsWebContents(); |
1506 if (web_contents) { | 1506 if (web_contents) { |
1507 const GURL& current_url = web_contents->GetURL(); | 1507 const GURL& current_url = web_contents->GetURL(); |
1508 if (SiteInstance::IsSameWebSite(current_url, url)) | 1508 if (SiteInstance::IsSameWebSite(current_url, url)) |
1509 instance = web_contents->GetSiteInstance(); | 1509 instance = web_contents->GetSiteInstance(); |
1510 } | 1510 } |
1511 } | 1511 } |
1512 } | 1512 } |
1513 | 1513 |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 | 2409 |
2410 // We need to register the window position pref. | 2410 // We need to register the window position pref. |
2411 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2411 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
2412 window_pref.append(L"_"); | 2412 window_pref.append(L"_"); |
2413 window_pref.append(app_name); | 2413 window_pref.append(app_name); |
2414 PrefService* prefs = g_browser_process->local_state(); | 2414 PrefService* prefs = g_browser_process->local_state(); |
2415 DCHECK(prefs); | 2415 DCHECK(prefs); |
2416 | 2416 |
2417 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2417 prefs->RegisterDictionaryPref(window_pref.c_str()); |
2418 } | 2418 } |
OLD | NEW |