| 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/ash/launcher/chrome_launcher_delegate.h" | 5 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher_model.h" | 7 #include "ash/launcher/launcher_model.h" |
| 8 #include "ash/launcher/launcher_types.h" | 8 #include "ash/launcher/launcher_types.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/defaults.h" | 14 #include "chrome/browser/defaults.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 16 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/tabs/tab_strip_model.h" | 21 #include "chrome/browser/tabs/tab_strip_model.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_list.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/browser/ui/views/ash/launcher/launcher_app_icon_loader.h" | 26 #include "chrome/browser/ui/views/ash/launcher/launcher_app_icon_loader.h" |
| 26 #include "chrome/browser/ui/views/ash/launcher/launcher_context_menu.h" | 27 #include "chrome/browser/ui/views/ash/launcher/launcher_context_menu.h" |
| 27 #include "chrome/browser/ui/views/ash/launcher/launcher_updater.h" | 28 #include "chrome/browser/ui/views/ash/launcher/launcher_updater.h" |
| 28 #include "chrome/browser/web_applications/web_app.h" | 29 #include "chrome/browser/web_applications/web_app.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/extensions/extension.h" | 31 #include "chrome/common/extensions/extension.h" |
| 31 #include "chrome/common/extensions/extension_resource.h" | 32 #include "chrome/common/extensions/extension_resource.h" |
| 32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 void ChromeLauncherDelegate::UnpinAppsWithID(const std::string& app_id) { | 315 void ChromeLauncherDelegate::UnpinAppsWithID(const std::string& app_id) { |
| 315 for (IDToItemMap::iterator i = id_to_item_map_.begin(); | 316 for (IDToItemMap::iterator i = id_to_item_map_.begin(); |
| 316 i != id_to_item_map_.end(); ) { | 317 i != id_to_item_map_.end(); ) { |
| 317 IDToItemMap::iterator current(i); | 318 IDToItemMap::iterator current(i); |
| 318 ++i; | 319 ++i; |
| 319 if (current->second.app_id == app_id && IsPinned(current->first)) | 320 if (current->second.app_id == app_id && IsPinned(current->first)) |
| 320 Unpin(current->first); | 321 Unpin(current->first); |
| 321 } | 322 } |
| 322 } | 323 } |
| 323 | 324 |
| 324 void ChromeLauncherDelegate::CreateNewWindow() { | 325 void ChromeLauncherDelegate::CreateNewTab() { |
| 325 Browser::NewEmptyWindow(GetProfileForNewWindows()); | 326 Browser *last_browser = BrowserList::FindTabbedBrowser( |
| 327 GetProfileForNewWindows(), true); |
| 328 |
| 329 if (last_browser) { |
| 330 last_browser->NewTab(); |
| 331 aura::Window* window = last_browser->window()->GetNativeHandle(); |
| 332 window->Show(); |
| 333 ash::wm::ActivateWindow(window); |
| 334 } else { |
| 335 Browser::NewEmptyWindow(GetProfileForNewWindows()); |
| 336 } |
| 326 } | 337 } |
| 327 | 338 |
| 328 void ChromeLauncherDelegate::ItemClicked(const ash::LauncherItem& item) { | 339 void ChromeLauncherDelegate::ItemClicked(const ash::LauncherItem& item) { |
| 329 DCHECK(id_to_item_map_.find(item.id) != id_to_item_map_.end()); | 340 DCHECK(id_to_item_map_.find(item.id) != id_to_item_map_.end()); |
| 330 Open(item.id); | 341 Open(item.id); |
| 331 } | 342 } |
| 332 | 343 |
| 333 int ChromeLauncherDelegate::GetBrowserShortcutResourceId() { | 344 int ChromeLauncherDelegate::GetBrowserShortcutResourceId() { |
| 334 return IDR_PRODUCT_LOGO_32; | 345 return IDR_PRODUCT_LOGO_32; |
| 335 } | 346 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 449 } |
| 439 } | 450 } |
| 440 | 451 |
| 441 void ChromeLauncherDelegate::SetAppIconLoaderForTest(AppIconLoader* loader) { | 452 void ChromeLauncherDelegate::SetAppIconLoaderForTest(AppIconLoader* loader) { |
| 442 app_icon_loader_.reset(loader); | 453 app_icon_loader_.reset(loader); |
| 443 } | 454 } |
| 444 | 455 |
| 445 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() { | 456 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() { |
| 446 return ProfileManager::GetDefaultProfileOrOffTheRecord(); | 457 return ProfileManager::GetDefaultProfileOrOffTheRecord(); |
| 447 } | 458 } |
| OLD | NEW |