| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 } | 634 } |
| 635 | 635 |
| 636 bool Browser::is_devtools() const { | 636 bool Browser::is_devtools() const { |
| 637 return app_name_ == DevToolsWindow::kDevToolsApp; | 637 return app_name_ == DevToolsWindow::kDevToolsApp; |
| 638 } | 638 } |
| 639 | 639 |
| 640 /////////////////////////////////////////////////////////////////////////////// | 640 /////////////////////////////////////////////////////////////////////////////// |
| 641 // Browser, Creation Helpers: | 641 // Browser, Creation Helpers: |
| 642 | 642 |
| 643 // static | 643 // static |
| 644 void Browser::NewEmptyWindow(Profile* profile) { | 644 Browser* Browser::NewEmptyWindow(Profile* profile) { |
| 645 bool incognito = profile->IsOffTheRecord(); | 645 bool incognito = profile->IsOffTheRecord(); |
| 646 PrefService* prefs = profile->GetPrefs(); | 646 PrefService* prefs = profile->GetPrefs(); |
| 647 if (incognito) { | 647 if (incognito) { |
| 648 if (IncognitoModePrefs::GetAvailability(prefs) == | 648 if (IncognitoModePrefs::GetAvailability(prefs) == |
| 649 IncognitoModePrefs::DISABLED) { | 649 IncognitoModePrefs::DISABLED) { |
| 650 incognito = false; | 650 incognito = false; |
| 651 } | 651 } |
| 652 } else { | 652 } else { |
| 653 if (browser_defaults::kAlwaysOpenIncognitoWindow && | 653 if (browser_defaults::kAlwaysOpenIncognitoWindow && |
| 654 IncognitoModePrefs::ShouldLaunchIncognito( | 654 IncognitoModePrefs::ShouldLaunchIncognito( |
| 655 *CommandLine::ForCurrentProcess(), prefs)) { | 655 *CommandLine::ForCurrentProcess(), prefs)) { |
| 656 incognito = true; | 656 incognito = true; |
| 657 } | 657 } |
| 658 } | 658 } |
| 659 | 659 |
| 660 if (incognito) { | 660 if (incognito) { |
| 661 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); | 661 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); |
| 662 OpenEmptyWindow(profile->GetOffTheRecordProfile()); | 662 return OpenEmptyWindow(profile->GetOffTheRecordProfile()); |
| 663 } else { | 663 } else { |
| 664 content::RecordAction(UserMetricsAction("NewWindow")); | 664 content::RecordAction(UserMetricsAction("NewWindow")); |
| 665 SessionService* session_service = | 665 SessionService* session_service = |
| 666 SessionServiceFactory::GetForProfile(profile->GetOriginalProfile()); | 666 SessionServiceFactory::GetForProfile(profile->GetOriginalProfile()); |
| 667 if (!session_service || | 667 if (!session_service || |
| 668 !session_service->RestoreIfNecessary(std::vector<GURL>())) { | 668 !session_service->RestoreIfNecessary(std::vector<GURL>())) { |
| 669 OpenEmptyWindow(profile->GetOriginalProfile()); | 669 return OpenEmptyWindow(profile->GetOriginalProfile()); |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 return NULL; |
| 672 } | 673 } |
| 673 | 674 |
| 674 // static | 675 // static |
| 675 void Browser::OpenEmptyWindow(Profile* profile) { | 676 Browser* Browser::OpenEmptyWindow(Profile* profile) { |
| 676 Browser* browser = Browser::Create(profile); | 677 Browser* browser = Browser::Create(profile); |
| 677 browser->AddBlankTab(true); | 678 browser->AddBlankTab(true); |
| 678 browser->window()->Show(); | 679 browser->window()->Show(); |
| 680 return browser; |
| 679 } | 681 } |
| 680 | 682 |
| 681 // static | 683 // static |
| 682 void Browser::OpenWindowWithRestoredTabs(Profile* profile) { | 684 void Browser::OpenWindowWithRestoredTabs(Profile* profile) { |
| 683 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); | 685 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); |
| 684 if (service) | 686 if (service) |
| 685 service->RestoreMostRecentEntry(NULL); | 687 service->RestoreMostRecentEntry(NULL); |
| 686 } | 688 } |
| 687 | 689 |
| 688 // static | 690 // static |
| (...skipping 4931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5620 } else { | 5622 } else { |
| 5621 LoginUIServiceFactory::GetForProfile( | 5623 LoginUIServiceFactory::GetForProfile( |
| 5622 profile()->GetOriginalProfile())->ShowLoginUI(); | 5624 profile()->GetOriginalProfile())->ShowLoginUI(); |
| 5623 } | 5625 } |
| 5624 #endif | 5626 #endif |
| 5625 } | 5627 } |
| 5626 | 5628 |
| 5627 void Browser::ToggleSpeechInput() { | 5629 void Browser::ToggleSpeechInput() { |
| 5628 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5630 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
| 5629 } | 5631 } |
| OLD | NEW |