| 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 } | 635 } |
| 636 | 636 |
| 637 bool Browser::is_devtools() const { | 637 bool Browser::is_devtools() const { |
| 638 return app_name_ == DevToolsWindow::kDevToolsApp; | 638 return app_name_ == DevToolsWindow::kDevToolsApp; |
| 639 } | 639 } |
| 640 | 640 |
| 641 /////////////////////////////////////////////////////////////////////////////// | 641 /////////////////////////////////////////////////////////////////////////////// |
| 642 // Browser, Creation Helpers: | 642 // Browser, Creation Helpers: |
| 643 | 643 |
| 644 // static | 644 // static |
| 645 void Browser::NewEmptyWindow(Profile* profile) { | 645 Browser* Browser::NewEmptyWindow(Profile* profile) { |
| 646 bool incognito = profile->IsOffTheRecord(); | 646 bool incognito = profile->IsOffTheRecord(); |
| 647 PrefService* prefs = profile->GetPrefs(); | 647 PrefService* prefs = profile->GetPrefs(); |
| 648 if (incognito) { | 648 if (incognito) { |
| 649 if (IncognitoModePrefs::GetAvailability(prefs) == | 649 if (IncognitoModePrefs::GetAvailability(prefs) == |
| 650 IncognitoModePrefs::DISABLED) { | 650 IncognitoModePrefs::DISABLED) { |
| 651 incognito = false; | 651 incognito = false; |
| 652 } | 652 } |
| 653 } else { | 653 } else { |
| 654 if (browser_defaults::kAlwaysOpenIncognitoWindow && | 654 if (browser_defaults::kAlwaysOpenIncognitoWindow && |
| 655 IncognitoModePrefs::ShouldLaunchIncognito( | 655 IncognitoModePrefs::ShouldLaunchIncognito( |
| 656 *CommandLine::ForCurrentProcess(), prefs)) { | 656 *CommandLine::ForCurrentProcess(), prefs)) { |
| 657 incognito = true; | 657 incognito = true; |
| 658 } | 658 } |
| 659 } | 659 } |
| 660 | 660 |
| 661 if (incognito) { | 661 if (incognito) { |
| 662 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); | 662 content::RecordAction(UserMetricsAction("NewIncognitoWindow")); |
| 663 OpenEmptyWindow(profile->GetOffTheRecordProfile()); | 663 return OpenEmptyWindow(profile->GetOffTheRecordProfile()); |
| 664 } else { | 664 } else { |
| 665 content::RecordAction(UserMetricsAction("NewWindow")); | 665 content::RecordAction(UserMetricsAction("NewWindow")); |
| 666 SessionService* session_service = | 666 SessionService* session_service = |
| 667 SessionServiceFactory::GetForProfile(profile->GetOriginalProfile()); | 667 SessionServiceFactory::GetForProfile(profile->GetOriginalProfile()); |
| 668 if (!session_service || | 668 if (!session_service || |
| 669 !session_service->RestoreIfNecessary(std::vector<GURL>())) { | 669 !session_service->RestoreIfNecessary(std::vector<GURL>())) { |
| 670 OpenEmptyWindow(profile->GetOriginalProfile()); | 670 return OpenEmptyWindow(profile->GetOriginalProfile()); |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 return NULL; |
| 673 } | 674 } |
| 674 | 675 |
| 675 // static | 676 // static |
| 676 void Browser::OpenEmptyWindow(Profile* profile) { | 677 Browser* Browser::OpenEmptyWindow(Profile* profile) { |
| 677 Browser* browser = Browser::Create(profile); | 678 Browser* browser = Browser::Create(profile); |
| 678 browser->AddBlankTab(true); | 679 browser->AddBlankTab(true); |
| 679 browser->window()->Show(); | 680 browser->window()->Show(); |
| 681 return browser; |
| 680 } | 682 } |
| 681 | 683 |
| 682 // static | 684 // static |
| 683 void Browser::OpenWindowWithRestoredTabs(Profile* profile) { | 685 void Browser::OpenWindowWithRestoredTabs(Profile* profile) { |
| 684 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); | 686 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); |
| 685 if (service) | 687 if (service) |
| 686 service->RestoreMostRecentEntry(NULL); | 688 service->RestoreMostRecentEntry(NULL); |
| 687 } | 689 } |
| 688 | 690 |
| 689 // static | 691 // static |
| (...skipping 4959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5649 } else { | 5651 } else { |
| 5650 LoginUIServiceFactory::GetForProfile( | 5652 LoginUIServiceFactory::GetForProfile( |
| 5651 profile()->GetOriginalProfile())->ShowLoginUI(); | 5653 profile()->GetOriginalProfile())->ShowLoginUI(); |
| 5652 } | 5654 } |
| 5653 #endif | 5655 #endif |
| 5654 } | 5656 } |
| 5655 | 5657 |
| 5656 void Browser::ToggleSpeechInput() { | 5658 void Browser::ToggleSpeechInput() { |
| 5657 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); | 5659 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); |
| 5658 } | 5660 } |
| OLD | NEW |