window_open_disposition.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_BASE_WINDOW_OPEN_DISPOSITION_H_
  5. #define UI_BASE_WINDOW_OPEN_DISPOSITION_H_
  6. #include "base/component_export.h"
  7. enum class WindowOpenDisposition {
  8. UNKNOWN,
  9. CURRENT_TAB,
  10. // Indicates that only one tab with the url should exist in the same window.
  11. SINGLETON_TAB,
  12. NEW_FOREGROUND_TAB,
  13. NEW_BACKGROUND_TAB,
  14. NEW_POPUP,
  15. NEW_WINDOW,
  16. SAVE_TO_DISK,
  17. OFF_THE_RECORD,
  18. IGNORE_ACTION,
  19. // Activates an existing tab containing the url, rather than navigating.
  20. // This is similar to SINGLETON_TAB, but searches across all windows from
  21. // the current profile and anonymity (instead of just the current one);
  22. // closes the current tab on switching if the current tab was the NTP with
  23. // no session history; and behaves like CURRENT_TAB instead of
  24. // NEW_FOREGROUND_TAB when no existing tab is found.
  25. SWITCH_TO_TAB,
  26. // Creates a new document picture-in-picture window showing a child WebView.
  27. NEW_PICTURE_IN_PICTURE,
  28. // Update when adding a new disposition.
  29. MAX_VALUE = NEW_PICTURE_IN_PICTURE,
  30. };
  31. namespace ui {
  32. // Translates event flags from a click on a link into the user's desired window
  33. // disposition. For example, a middle click would mean to open a background
  34. // tab. |disposition_for_current_tab| is the disposition to return if the flags
  35. // suggest opening in the current tab; for example, a caller could set this to
  36. // NEW_FOREGROUND_TAB to prevent a click from overwriting the current tab by
  37. // default.
  38. COMPONENT_EXPORT(UI_BASE)
  39. WindowOpenDisposition DispositionFromClick(
  40. bool middle_button,
  41. bool alt_key,
  42. bool ctrl_key,
  43. bool meta_key,
  44. bool shift_key,
  45. WindowOpenDisposition disposition_for_current_tab =
  46. WindowOpenDisposition::CURRENT_TAB);
  47. // As with DispositionFromClick(), but using |event_flags| as in ui::MouseEvent.
  48. COMPONENT_EXPORT(UI_BASE)
  49. WindowOpenDisposition DispositionFromEventFlags(
  50. int event_flags,
  51. WindowOpenDisposition disposition_for_current_tab =
  52. WindowOpenDisposition::CURRENT_TAB);
  53. } // namespace ui
  54. #endif // UI_BASE_WINDOW_OPEN_DISPOSITION_H_