blob: 4ae492c02be896fe4680d20a76bca1ef465409cb [file] [log] [blame]
Scott Violetb11ad6a2022-09-23 22:41:021// Copyright 2022 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef UI_BASE_WINDOW_OPEN_DISPOSITION_UTILS_H_
6#define UI_BASE_WINDOW_OPEN_DISPOSITION_UTILS_H_
7
8#include "base/component_export.h"
9#include "ui/base/window_open_disposition.h"
10
11namespace ui {
12
13// Translates event flags from a click on a link into the user's desired window
14// disposition. For example, a middle click would mean to open a background
15// tab. |disposition_for_current_tab| is the disposition to return if the flags
16// suggest opening in the current tab; for example, a caller could set this to
17// NEW_FOREGROUND_TAB to prevent a click from overwriting the current tab by
18// default.
19COMPONENT_EXPORT(UI_BASE)
20WindowOpenDisposition DispositionFromClick(
21 bool middle_button,
22 bool alt_key,
23 bool ctrl_key,
24 bool meta_key,
25 bool shift_key,
26 WindowOpenDisposition disposition_for_current_tab =
27 WindowOpenDisposition::CURRENT_TAB);
28
29// As with DispositionFromClick(), but using |event_flags| as in ui::MouseEvent.
30COMPONENT_EXPORT(UI_BASE)
31WindowOpenDisposition DispositionFromEventFlags(
32 int event_flags,
33 WindowOpenDisposition disposition_for_current_tab =
34 WindowOpenDisposition::CURRENT_TAB);
35
36} // namespace ui
37
38#endif // UI_BASE_WINDOW_OPEN_DISPOSITION_UTILS_H_