Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: chrome/browser/ui/views/aura/chrome_shell_delegate.cc

Issue 9297008: [HTerm-Crosh] Add key shortcut for opening Crosh on ChromeOS Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pass GURL to OpenNewTab Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/shell_url_constants.h"
8 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "chrome/browser/defaults.h" 11 #include "chrome/browser/defaults.h"
11 #include "chrome/browser/prefs/incognito_mode_prefs.h" 12 #include "chrome/browser/prefs/incognito_mode_prefs.h"
12 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.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_model_builder.h"
16 #include "chrome/browser/ui/views/aura/app_list/app_list_view_delegate.h" 17 #include "chrome/browser/ui/views/aura/app_list/app_list_view_delegate.h"
17 #include "chrome/browser/ui/views/aura/launcher_icon_updater.h" 18 #include "chrome/browser/ui/views/aura/launcher_icon_updater.h"
18 #include "chrome/browser/ui/views/aura/status_area_host_aura.h" 19 #include "chrome/browser/ui/views/aura/status_area_host_aura.h"
19 #include "chrome/browser/ui/views/frame/browser_view.h" 20 #include "chrome/browser/ui/views/frame/browser_view.h"
21 #include "content/public/browser/page_navigator.h"
22 #include "googleurl/src/gurl.h"
20 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
21 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
22 25
23 #if defined(OS_CHROMEOS) 26 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" 27 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
25 #include "chrome/browser/chromeos/dbus/power_manager_client.h" 28 #include "chrome/browser/chromeos/dbus/power_manager_client.h"
29 #include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
26 #endif 30 #endif
27 namespace { 31 namespace {
28 32
29 // Returns a list of Aura windows from a BrowserList, using either a 33 // Returns a list of Aura windows from a BrowserList, using either a
30 // const_iterator or const_reverse_iterator. 34 // const_iterator or const_reverse_iterator.
31 template<typename IT> 35 template<typename IT>
32 std::vector<aura::Window*> GetTabbedBrowserWindows(IT begin, IT end) { 36 std::vector<aura::Window*> GetTabbedBrowserWindows(IT begin, IT end) {
33 std::vector<aura::Window*> windows; 37 std::vector<aura::Window*> windows;
34 for (IT it = begin; it != end; ++it) { 38 for (IT it = begin; it != end; ++it) {
35 Browser* browser = *it; 39 Browser* browser = *it;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 windows = GetTabbedBrowserWindows(BrowserList::begin(), 108 windows = GetTabbedBrowserWindows(BrowserList::begin(),
105 BrowserList::end()); 109 BrowserList::end());
106 break; 110 break;
107 default: 111 default:
108 NOTREACHED(); 112 NOTREACHED();
109 break; 113 break;
110 } 114 }
111 return windows; 115 return windows;
112 } 116 }
113 117
118 void ChromeShellDelegate::OpenNewTab(const GURL& url) {
119 GURL new_tab_url = url;
120 Browser* browser = BrowserList::GetLastActive();
121
122 #if defined(OS_CHROMEOS)
123 if (url == GURL(ash::kAuraTerminalURL)) {
124 new_tab_url =
tbarzic 2012/01/30 22:57:18 have to fix spacing here..
125 TerminalExtensionHelper::GetCroshExtensionURL(browser->profile());
126 }
127 #endif
128
129 if (!new_tab_url.is_valid())
130 return;
131
132 browser->OpenURL(content::OpenURLParams(new_tab_url,
133 content::Referrer(),
134 NEW_FOREGROUND_TAB,
135 content::PAGE_TRANSITION_GENERATED,
136 false));
137 }
138
114 void ChromeShellDelegate::CreateNewWindow() { 139 void ChromeShellDelegate::CreateNewWindow() {
115 Profile* profile = ProfileManager::GetDefaultProfile(); 140 Profile* profile = ProfileManager::GetDefaultProfile();
116 if (browser_defaults::kAlwaysOpenIncognitoWindow && 141 if (browser_defaults::kAlwaysOpenIncognitoWindow &&
117 IncognitoModePrefs::ShouldLaunchIncognito( 142 IncognitoModePrefs::ShouldLaunchIncognito(
118 *CommandLine::ForCurrentProcess(), 143 *CommandLine::ForCurrentProcess(),
119 profile->GetPrefs())) { 144 profile->GetPrefs())) {
120 profile = profile->GetOffTheRecordProfile(); 145 profile = profile->GetOffTheRecordProfile();
121 } 146 }
122 Browser::OpenEmptyWindow(profile); 147 Browser::OpenEmptyWindow(profile);
123 } 148 }
124 149
125 void ChromeShellDelegate::LauncherItemClicked( 150 void ChromeShellDelegate::LauncherItemClicked(
126 const ash::LauncherItem& item) { 151 const ash::LauncherItem& item) {
127 LauncherIconUpdater::ActivateByID(item.id); 152 LauncherIconUpdater::ActivateByID(item.id);
128 } 153 }
129 154
130 int ChromeShellDelegate::GetBrowserShortcutResourceId() { 155 int ChromeShellDelegate::GetBrowserShortcutResourceId() {
131 return IDR_PRODUCT_LOGO_32; 156 return IDR_PRODUCT_LOGO_32;
132 } 157 }
133 158
134 string16 ChromeShellDelegate::GetLauncherItemTitle( 159 string16 ChromeShellDelegate::GetLauncherItemTitle(
135 const ash::LauncherItem& item) { 160 const ash::LauncherItem& item) {
136 return LauncherIconUpdater::GetTitleByID(item.id); 161 return LauncherIconUpdater::GetTitleByID(item.id);
137 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698