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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: response to sky Created 8 years 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
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/ash/launcher/chrome_launcher_controller.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
12 #include "base/command_line.h" 12 #include "base/command_line.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/extensions/extension_system.h"
16 #include "chrome/browser/prefs/incognito_mode_prefs.h" 17 #include "chrome/browser/prefs/incognito_mode_prefs.h"
17 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/prefs/scoped_user_pref_update.h" 19 #include "chrome/browser/prefs/scoped_user_pref_update.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/ui/ash/app_sync_ui_state.h" 22 #include "chrome/browser/ui/ash/app_sync_ui_state.h"
22 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 23 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
23 #include "chrome/browser/ui/ash/extension_utils.h" 24 #include "chrome/browser/ui/ash/extension_utils.h"
24 #include "chrome/browser/ui/ash/launcher/launcher_app_icon_loader.h" 25 #include "chrome/browser/ui/ash/launcher/launcher_app_icon_loader.h"
25 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h" 26 #include "chrome/browser/ui/ash/launcher/launcher_app_tab_helper.h"
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 447
447 LaunchApp(app_id, event_flags); 448 LaunchApp(app_id, event_flags);
448 } 449 }
449 450
450 extensions::ExtensionPrefs::LaunchType ChromeLauncherController::GetLaunchType( 451 extensions::ExtensionPrefs::LaunchType ChromeLauncherController::GetLaunchType(
451 ash::LauncherID id) { 452 ash::LauncherID id) {
452 DCHECK(HasItemController(id)); 453 DCHECK(HasItemController(id));
453 454
454 const Extension* extension = GetExtensionForAppID( 455 const Extension* extension = GetExtensionForAppID(
455 id_to_item_controller_map_[id]->app_id()); 456 id_to_item_controller_map_[id]->app_id());
456 return profile_->GetExtensionService()->extension_prefs()->GetLaunchType( 457 return extensions::ExtensionSystem::Get(profile_)->extension_service()->
457 extension, 458 extension_prefs()->GetLaunchType(extension,
458 extensions::ExtensionPrefs::LAUNCH_DEFAULT); 459 extensions::ExtensionPrefs::LAUNCH_DEFAULT);
Yoyo Zhou 2012/11/21 00:27:13 nit: indent
Miranda Callahan 2012/11/26 22:14:24 Done.
459 } 460 }
460 461
461 std::string ChromeLauncherController::GetAppID(TabContents* tab) { 462 std::string ChromeLauncherController::GetAppID(TabContents* tab) {
462 return app_tab_helper_->GetAppID(tab); 463 return app_tab_helper_->GetAppID(tab);
463 } 464 }
464 465
465 ash::LauncherID ChromeLauncherController::GetLauncherIDForAppID( 466 ash::LauncherID ChromeLauncherController::GetLauncherIDForAppID(
466 const std::string& app_id) { 467 const std::string& app_id) {
467 for (IDToItemControllerMap::const_iterator i = 468 for (IDToItemControllerMap::const_iterator i =
468 id_to_item_controller_map_.begin(); 469 id_to_item_controller_map_.begin();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 else 521 else
521 NOTREACHED(); 522 NOTREACHED();
522 } 523 }
523 524
524 void ChromeLauncherController::SetLaunchType( 525 void ChromeLauncherController::SetLaunchType(
525 ash::LauncherID id, 526 ash::LauncherID id,
526 extensions::ExtensionPrefs::LaunchType launch_type) { 527 extensions::ExtensionPrefs::LaunchType launch_type) {
527 if (!HasItemController(id)) 528 if (!HasItemController(id))
528 return; 529 return;
529 530
530 return profile_->GetExtensionService()->extension_prefs()->SetLaunchType( 531 return extensions::ExtensionSystem::Get(profile_)->extension_service()->
531 id_to_item_controller_map_[id]->app_id(), launch_type); 532 extension_prefs()->SetLaunchType(id_to_item_controller_map_[id]->app_id(),
533 launch_type);
532 } 534 }
533 535
534 void ChromeLauncherController::UnpinAppsWithID(const std::string& app_id) { 536 void ChromeLauncherController::UnpinAppsWithID(const std::string& app_id) {
535 if (CanPin()) 537 if (CanPin())
536 DoUnpinAppsWithID(app_id); 538 DoUnpinAppsWithID(app_id);
537 else 539 else
538 NOTREACHED(); 540 NOTREACHED();
539 } 541 }
540 542
541 bool ChromeLauncherController::IsLoggedInAsGuest() { 543 bool ChromeLauncherController::IsLoggedInAsGuest() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 AppShortcutLauncherItemController* app_controller = 666 AppShortcutLauncherItemController* app_controller =
665 static_cast<AppShortcutLauncherItemController*>(controller); 667 static_cast<AppShortcutLauncherItemController*>(controller);
666 app_controller->set_refocus_url(url); 668 app_controller->set_refocus_url(url);
667 } else { 669 } else {
668 NOTREACHED() << "Invalid launcher type"; 670 NOTREACHED() << "Invalid launcher type";
669 } 671 }
670 } 672 }
671 673
672 const Extension* ChromeLauncherController::GetExtensionForAppID( 674 const Extension* ChromeLauncherController::GetExtensionForAppID(
673 const std::string& app_id) { 675 const std::string& app_id) {
674 return profile_->GetExtensionService()->GetInstalledExtension(app_id); 676 return extensions::ExtensionSystem::Get(profile_)->extension_service()->
677 GetInstalledExtension(app_id);
675 } 678 }
676 679
677 void ChromeLauncherController::OnBrowserShortcutClicked(int event_flags) { 680 void ChromeLauncherController::OnBrowserShortcutClicked(int event_flags) {
678 if (event_flags & ui::EF_CONTROL_DOWN) { 681 if (event_flags & ui::EF_CONTROL_DOWN) {
679 CreateNewWindow(); 682 CreateNewWindow();
680 return; 683 return;
681 } 684 }
682 685
683 Browser* last_browser = browser::FindTabbedBrowser( 686 Browser* last_browser = browser::FindTabbedBrowser(
684 GetProfileForNewWindows(), true, chrome::HOST_DESKTOP_TYPE_ASH); 687 GetProfileForNewWindows(), true, chrome::HOST_DESKTOP_TYPE_ASH);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 new AppShortcutLauncherItemController(app_id, this); 1076 new AppShortcutLauncherItemController(app_id, this);
1074 ash::LauncherID launcher_id = InsertAppLauncherItem( 1077 ash::LauncherID launcher_id = InsertAppLauncherItem(
1075 controller, app_id, ash::STATUS_CLOSED, index); 1078 controller, app_id, ash::STATUS_CLOSED, index);
1076 return launcher_id; 1079 return launcher_id;
1077 } 1080 }
1078 1081
1079 bool ChromeLauncherController::HasItemController(ash::LauncherID id) const { 1082 bool ChromeLauncherController::HasItemController(ash::LauncherID id) const {
1080 return id_to_item_controller_map_.find(id) != 1083 return id_to_item_controller_map_.find(id) !=
1081 id_to_item_controller_map_.end(); 1084 id_to_item_controller_map_.end();
1082 } 1085 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698