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_commands.h" | 5 #include "chrome/browser/ui/browser_commands.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 last_committed_entry ? last_committed_entry->GetURL() : GURL()) || | 329 last_committed_entry ? last_committed_entry->GetURL() : GURL()) || |
| 330 current_tab->ShowingInterstitialPage()) | 330 current_tab->ShowingInterstitialPage()) |
| 331 content_restrictions |= CONTENT_RESTRICTION_SAVE; | 331 content_restrictions |= CONTENT_RESTRICTION_SAVE; |
| 332 if (current_tab->ShowingInterstitialPage()) | 332 if (current_tab->ShowingInterstitialPage()) |
| 333 content_restrictions |= CONTENT_RESTRICTION_PRINT; | 333 content_restrictions |= CONTENT_RESTRICTION_PRINT; |
| 334 } | 334 } |
| 335 return content_restrictions; | 335 return content_restrictions; |
| 336 } | 336 } |
| 337 | 337 |
| 338 void NewEmptyWindow(Profile* profile, HostDesktopType desktop_type) { | 338 void NewEmptyWindow(Profile* profile, HostDesktopType desktop_type) { |
| 339 NewWindow(profile, desktop_type, GURL()); | |
| 340 } | |
| 341 | |
| 342 Browser* OpenEmptyWindow(Profile* profile, HostDesktopType desktop_type) { | |
|
dgozman
2014/07/21 13:43:47
I think, this method is not used anymore.
| |
| 343 return OpenWindow(profile, desktop_type, GURL()); | |
| 344 } | |
| 345 | |
| 346 void NewWindow(Profile* profile, | |
| 347 HostDesktopType desktop_type, | |
| 348 const GURL& url) { | |
| 339 bool incognito = profile->IsOffTheRecord(); | 349 bool incognito = profile->IsOffTheRecord(); |
| 340 PrefService* prefs = profile->GetPrefs(); | 350 PrefService* prefs = profile->GetPrefs(); |
| 341 if (incognito) { | 351 if (incognito) { |
| 342 if (IncognitoModePrefs::GetAvailability(prefs) == | 352 if (IncognitoModePrefs::GetAvailability(prefs) == |
| 343 IncognitoModePrefs::DISABLED) { | 353 IncognitoModePrefs::DISABLED) { |
| 344 incognito = false; | 354 incognito = false; |
| 345 } | 355 } |
| 346 } else if (profile->IsGuestSession() || | 356 } else if (profile->IsGuestSession() || |
| 347 (browser_defaults::kAlwaysOpenIncognitoWindow && | 357 (browser_defaults::kAlwaysOpenIncognitoWindow && |
| 348 IncognitoModePrefs::ShouldLaunchIncognito( | 358 IncognitoModePrefs::ShouldLaunchIncognito( |
| 349 *CommandLine::ForCurrentProcess(), prefs))) { | 359 *CommandLine::ForCurrentProcess(), prefs))) { |
| 350 incognito = true; | 360 incognito = true; |
| 351 } | 361 } |
| 352 | 362 |
| 353 if (incognito) { | 363 if (incognito) { |
| 354 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); | 364 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); |
| 355 OpenEmptyWindow(profile->GetOffTheRecordProfile(), desktop_type); | 365 OpenWindow(profile->GetOffTheRecordProfile(), desktop_type, url); |
| 356 } else { | 366 } else { |
| 357 content::RecordAction(UserMetricsAction("NewWindow")); | 367 content::RecordAction(UserMetricsAction("NewWindow")); |
| 358 SessionService* session_service = | 368 SessionService* session_service = |
| 359 SessionServiceFactory::GetForProfileForSessionRestore( | 369 SessionServiceFactory::GetForProfileForSessionRestore( |
| 360 profile->GetOriginalProfile()); | 370 profile->GetOriginalProfile()); |
| 361 if (!session_service || | 371 if (!session_service || |
| 362 !session_service->RestoreIfNecessary(std::vector<GURL>())) { | 372 !session_service->RestoreIfNecessary(std::vector<GURL>())) { |
| 363 OpenEmptyWindow(profile->GetOriginalProfile(), desktop_type); | 373 OpenWindow(profile->GetOriginalProfile(), desktop_type, url); |
| 364 } | 374 } |
| 365 } | 375 } |
| 366 } | 376 } |
| 367 | 377 |
| 368 Browser* OpenEmptyWindow(Profile* profile, HostDesktopType desktop_type) { | 378 Browser* OpenWindow(Profile* profile, |
| 379 HostDesktopType desktop_type, | |
| 380 const GURL& url) { | |
| 369 Browser* browser = new Browser( | 381 Browser* browser = new Browser( |
| 370 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); | 382 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); |
| 371 AddTabAt(browser, GURL(), -1, true); | 383 AddTabAt(browser, url, -1, true); |
| 372 browser->window()->Show(); | 384 browser->window()->Show(); |
| 373 return browser; | 385 return browser; |
| 374 } | 386 } |
| 375 | 387 |
| 376 void OpenWindowWithRestoredTabs(Profile* profile, | 388 void OpenWindowWithRestoredTabs(Profile* profile, |
| 377 HostDesktopType host_desktop_type) { | 389 HostDesktopType host_desktop_type) { |
| 378 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); | 390 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); |
| 379 if (service) | 391 if (service) |
| 380 service->RestoreMostRecentEntry(NULL, host_desktop_type); | 392 service->RestoreMostRecentEntry(NULL, host_desktop_type); |
| 381 } | 393 } |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 browser->profile(), | 1298 browser->profile(), |
| 1287 browser->host_desktop_type())); | 1299 browser->host_desktop_type())); |
| 1288 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1300 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
| 1289 | 1301 |
| 1290 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1302 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1291 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1303 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1292 app_browser->window()->Show(); | 1304 app_browser->window()->Show(); |
| 1293 } | 1305 } |
| 1294 | 1306 |
| 1295 } // namespace chrome | 1307 } // namespace chrome |
| OLD | NEW |