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/views/aura/chrome_shell_delegate.h" | 5 #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h" |
6 | 6 |
7 #include "ash/launcher/launcher_types.h" | 7 #include "ash/launcher/launcher_types.h" |
8 #include "ash/wm/window_util.h" | 8 #include "ash/wm/window_util.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
11 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 11 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
15 #include "chrome/browser/ui/views/aura/app_list/app_list_model_builder.h" | 15 #include "chrome/browser/ui/views/aura/app_list/app_list_model_builder.h" |
16 #include "chrome/browser/ui/views/aura/app_list/app_list_view_delegate.h" | 16 #include "chrome/browser/ui/views/aura/app_list/app_list_view_delegate.h" |
17 #include "chrome/browser/ui/views/aura/launcher_icon_updater.h" | 17 #include "chrome/browser/ui/views/aura/launcher_icon_updater.h" |
18 #include "chrome/browser/ui/views/aura/status_area_host_aura.h" | 18 #include "chrome/browser/ui/views/aura/status_area_host_aura.h" |
19 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 20 #include "content/public/browser/page_navigator.h" |
20 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
22 | 23 |
23 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
24 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 25 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
25 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 26 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 27 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h" |
26 #endif | 28 #endif |
27 namespace { | 29 namespace { |
28 | 30 |
29 // Returns a list of Aura windows from a BrowserList, using either a | 31 // Returns a list of Aura windows from a BrowserList, using either a |
30 // const_iterator or const_reverse_iterator. | 32 // const_iterator or const_reverse_iterator. |
31 template<typename IT> | 33 template<typename IT> |
32 std::vector<aura::Window*> GetTabbedBrowserWindows(IT begin, IT end) { | 34 std::vector<aura::Window*> GetTabbedBrowserWindows(IT begin, IT end) { |
33 std::vector<aura::Window*> windows; | 35 std::vector<aura::Window*> windows; |
34 for (IT it = begin; it != end; ++it) { | 36 for (IT it = begin; it != end; ++it) { |
35 Browser* browser = *it; | 37 Browser* browser = *it; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 windows = GetTabbedBrowserWindows(BrowserList::begin(), | 106 windows = GetTabbedBrowserWindows(BrowserList::begin(), |
105 BrowserList::end()); | 107 BrowserList::end()); |
106 break; | 108 break; |
107 default: | 109 default: |
108 NOTREACHED(); | 110 NOTREACHED(); |
109 break; | 111 break; |
110 } | 112 } |
111 return windows; | 113 return windows; |
112 } | 114 } |
113 | 115 |
| 116 void ChromeShellDelegate::OpenNewTab(NewTabContentType type) { |
| 117 GURL new_tab_url; |
| 118 Browser* browser = BrowserList::GetLastActive(); |
| 119 |
| 120 switch (type) { |
| 121 case NEW_TAB_CONTENT_CROSH: |
| 122 #if defined(OS_CHROMEOS) |
| 123 new_tab_url = |
| 124 TerminalExtensionHelper::GetCroshExtensionURL(browser->profile()); |
| 125 #endif |
| 126 break; |
| 127 default: |
| 128 NOTREACHED(); |
| 129 break; |
| 130 } |
| 131 |
| 132 if (!new_tab_url.is_valid()) |
| 133 return; |
| 134 |
| 135 browser->OpenURL(content::OpenURLParams(new_tab_url, |
| 136 content::Referrer(), |
| 137 NEW_FOREGROUND_TAB, |
| 138 content::PAGE_TRANSITION_GENERATED, |
| 139 false)); |
| 140 } |
| 141 |
114 void ChromeShellDelegate::CreateNewWindow() { | 142 void ChromeShellDelegate::CreateNewWindow() { |
115 Profile* profile = ProfileManager::GetDefaultProfile(); | 143 Profile* profile = ProfileManager::GetDefaultProfile(); |
116 if (browser_defaults::kAlwaysOpenIncognitoWindow && | 144 if (browser_defaults::kAlwaysOpenIncognitoWindow && |
117 IncognitoModePrefs::ShouldLaunchIncognito( | 145 IncognitoModePrefs::ShouldLaunchIncognito( |
118 *CommandLine::ForCurrentProcess(), | 146 *CommandLine::ForCurrentProcess(), |
119 profile->GetPrefs())) { | 147 profile->GetPrefs())) { |
120 profile = profile->GetOffTheRecordProfile(); | 148 profile = profile->GetOffTheRecordProfile(); |
121 } | 149 } |
122 Browser::OpenEmptyWindow(profile); | 150 Browser::OpenEmptyWindow(profile); |
123 } | 151 } |
124 | 152 |
125 void ChromeShellDelegate::LauncherItemClicked( | 153 void ChromeShellDelegate::LauncherItemClicked( |
126 const ash::LauncherItem& item) { | 154 const ash::LauncherItem& item) { |
127 LauncherIconUpdater::ActivateByID(item.id); | 155 LauncherIconUpdater::ActivateByID(item.id); |
128 } | 156 } |
129 | 157 |
130 int ChromeShellDelegate::GetBrowserShortcutResourceId() { | 158 int ChromeShellDelegate::GetBrowserShortcutResourceId() { |
131 return IDR_PRODUCT_LOGO_32; | 159 return IDR_PRODUCT_LOGO_32; |
132 } | 160 } |
133 | 161 |
134 string16 ChromeShellDelegate::GetLauncherItemTitle( | 162 string16 ChromeShellDelegate::GetLauncherItemTitle( |
135 const ash::LauncherItem& item) { | 163 const ash::LauncherItem& item) { |
136 return LauncherIconUpdater::GetTitleByID(item.id); | 164 return LauncherIconUpdater::GetTitleByID(item.id); |
137 } | 165 } |
OLD | NEW |