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

Unified Diff: chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc

Issue 23606016: Refactor LauncherItemController and LauncherItemDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for unittest.. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
index 7c8df1eb01a320a9852062a724bd5f30c3279223..84128775261c9b74cb2003b9db5023b26a684b95 100644
--- a/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.cc
@@ -16,6 +16,8 @@
#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
+#include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h"
+#include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
@@ -96,10 +98,6 @@ void BrowserShortcutLauncherItemController::UpdateBrowserItemState() {
}
}
-string16 BrowserShortcutLauncherItemController::GetTitle() {
- return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
-}
-
bool BrowserShortcutLauncherItemController::IsCurrentlyShownInWindow(
aura::Window* window) const {
const BrowserList* ash_browser_list =
@@ -157,31 +155,6 @@ void BrowserShortcutLauncherItemController::Activate(ash::LaunchSource source) {
void BrowserShortcutLauncherItemController::Close() {
}
-void BrowserShortcutLauncherItemController::Clicked(const ui::Event& event) {
- #if defined(OS_CHROMEOS)
- chromeos::default_pinned_apps_field_trial::RecordShelfClick(
- chromeos::default_pinned_apps_field_trial::CHROME);
- #endif
-
- if (event.flags() & ui::EF_CONTROL_DOWN) {
- launcher_controller()->CreateNewWindow();
- return;
- }
-
- // In case of a keyboard event, we were called by a hotkey. In that case we
- // activate the next item in line if an item of our list is already active.
- if (event.type() & ui::ET_KEY_RELEASED) {
- ActivateOrAdvanceToNextBrowser();
- return;
- }
-
- Activate(ash::LAUNCH_FROM_UNKNOWN);
-}
-
-void BrowserShortcutLauncherItemController::OnRemoved() {
- // BrowserShortcutLauncherItemController is owned by ChromeLauncherController.
-}
-
ChromeLauncherAppMenuItems
BrowserShortcutLauncherItemController::GetApplicationList(int event_flags) {
ChromeLauncherAppMenuItems items;
@@ -234,6 +207,52 @@ BrowserShortcutLauncherItemController::GetApplicationList(int event_flags) {
return items.Pass();
}
+void BrowserShortcutLauncherItemController::ItemSelected(
+ const ui::Event& event) {
+#if defined(OS_CHROMEOS)
+ chromeos::default_pinned_apps_field_trial::RecordShelfClick(
+ chromeos::default_pinned_apps_field_trial::CHROME);
+#endif
+
+ if (event.flags() & ui::EF_CONTROL_DOWN) {
+ launcher_controller()->CreateNewWindow();
+ return;
+ }
+
+ // In case of a keyboard event, we were called by a hotkey. In that case we
+ // activate the next item in line if an item of our list is already active.
+ if (event.type() & ui::ET_KEY_RELEASED) {
+ ActivateOrAdvanceToNextBrowser();
+ return;
+ }
+
+ Activate(ash::LAUNCH_FROM_UNKNOWN);
+}
+
+string16 BrowserShortcutLauncherItemController::GetTitle() {
+ return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
+}
+
+ui::MenuModel* BrowserShortcutLauncherItemController::CreateContextMenu(
+ aura::RootWindow* root_window) {
+ ash::LauncherItem item =
+ *(launcher_controller()->model()->ItemByID(launcher_id()));
+ return new LauncherContextMenu(launcher_controller(), &item, root_window);
+}
+
+ash::LauncherMenuModel*
+BrowserShortcutLauncherItemController::CreateApplicationMenu(int event_flags) {
+ return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags));
+}
+
+bool BrowserShortcutLauncherItemController::IsDraggable() {
+ return launcher_controller()->CanPin() ? true : false;
+}
+
+bool BrowserShortcutLauncherItemController::ShouldShowTooltip() {
+ return true;
+}
+
gfx::Image BrowserShortcutLauncherItemController::GetBrowserListIcon(
content::WebContents* web_contents) const {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();

Powered by Google App Engine
This is Rietveld 408576698