Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 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 CHROME_BROWSER_UI_BROWSER_COMMANDS_H_ |
| 6 | #define CHROME_BROWSER_UI_BROWSER_COMMANDS_H_ |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 7 | |
[email protected] | 2cd4fde | 2012-06-26 03:10:26 | [diff] [blame] | 8 | #include <string> |
David Jacobo | 5fe1712 | 2017-10-14 00:13:35 | [diff] [blame] | 9 | #include <vector> |
[email protected] | 2cd4fde | 2012-06-26 03:10:26 | [diff] [blame] | 10 | |
Edwin Joe | 6f6fc1e | 2019-02-27 20:00:37 | [diff] [blame] | 11 | #include "base/time/time.h" |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 12 | #include "build/build_config.h" |
[email protected] | 7001915 | 2012-12-19 11:44:19 | [diff] [blame] | 13 | #include "chrome/browser/devtools/devtools_toggle_action.h" |
Changhao Han | eea6827 | 2020-11-12 13:30:45 | [diff] [blame] | 14 | #include "chrome/browser/devtools/devtools_window.h" |
afakhry | f4575bd | 2017-04-28 02:21:04 | [diff] [blame] | 15 | #include "chrome/browser/ui/chrome_pages.h" |
[email protected] | 2bf6314b | 2013-02-20 03:51:14 | [diff] [blame] | 16 | #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
David Pennington | 3dbbfa5b | 2022-06-27 21:24:00 | [diff] [blame] | 17 | #include "chrome/browser/ui/tabs/tab_strip_user_gesture_details.h" |
Ramin Halavati | 52a9a29 | 2022-04-28 04:27:49 | [diff] [blame] | 18 | #include "components/services/screen_ai/buildflags/buildflags.h" |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 19 | #include "content/public/common/page_zoom.h" |
Scott Violet | 318a55f | 2018-03-30 19:08:19 | [diff] [blame] | 20 | #include "printing/buildflags/buildflags.h" |
Anton Bikineev | 46bbb97 | 2021-05-15 17:53:53 | [diff] [blame] | 21 | #include "third_party/abseil-cpp/absl/types/optional.h" |
[email protected] | f47621b | 2013-01-22 20:50:33 | [diff] [blame] | 22 | #include "ui/base/window_open_disposition.h" |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 23 | |
| 24 | class Browser; |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 25 | class CommandObserver; |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 26 | class GURL; |
| 27 | class Profile; |
| 28 | |
| 29 | namespace content { |
| 30 | class WebContents; |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | namespace chrome { |
| 34 | |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 35 | // For all commands, where a tab is not specified, the active tab is assumed. |
| 36 | |
| 37 | bool IsCommandEnabled(Browser* browser, int command); |
| 38 | bool SupportsCommand(Browser* browser, int command); |
Edwin Joe | 6f6fc1e | 2019-02-27 20:00:37 | [diff] [blame] | 39 | bool ExecuteCommand(Browser* browser, |
| 40 | int command, |
| 41 | base::TimeTicks time_stamp = base::TimeTicks::Now()); |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 42 | bool ExecuteCommandWithDisposition(Browser* browser, |
| 43 | int command, |
| 44 | WindowOpenDisposition disposition); |
| 45 | void UpdateCommandEnabled(Browser* browser, int command, bool enabled); |
| 46 | void AddCommandObserver(Browser*, int command, CommandObserver* observer); |
| 47 | void RemoveCommandObserver(Browser*, int command, CommandObserver* observer); |
| 48 | |
| 49 | int GetContentRestrictions(const Browser* browser); |
| 50 | |
Nancy Wang | c19823d4 | 2021-08-19 03:28:32 | [diff] [blame] | 51 | // Opens a new window. If the |should_trigger_session_restore| is true, a new |
| 52 | // window opening should be treated like the start of a session (with potential |
| 53 | // session restore, startup URLs, etc.). Otherwise, don't restore the session, |
| 54 | // opens a new window with the default blank tab. |
| 55 | void NewEmptyWindow(Profile* profile, |
| 56 | bool should_trigger_session_restore = true); |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 57 | |
Nancy Wang | c19823d4 | 2021-08-19 03:28:32 | [diff] [blame] | 58 | // Opens a new window. If the |should_trigger_session_restore| is true, a new |
| 59 | // window opening should be treated like the start of a session (with potential |
| 60 | // session restore, startup URLs, etc.). Otherwise, don't restore the session, |
| 61 | // opens a new window with the default blank tab. This bypasses metrics and |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 62 | // various internal bookkeeping; NewEmptyWindow (above) is preferred. |
Ramin Halavati | 3294f93 | 2021-01-31 18:20:07 | [diff] [blame] | 63 | // Returns nullptr if browser creation is not possible. |
Nancy Wang | c19823d4 | 2021-08-19 03:28:32 | [diff] [blame] | 64 | Browser* OpenEmptyWindow(Profile* profile, |
| 65 | bool should_trigger_session_restore = true); |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 66 | |
| 67 | // Opens a new window with the tabs from |profile|'s TabRestoreService. |
scottmg | d161e6c | 2016-02-17 02:08:01 | [diff] [blame] | 68 | void OpenWindowWithRestoredTabs(Profile* profile); |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 69 | |
scottmg | 85194900 | 2016-02-09 20:09:44 | [diff] [blame] | 70 | // Opens the specified URL in a new browser window in an incognito session. If |
| 71 | // there is already an existing active incognito session for the specified |
| 72 | // |profile|, that session is re- used. |
| 73 | void OpenURLOffTheRecord(Profile* profile, const GURL& url); |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 74 | |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 75 | bool CanGoBack(const Browser* browser); |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 76 | void GoBack(Browser* browser, WindowOpenDisposition disposition); |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 77 | bool CanGoForward(const Browser* browser); |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 78 | void GoForward(Browser* browser, WindowOpenDisposition disposition); |
Kevin McNee | 638e32ae | 2019-07-08 16:42:20 | [diff] [blame] | 79 | void NavigateToIndexWithDisposition(Browser* browser, |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 80 | int index, |
[email protected] | 26b3abb1 | 2014-03-20 21:00:39 | [diff] [blame] | 81 | WindowOpenDisposition disposition); |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 82 | void Reload(Browser* browser, WindowOpenDisposition disposition); |
toyoshim | 7dad4b118 | 2016-04-01 14:28:05 | [diff] [blame] | 83 | void ReloadBypassingCache(Browser* browser, WindowOpenDisposition disposition); |
[email protected] | 5d9829491 | 2012-06-27 22:57:40 | [diff] [blame] | 84 | bool CanReload(const Browser* browser); |
[email protected] | a37d4b0 | 2012-06-25 21:56:10 | [diff] [blame] | 85 | void Home(Browser* browser, WindowOpenDisposition disposition); |
Alexander Timin | 66dab13 | 2021-09-23 14:36:04 | [diff] [blame] |
|