blob: de5f483b33e8bb7a4d5dfc7959e5640eba69253c [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2012 The Chromium Authors
[email protected]a37d4b02012-06-25 21:56:102// 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]a37d4b02012-06-25 21:56:107
[email protected]2cd4fde2012-06-26 03:10:268#include <string>
David Jacobo5fe17122017-10-14 00:13:359#include <vector>
[email protected]2cd4fde2012-06-26 03:10:2610
Edwin Joe6f6fc1e2019-02-27 20:00:3711#include "base/time/time.h"
avi655876a2015-12-25 07:18:1512#include "build/build_config.h"
[email protected]70019152012-12-19 11:44:1913#include "chrome/browser/devtools/devtools_toggle_action.h"
Changhao Haneea68272020-11-12 13:30:4514#include "chrome/browser/devtools/devtools_window.h"
afakhryf4575bd2017-04-28 02:21:0415#include "chrome/browser/ui/chrome_pages.h"
[email protected]2bf6314b2013-02-20 03:51:1416#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
David Pennington3dbbfa5b2022-06-27 21:24:0017#include "chrome/browser/ui/tabs/tab_strip_user_gesture_details.h"
Ramin Halavati52a9a292022-04-28 04:27:4918#include "components/services/screen_ai/buildflags/buildflags.h"
[email protected]a37d4b02012-06-25 21:56:1019#include "content/public/common/page_zoom.h"
Scott Violet318a55f2018-03-30 19:08:1920#include "printing/buildflags/buildflags.h"
Anton Bikineev46bbb972021-05-15 17:53:5321#include "third_party/abseil-cpp/absl/types/optional.h"
[email protected]f47621b2013-01-22 20:50:3322#include "ui/base/window_open_disposition.h"
[email protected]a37d4b02012-06-25 21:56:1023
24class Browser;
[email protected]5d98294912012-06-27 22:57:4025class CommandObserver;
[email protected]a37d4b02012-06-25 21:56:1026class GURL;
27class Profile;
28
29namespace content {
30class WebContents;
[email protected]a37d4b02012-06-25 21:56:1031}
32
33namespace chrome {
34
[email protected]5d98294912012-06-27 22:57:4035// For all commands, where a tab is not specified, the active tab is assumed.
36
37bool IsCommandEnabled(Browser* browser, int command);
38bool SupportsCommand(Browser* browser, int command);
Edwin Joe6f6fc1e2019-02-27 20:00:3739bool ExecuteCommand(Browser* browser,
40 int command,
41 base::TimeTicks time_stamp = base::TimeTicks::Now());
[email protected]5d98294912012-06-27 22:57:4042bool ExecuteCommandWithDisposition(Browser* browser,
43 int command,
44 WindowOpenDisposition disposition);
45void UpdateCommandEnabled(Browser* browser, int command, bool enabled);
46void AddCommandObserver(Browser*, int command, CommandObserver* observer);
47void RemoveCommandObserver(Browser*, int command, CommandObserver* observer);
48
49int GetContentRestrictions(const Browser* browser);
50
Nancy Wangc19823d42021-08-19 03:28:3251// 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.
55void NewEmptyWindow(Profile* profile,
56 bool should_trigger_session_restore = true);
[email protected]a37d4b02012-06-25 21:56:1057
Nancy Wangc19823d42021-08-19 03:28:3258// 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]a37d4b02012-06-25 21:56:1062// various internal bookkeeping; NewEmptyWindow (above) is preferred.
Ramin Halavati3294f932021-01-31 18:20:0763// Returns nullptr if browser creation is not possible.
Nancy Wangc19823d42021-08-19 03:28:3264Browser* OpenEmptyWindow(Profile* profile,
65 bool should_trigger_session_restore = true);
[email protected]a37d4b02012-06-25 21:56:1066
67// Opens a new window with the tabs from |profile|'s TabRestoreService.
scottmgd161e6c2016-02-17 02:08:0168void OpenWindowWithRestoredTabs(Profile* profile);
[email protected]a37d4b02012-06-25 21:56:1069
scottmg851949002016-02-09 20:09:4470// 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.
73void OpenURLOffTheRecord(Profile* profile, const GURL& url);
[email protected]a37d4b02012-06-25 21:56:1074
[email protected]5d98294912012-06-27 22:57:4075bool CanGoBack(const Browser* browser);
[email protected]a37d4b02012-06-25 21:56:1076void GoBack(Browser* browser, WindowOpenDisposition disposition);
[email protected]5d98294912012-06-27 22:57:4077bool CanGoForward(const Browser* browser);
[email protected]a37d4b02012-06-25 21:56:1078void GoForward(Browser* browser, WindowOpenDisposition disposition);
Kevin McNee638e32ae2019-07-08 16:42:2079void NavigateToIndexWithDisposition(Browser* browser,
[email protected]a37d4b02012-06-25 21:56:1080 int index,
[email protected]26b3abb12014-03-20 21:00:3981 WindowOpenDisposition disposition);
[email protected]a37d4b02012-06-25 21:56:1082void Reload(Browser* browser, WindowOpenDisposition disposition);
toyoshim7dad4b1182016-04-01 14:28:0583void ReloadBypassingCache(Browser* browser, WindowOpenDisposition disposition);
[email protected]5d98294912012-06-27 22:57:4084bool CanReload(const Browser* browser);
[email protected]a37d4b02012-06-25 21:56:1085void Home(Browser* browser, WindowOpenDisposition disposition);
Alexander Timin66dab132021-09-23 14:36:04