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/ash/launcher/chrome_launcher_controller_per_app.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/launcher/launcher_model.h" | 10 #include "ash/launcher/launcher_model.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #include "extensions/common/extension_resource.h" | 63 #include "extensions/common/extension_resource.h" |
64 #include "extensions/common/url_pattern.h" | 64 #include "extensions/common/url_pattern.h" |
65 #include "grit/ash_resources.h" | 65 #include "grit/ash_resources.h" |
66 #include "grit/chromium_strings.h" | 66 #include "grit/chromium_strings.h" |
67 #include "grit/generated_resources.h" | 67 #include "grit/generated_resources.h" |
68 #include "grit/theme_resources.h" | 68 #include "grit/theme_resources.h" |
69 #include "grit/ui_resources.h" | 69 #include "grit/ui_resources.h" |
70 #include "ui/aura/root_window.h" | 70 #include "ui/aura/root_window.h" |
71 #include "ui/aura/window.h" | 71 #include "ui/aura/window.h" |
72 #include "ui/base/l10n/l10n_util.h" | 72 #include "ui/base/l10n/l10n_util.h" |
| 73 #include "ui/views/corewm/window_animations.h" |
73 | 74 |
74 using extensions::Extension; | 75 using extensions::Extension; |
75 using content::WebContents; | 76 using content::WebContents; |
76 | 77 |
77 namespace { | 78 namespace { |
78 | 79 |
79 std::string GetPrefKeyForRootWindow(aura::RootWindow* root_window) { | 80 std::string GetPrefKeyForRootWindow(aura::RootWindow* root_window) { |
80 gfx::Display display = gfx::Screen::GetScreenFor( | 81 gfx::Display display = gfx::Screen::GetScreenFor( |
81 root_window)->GetDisplayNearestWindow(root_window); | 82 root_window)->GetDisplayNearestWindow(root_window); |
82 DCHECK(display.is_valid()); | 83 DCHECK(display.is_valid()); |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 } else { | 867 } else { |
867 NOTREACHED() << "Invalid launcher type"; | 868 NOTREACHED() << "Invalid launcher type"; |
868 } | 869 } |
869 } | 870 } |
870 | 871 |
871 const Extension* ChromeLauncherControllerPerApp::GetExtensionForAppID( | 872 const Extension* ChromeLauncherControllerPerApp::GetExtensionForAppID( |
872 const std::string& app_id) const { | 873 const std::string& app_id) const { |
873 return profile_->GetExtensionService()->GetInstalledExtension(app_id); | 874 return profile_->GetExtensionService()->GetInstalledExtension(app_id); |
874 } | 875 } |
875 | 876 |
| 877 void ChromeLauncherControllerPerApp::ActivateWindowOrMinimizeIfActive( |
| 878 BaseWindow* window, |
| 879 bool allow_minimize) { |
| 880 if (window->IsActive() && allow_minimize) { |
| 881 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 882 switches::kDisableMinimizeOnSecondLauncherItemClick)) { |
| 883 AnimateWindow(window->GetNativeWindow(), |
| 884 views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE); |
| 885 } else { |
| 886 window->Minimize(); |
| 887 } |
| 888 } else { |
| 889 window->Show(); |
| 890 window->Activate(); |
| 891 } |
| 892 } |
| 893 |
876 void ChromeLauncherControllerPerApp::OnBrowserShortcutClicked( | 894 void ChromeLauncherControllerPerApp::OnBrowserShortcutClicked( |
877 int event_flags) { | 895 int event_flags) { |
878 if (event_flags & ui::EF_CONTROL_DOWN) { | 896 if (event_flags & ui::EF_CONTROL_DOWN) { |
879 CreateNewWindow(); | 897 CreateNewWindow(); |
880 return; | 898 return; |
881 } | 899 } |
882 | 900 |
883 Browser* last_browser = chrome::FindTabbedBrowser( | 901 Browser* last_browser = chrome::FindTabbedBrowser( |
884 GetProfileForNewWindows(), true, chrome::HOST_DESKTOP_TYPE_ASH); | 902 GetProfileForNewWindows(), true, chrome::HOST_DESKTOP_TYPE_ASH); |
885 | 903 |
886 if (!last_browser) { | 904 if (!last_browser) { |
887 CreateNewWindow(); | 905 CreateNewWindow(); |
888 return; | 906 return; |
889 } | 907 } |
890 | 908 |
891 aura::Window* window = last_browser->window()->GetNativeWindow(); | 909 ActivateWindowOrMinimizeIfActive(last_browser->window(), |
892 window->Show(); | 910 GetBrowserApplicationList(0).size() == 2); |
893 ash::wm::ActivateWindow(window); | |
894 } | 911 } |
895 | 912 |
896 void ChromeLauncherControllerPerApp::ItemClicked(const ash::LauncherItem& item, | 913 void ChromeLauncherControllerPerApp::ItemClicked(const ash::LauncherItem& item, |
897 const ui::Event& event) { | 914 const ui::Event& event) { |
898 DCHECK(HasItemController(item.id)); | 915 DCHECK(HasItemController(item.id)); |
899 id_to_item_controller_map_[item.id]->Clicked(event); | 916 id_to_item_controller_map_[item.id]->Clicked(event); |
900 } | 917 } |
901 | 918 |
902 int ChromeLauncherControllerPerApp::GetBrowserShortcutResourceId() { | 919 int ChromeLauncherControllerPerApp::GetBrowserShortcutResourceId() { |
903 return IDR_PRODUCT_LOGO_32; | 920 return IDR_PRODUCT_LOGO_32; |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 GetLauncherIDForAppID(web_app::GetExtensionIdFromApplicationName( | 1615 GetLauncherIDForAppID(web_app::GetExtensionIdFromApplicationName( |
1599 browser->app_name())) <= 0)); | 1616 browser->app_name())) <= 0)); |
1600 } | 1617 } |
1601 | 1618 |
1602 bool ChromeLauncherControllerPerApp::IsIncognito( | 1619 bool ChromeLauncherControllerPerApp::IsIncognito( |
1603 content::WebContents* web_contents) const { | 1620 content::WebContents* web_contents) const { |
1604 const Profile* profile = | 1621 const Profile* profile = |
1605 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 1622 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
1606 return profile->IsOffTheRecord() && !profile->IsGuestSession(); | 1623 return profile->IsOffTheRecord() && !profile->IsGuestSession(); |
1607 } | 1624 } |
OLD | NEW |