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

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

Issue 2894743002: Make launching apps from shelf more intuitive (Closed)
Patch Set: This patch set has many platform related issue Created 3 years, 7 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
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/app_shortcut_launcher_item_controller.h " 5 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "ash/root_window_controller.h"
12 #include "ash/shell.h"
11 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
12 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
13 #include "chrome/browser/extensions/launch_util.h" 15 #include "chrome/browser/extensions/launch_util.h"
14 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 16 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
15 #include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_co ntroller.h" 17 #include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_co ntroller.h"
16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 18 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" 19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
18 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" 20 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
19 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 21 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
20 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 22 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // which take a lot of time for pre-processing (like the files app) before 109 // which take a lot of time for pre-processing (like the files app) before
108 // they open a window. Since there is currently no other way to detect if an 110 // they open a window. Since there is currently no other way to detect if an
109 // app was started we suppress any further clicks within a special time out. 111 // app was started we suppress any further clicks within a special time out.
110 if (IsV2App() && !AllowNextLaunchAttempt()) { 112 if (IsV2App() && !AllowNextLaunchAttempt()) {
111 std::move(callback).Run( 113 std::move(callback).Run(
112 ash::SHELF_ACTION_NONE, 114 ash::SHELF_ACTION_NONE,
113 GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); 115 GetAppMenuItems(event ? event->flags() : ui::EF_NONE));
114 return; 116 return;
115 } 117 }
116 118
119 aura::Window* root_window =
120 ash::Shell::Get()
121 ->GetRootWindowControllerWithDisplayId(display_id)
122 ->GetRootWindow();
123
117 // Launching some items replaces this item controller instance, which 124 // Launching some items replaces this item controller instance, which
118 // destroys its ShelfID string pair; making copies avoid crashes. 125 // destroys its ShelfID string pair; making copies avoid crashes.
119 ChromeLauncherController::instance()->LaunchApp(ash::ShelfID(shelf_id()), 126 ChromeLauncherController::instance()->LaunchApp(
120 source, ui::EF_NONE); 127 ash::ShelfID(shelf_id()), source, ui::EF_NONE, root_window);
121 std::move(callback).Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, 128 std::move(callback).Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED,
122 base::nullopt); 129 base::nullopt);
123 return; 130 return;
124 } 131 }
125 132
126 const ash::ShelfAction action = ActivateContent(content); 133 const ash::ShelfAction action = ActivateContent(content);
127 std::move(callback).Run( 134 std::move(callback).Run(
128 action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE)); 135 action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE));
129 } 136 }
130 137
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 370
364 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() { 371 bool AppShortcutLauncherItemController::AllowNextLaunchAttempt() {
365 if (last_launch_attempt_.is_null() || 372 if (last_launch_attempt_.is_null() ||
366 last_launch_attempt_ + base::TimeDelta::FromMilliseconds( 373 last_launch_attempt_ + base::TimeDelta::FromMilliseconds(
367 kClickSuppressionInMS) < base::Time::Now()) { 374 kClickSuppressionInMS) < base::Time::Now()) {
368 last_launch_attempt_ = base::Time::Now(); 375 last_launch_attempt_ = base::Time::Now();
369 return true; 376 return true;
370 } 377 }
371 return false; 378 return false;
372 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698