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

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

Issue 2867673004: Use OnceCallback on Mojo interfaces in //ash (Closed)
Patch Set: count -> container_count 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/browser_shortcut_launcher_item_controll er.h" 5 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility>
8 #include <vector> 9 #include <vector>
9 10
10 #include "ash/public/cpp/window_properties.h" 11 #include "ash/public/cpp/window_properties.h"
11 #include "ash/resources/grit/ash_resources.h" 12 #include "ash/resources/grit/ash_resources.h"
12 #include "ash/shelf/shelf_model.h" 13 #include "ash/shelf/shelf_model.h"
13 #include "ash/wm_window.h" 14 #include "ash/wm_window.h"
14 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
15 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 18 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ash::kShelfIDKey, 177 ash::kShelfIDKey,
177 new ash::ShelfID( 178 new ash::ShelfID(
178 ChromeLauncherController::instance()->GetShelfIDForWebContents( 179 ChromeLauncherController::instance()->GetShelfIDForWebContents(
179 web_contents))); 180 web_contents)));
180 } 181 }
181 182
182 void BrowserShortcutLauncherItemController::ItemSelected( 183 void BrowserShortcutLauncherItemController::ItemSelected(
183 std::unique_ptr<ui::Event> event, 184 std::unique_ptr<ui::Event> event,
184 int64_t display_id, 185 int64_t display_id,
185 ash::ShelfLaunchSource source, 186 ash::ShelfLaunchSource source,
186 const ItemSelectedCallback& callback) { 187 ItemSelectedCallback callback) {
187 if (event && (event->flags() & ui::EF_CONTROL_DOWN)) { 188 if (event && (event->flags() & ui::EF_CONTROL_DOWN)) {
188 chrome::NewEmptyWindow(ChromeLauncherController::instance()->profile()); 189 chrome::NewEmptyWindow(ChromeLauncherController::instance()->profile());
189 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); 190 std::move(callback).Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED,
191 base::nullopt);
190 return; 192 return;
191 } 193 }
192 194
193 ash::MenuItemList items = 195 ash::MenuItemList items =
194 GetAppMenuItems(event ? event->flags() : ui::EF_NONE); 196 GetAppMenuItems(event ? event->flags() : ui::EF_NONE);
195 197
196 // In case of a keyboard event, we were called by a hotkey. In that case we 198 // In case of a keyboard event, we were called by a hotkey. In that case we
197 // activate the next item in line if an item of our list is already active. 199 // activate the next item in line if an item of our list is already active.
198 if (event && event->type() == ui::ET_KEY_RELEASED) { 200 if (event && event->type() == ui::ET_KEY_RELEASED) {
199 callback.Run(ActivateOrAdvanceToNextBrowser(), std::move(items)); 201 std::move(callback).Run(ActivateOrAdvanceToNextBrowser(), std::move(items));
200 return; 202 return;
201 } 203 }
202 204
203 Profile* profile = ChromeLauncherController::instance()->profile(); 205 Profile* profile = ChromeLauncherController::instance()->profile();
204 Browser* last_browser = chrome::FindTabbedBrowser(profile, true); 206 Browser* last_browser = chrome::FindTabbedBrowser(profile, true);
205 207
206 if (!last_browser) { 208 if (!last_browser) {
207 chrome::NewEmptyWindow(profile); 209 chrome::NewEmptyWindow(profile);
208 callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt); 210 std::move(callback).Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED,
211 base::nullopt);
209 return; 212 return;
210 } 213 }
211 214
212 ash::ShelfAction action = 215 ash::ShelfAction action =
213 ChromeLauncherController::instance()->ActivateWindowOrMinimizeIfActive( 216 ChromeLauncherController::instance()->ActivateWindowOrMinimizeIfActive(
214 last_browser->window(), items.size() == 1); 217 last_browser->window(), items.size() == 1);
215 callback.Run(action, std::move(items)); 218 std::move(callback).Run(action, std::move(items));
216 } 219 }
217 220
218 ash::MenuItemList BrowserShortcutLauncherItemController::GetAppMenuItems( 221 ash::MenuItemList BrowserShortcutLauncherItemController::GetAppMenuItems(
219 int event_flags) { 222 int event_flags) {
220 browser_menu_items_.clear(); 223 browser_menu_items_.clear();
221 registrar_.RemoveAll(); 224 registrar_.RemoveAll();
222 225
223 ash::MenuItemList items; 226 ash::MenuItemList items;
224 bool found_tabbed_browser = false; 227 bool found_tabbed_browser = false;
225 ChromeLauncherController* controller = ChromeLauncherController::instance(); 228 ChromeLauncherController* controller = ChromeLauncherController::instance();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 Browser* browser = content::Source<Browser>(source).ptr(); 401 Browser* browser = content::Source<Browser>(source).ptr();
399 DCHECK(browser); 402 DCHECK(browser);
400 BrowserList::BrowserVector::iterator item = std::find( 403 BrowserList::BrowserVector::iterator item = std::find(
401 browser_menu_items_.begin(), browser_menu_items_.end(), browser); 404 browser_menu_items_.begin(), browser_menu_items_.end(), browser);
402 DCHECK(item != browser_menu_items_.end()); 405 DCHECK(item != browser_menu_items_.end());
403 // Clear the entry for the closed browser and leave other indices intact. 406 // Clear the entry for the closed browser and leave other indices intact.
404 *item = nullptr; 407 *item = nullptr;
405 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSING, 408 registrar_.Remove(this, chrome::NOTIFICATION_BROWSER_CLOSING,
406 content::Source<Browser>(browser)); 409 content::Source<Browser>(browser));
407 } 410 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698