OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #include "chrome/common/chrome_switches.h" | 64 #include "chrome/common/chrome_switches.h" |
65 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 65 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
66 #include "chrome/common/pref_names.h" | 66 #include "chrome/common/pref_names.h" |
67 #include "chrome/common/url_constants.h" | 67 #include "chrome/common/url_constants.h" |
68 #include "content/public/browser/navigation_entry.h" | 68 #include "content/public/browser/navigation_entry.h" |
69 #include "content/public/browser/notification_registrar.h" | 69 #include "content/public/browser/notification_registrar.h" |
70 #include "content/public/browser/notification_service.h" | 70 #include "content/public/browser/notification_service.h" |
71 #include "content/public/browser/web_contents.h" | 71 #include "content/public/browser/web_contents.h" |
72 #include "extensions/browser/extension_prefs.h" | 72 #include "extensions/browser/extension_prefs.h" |
73 #include "extensions/browser/extension_system.h" | 73 #include "extensions/browser/extension_system.h" |
| 74 #include "extensions/browser/extension_util.h" |
74 #include "extensions/common/extension.h" | 75 #include "extensions/common/extension.h" |
75 #include "extensions/common/extension_resource.h" | 76 #include "extensions/common/extension_resource.h" |
76 #include "extensions/common/manifest_handlers/icons_handler.h" | 77 #include "extensions/common/manifest_handlers/icons_handler.h" |
77 #include "extensions/common/url_pattern.h" | 78 #include "extensions/common/url_pattern.h" |
78 #include "grit/ash_resources.h" | 79 #include "grit/ash_resources.h" |
79 #include "grit/chromium_strings.h" | 80 #include "grit/chromium_strings.h" |
80 #include "grit/generated_resources.h" | 81 #include "grit/generated_resources.h" |
81 #include "grit/theme_resources.h" | 82 #include "grit/theme_resources.h" |
82 #include "grit/ui_resources.h" | 83 #include "grit/ui_resources.h" |
83 #include "net/base/url_util.h" | 84 #include "net/base/url_util.h" |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 if (index == -1) | 573 if (index == -1) |
573 return false; | 574 return false; |
574 | 575 |
575 ash::ShelfItemType type = model_->items()[index].type; | 576 ash::ShelfItemType type = model_->items()[index].type; |
576 return ((type == ash::TYPE_APP_SHORTCUT || | 577 return ((type == ash::TYPE_APP_SHORTCUT || |
577 type == ash::TYPE_PLATFORM_APP || | 578 type == ash::TYPE_PLATFORM_APP || |
578 type == ash::TYPE_WINDOWED_APP) && | 579 type == ash::TYPE_WINDOWED_APP) && |
579 CanPin()); | 580 CanPin()); |
580 } | 581 } |
581 | 582 |
| 583 void ChromeLauncherController::Install(ash::ShelfID id) { |
| 584 if (!HasItemController(id)) |
| 585 return; |
| 586 |
| 587 std::string app_id = GetAppIDForShelfID(id); |
| 588 if (extensions::util::IsExtensionInstalledPermanently(app_id, profile_)) |
| 589 return; |
| 590 |
| 591 LauncherItemController* controller = id_to_item_controller_map_[id]; |
| 592 if (controller->type() == LauncherItemController::TYPE_APP) { |
| 593 AppWindowLauncherItemController* app_window_controller = |
| 594 static_cast<AppWindowLauncherItemController*>(controller); |
| 595 app_window_controller->InstallApp(); |
| 596 } |
| 597 } |
| 598 |
| 599 bool ChromeLauncherController::CanInstall(ash::ShelfID id) { |
| 600 int index = model_->ItemIndexByID(id); |
| 601 if (index == -1) |
| 602 return false; |
| 603 |
| 604 ash::ShelfItemType type = model_->items()[index].type; |
| 605 if (type != ash::TYPE_PLATFORM_APP) |
| 606 return false; |
| 607 |
| 608 return extensions::util::IsEphemeralApp(GetAppIDForShelfID(id), profile_); |
| 609 } |
| 610 |
582 void ChromeLauncherController::LockV1AppWithID( | 611 void ChromeLauncherController::LockV1AppWithID( |
583 const std::string& app_id) { | 612 const std::string& app_id) { |
584 ash::ShelfID id = GetShelfIDForAppID(app_id); | 613 ash::ShelfID id = GetShelfIDForAppID(app_id); |
585 if (!IsPinned(id) && !IsWindowedAppInLauncher(app_id)) { | 614 if (!IsPinned(id) && !IsWindowedAppInLauncher(app_id)) { |
586 CreateAppShortcutLauncherItemWithType(app_id, | 615 CreateAppShortcutLauncherItemWithType(app_id, |
587 model_->item_count(), | 616 model_->item_count(), |
588 ash::TYPE_WINDOWED_APP); | 617 ash::TYPE_WINDOWED_APP); |
589 id = GetShelfIDForAppID(app_id); | 618 id = GetShelfIDForAppID(app_id); |
590 } | 619 } |
591 CHECK(id); | 620 CHECK(id); |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2005 } | 2034 } |
2006 | 2035 |
2007 void ChromeLauncherController::ReleaseProfile() { | 2036 void ChromeLauncherController::ReleaseProfile() { |
2008 if (app_sync_ui_state_) | 2037 if (app_sync_ui_state_) |
2009 app_sync_ui_state_->RemoveObserver(this); | 2038 app_sync_ui_state_->RemoveObserver(this); |
2010 | 2039 |
2011 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); | 2040 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
2012 | 2041 |
2013 pref_change_registrar_.RemoveAll(); | 2042 pref_change_registrar_.RemoveAll(); |
2014 } | 2043 } |
OLD | NEW |