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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (!content::IsSavableURL( | 313 if (!content::IsSavableURL( |
314 last_committed_entry ? last_committed_entry->GetURL() : GURL()) || | 314 last_committed_entry ? last_committed_entry->GetURL() : GURL()) || |
315 current_tab->ShowingInterstitialPage()) | 315 current_tab->ShowingInterstitialPage()) |
316 content_restrictions |= CONTENT_RESTRICTION_SAVE; | 316 content_restrictions |= CONTENT_RESTRICTION_SAVE; |
317 if (current_tab->ShowingInterstitialPage()) | 317 if (current_tab->ShowingInterstitialPage()) |
318 content_restrictions |= CONTENT_RESTRICTION_PRINT; | 318 content_restrictions |= CONTENT_RESTRICTION_PRINT; |
319 } | 319 } |
320 return content_restrictions; | 320 return content_restrictions; |
321 } | 321 } |
322 | 322 |
323 void NewEmptyWindow(Profile* profile, HostDesktopType desktop_type) { | 323 void NewEmptyWindow(Profile* profile, ui::HostDesktopType desktop_type) { |
324 bool incognito = profile->IsOffTheRecord(); | 324 bool incognito = profile->IsOffTheRecord(); |
325 PrefService* prefs = profile->GetPrefs(); | 325 PrefService* prefs = profile->GetPrefs(); |
326 if (incognito) { | 326 if (incognito) { |
327 if (IncognitoModePrefs::GetAvailability(prefs) == | 327 if (IncognitoModePrefs::GetAvailability(prefs) == |
328 IncognitoModePrefs::DISABLED) { | 328 IncognitoModePrefs::DISABLED) { |
329 incognito = false; | 329 incognito = false; |
330 } | 330 } |
331 } else if (profile->IsGuestSession() || | 331 } else if (profile->IsGuestSession() || |
332 (browser_defaults::kAlwaysOpenIncognitoWindow && | 332 (browser_defaults::kAlwaysOpenIncognitoWindow && |
333 IncognitoModePrefs::ShouldLaunchIncognito( | 333 IncognitoModePrefs::ShouldLaunchIncognito( |
334 *base::CommandLine::ForCurrentProcess(), prefs))) { | 334 *base::CommandLine::ForCurrentProcess(), prefs))) { |
335 incognito = true; | 335 incognito = true; |
336 } | 336 } |
337 | 337 |
338 if (incognito) { | 338 if (incognito) { |
339 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); | 339 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); |
340 OpenEmptyWindow(profile->GetOffTheRecordProfile(), desktop_type); | 340 OpenEmptyWindow(profile->GetOffTheRecordProfile(), desktop_type); |
341 } else { | 341 } else { |
342 content::RecordAction(UserMetricsAction("NewWindow")); | 342 content::RecordAction(UserMetricsAction("NewWindow")); |
343 SessionService* session_service = | 343 SessionService* session_service = |
344 SessionServiceFactory::GetForProfileForSessionRestore( | 344 SessionServiceFactory::GetForProfileForSessionRestore( |
345 profile->GetOriginalProfile()); | 345 profile->GetOriginalProfile()); |
346 if (!session_service || | 346 if (!session_service || |
347 !session_service->RestoreIfNecessary(std::vector<GURL>())) { | 347 !session_service->RestoreIfNecessary(std::vector<GURL>())) { |
348 OpenEmptyWindow(profile->GetOriginalProfile(), desktop_type); | 348 OpenEmptyWindow(profile->GetOriginalProfile(), desktop_type); |
349 } | 349 } |
350 } | 350 } |
351 } | 351 } |
352 | 352 |
353 Browser* OpenEmptyWindow(Profile* profile, HostDesktopType desktop_type) { | 353 Browser* OpenEmptyWindow(Profile* profile, ui::HostDesktopType desktop_type) { |
354 Browser* browser = new Browser( | 354 Browser* browser = new Browser( |
355 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); | 355 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); |
356 AddTabAt(browser, GURL(), -1, true); | 356 AddTabAt(browser, GURL(), -1, true); |
357 browser->window()->Show(); | 357 browser->window()->Show(); |
358 return browser; | 358 return browser; |
359 } | 359 } |
360 | 360 |
361 void OpenWindowWithRestoredTabs(Profile* profile, | 361 void OpenWindowWithRestoredTabs(Profile* profile, |
362 HostDesktopType host_desktop_type) { | 362 ui::HostDesktopType host_desktop_type) { |
363 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); | 363 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); |
364 if (service) | 364 if (service) |
365 service->RestoreMostRecentEntry(NULL, host_desktop_type); | 365 service->RestoreMostRecentEntry(NULL, host_desktop_type); |
366 } | 366 } |
367 | 367 |
368 void OpenURLOffTheRecord(Profile* profile, | 368 void OpenURLOffTheRecord(Profile* profile, |
369 const GURL& url, | 369 const GURL& url, |
370 chrome::HostDesktopType desktop_type) { | 370 ui::HostDesktopType desktop_type) { |
371 ScopedTabbedBrowserDisplayer displayer(profile->GetOffTheRecordProfile(), | 371 ScopedTabbedBrowserDisplayer displayer(profile->GetOffTheRecordProfile(), |
372 desktop_type); | 372 desktop_type); |
373 AddSelectedTabWithURL(displayer.browser(), url, | 373 AddSelectedTabWithURL(displayer.browser(), url, |
374 ui::PAGE_TRANSITION_LINK); | 374 ui::PAGE_TRANSITION_LINK); |
375 } | 375 } |
376 | 376 |
377 bool CanGoBack(const Browser* browser) { | 377 bool CanGoBack(const Browser* browser) { |
378 return browser->tab_strip_model()->GetActiveWebContents()-> | 378 return browser->tab_strip_model()->GetActiveWebContents()-> |
379 GetController().CanGoBack(); | 379 GetController().CanGoBack(); |
380 } | 380 } |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 void BasicPrint(Browser* browser) { | 894 void BasicPrint(Browser* browser) { |
895 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); | 895 printing::StartBasicPrint(browser->tab_strip_model()->GetActiveWebContents()); |
896 } | 896 } |
897 | 897 |
898 bool CanBasicPrint(Browser* browser) { | 898 bool CanBasicPrint(Browser* browser) { |
899 // If printing is not disabled via pref or policy, it is always possible to | 899 // If printing is not disabled via pref or policy, it is always possible to |
900 // advanced print when the print preview is visible. The exception to this | 900 // advanced print when the print preview is visible. The exception to this |
901 // is under Win8 ash, since showing the advanced print dialog will open it | 901 // is under Win8 ash, since showing the advanced print dialog will open it |
902 // modally on the Desktop and hang the browser. | 902 // modally on the Desktop and hang the browser. |
903 #if defined(OS_WIN) | 903 #if defined(OS_WIN) |
904 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) | 904 if (chrome::GetActiveDesktop() == ui::HOST_DESKTOP_TYPE_ASH) |
905 return false; | 905 return false; |
906 #endif | 906 #endif |
907 | 907 |
908 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && | 908 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && |
909 (PrintPreviewShowing(browser) || CanPrint(browser)); | 909 (PrintPreviewShowing(browser) || CanPrint(browser)); |
910 } | 910 } |
911 #endif // ENABLE_BASIC_PRINTING | 911 #endif // ENABLE_BASIC_PRINTING |
912 | 912 |
913 void EmailPageLocation(Browser* browser) { | 913 void EmailPageLocation(Browser* browser) { |
914 content::RecordAction(UserMetricsAction("EmailPageLocation")); | 914 content::RecordAction(UserMetricsAction("EmailPageLocation")); |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 browser->host_desktop_type())); | 1284 browser->host_desktop_type())); |
1285 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1285 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1286 | 1286 |
1287 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1287 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1288 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1288 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1289 app_browser->window()->Show(); | 1289 app_browser->window()->Show(); |
1290 } | 1290 } |
1291 #endif // defined(ENABLE_EXTENSIONS) | 1291 #endif // defined(ENABLE_EXTENSIONS) |
1292 | 1292 |
1293 } // namespace chrome | 1293 } // namespace chrome |
OLD | NEW |