1 // Copyright (c) 2012 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 5 #ifndef CHROME_BROWSER_UI_BROWSER_COMMANDS_H_ 6 #define CHROME_BROWSER_UI_BROWSER_COMMANDS_H_ 7 8 #include <string> 9 10 #include "chrome/browser/devtools/devtools_toggle_action.h" 11 #include "chrome/browser/ui/host_desktop.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 13 #include "content/public/common/page_zoom.h" 14 #include "ui/base/window_open_disposition.h" 15 16 class Browser; 17 class CommandObserver; 18 class GURL; 19 class Profile; 20 21 namespace content { 22 class PageState; 23 class WebContents; 24 struct SSLStatus; 25 } 26 27 namespace chrome { 28 29 // For all commands, where a tab is not specified, the active tab is assumed. 30 31 bool IsCommandEnabled(Browser* browser, int command); 32 bool SupportsCommand(Browser* browser, int command); 33 bool ExecuteCommand(Browser* browser, int command); 34 bool ExecuteCommandWithDisposition(Browser* browser, 35 int command, 36 WindowOpenDisposition disposition); 37 void UpdateCommandEnabled(Browser* browser, int command, bool enabled); 38 void AddCommandObserver(Browser*, int command, CommandObserver* observer); 39 void RemoveCommandObserver(Browser*, int command, CommandObserver* observer); 40 41 int GetContentRestrictions(const Browser* browser); 42 43 // Opens a new window with the default blank tab. 44 void NewEmptyWindow(Profile* profile, HostDesktopType desktop_type); 45 46 // Opens a new window with the default blank tab. This bypasses metrics and 47 // various internal bookkeeping; NewEmptyWindow (above) is preferred. 48 Browser* OpenEmptyWindow(Profile* profile, HostDesktopType desktop_type); 49 50 // Opens a new window with the tabs from |profile|'s TabRestoreService. 51 void OpenWindowWithRestoredTabs(Profile* profile, 52 HostDesktopType host_desktop_type); 53 54 // Opens the specified URL in a new browser window in an incognito session on 55 // the desktop specified by |desktop_type|. If there is already an existing 56 // active incognito session for the specified |profile|, that session is re- 57 // used. 58 void OpenURLOffTheRecord(Profile* profile, const GURL& url, 59 chrome::HostDesktopType desktop_type); 60 61 bool CanGoBack(const Browser* browser); 62 void GoBack(Browser* browser, WindowOpenDisposition disposition); 63 bool CanGoForward(const Browser* browser); 64 void GoForward(Browser* browser, WindowOpenDisposition disposition); 65 bool NavigateToIndexWithDisposition(Browser* browser, 66 int index, 67 WindowOpenDisposition disposition); 68 void Reload(Browser* browser, WindowOpenDisposition disposition); 69 void ReloadIgnoringCache(Browser* browser, WindowOpenDisposition disposition); 70 bool CanReload(const Browser* browser); 71 void Home(Browser* browser, WindowOpenDisposition disposition); 72 void OpenCurrentURL(Browser* browser); 73 void Stop(Browser* browser); 74 void NewWindow(Browser* browser); 75 void NewIncognitoWindow(Browser* browser); 76 void CloseWindow(Browser* browser); 77 void NewTab(Browser* browser); 78 void CloseTab(Browser* browser); 79 bool CanZoomIn(content::WebContents* contents); 80 bool CanZoomOut(content::WebContents* contents); 81 bool ActualSize(content::WebContents* contents); 82 void RestoreTab(Browser* browser); 83 TabStripModelDelegate::RestoreTabType GetRestoreTabType( 84 const Browser* browser); 85 void SelectNextTab(Browser* browser); 86 void SelectPreviousTab(Browser* browser); 87 void MoveTabNext(Browser* browser); 88 void MoveTabPrevious(Browser* browser); 89 void SelectNumberedTab(Browser* browser, int index); 90 void SelectLastTab(Browser* browser); 91 void DuplicateTab(Browser* browser); 92 bool CanDuplicateTab(const Browser* browser); 93 content::WebContents* DuplicateTabAt(Browser* browser, int index); 94 bool CanDuplicateTabAt(Browser* browser, int index); 95 void ConvertPopupToTabbedBrowser(Browser* browser); 96 void Exit(); 97 void BookmarkCurrentPage(Browser* browser); 98 bool CanBookmarkCurrentPage(const Browser* browser); 99 void BookmarkAllTabs(Browser* browser); 100 bool CanBookmarkAllTabs(const Browser* browser); 101 void Translate(Browser* browser); 102 void ManagePasswordsForPage(Browser* browser); 103 void TogglePagePinnedToStartScreen(Browser* browser); 104 void SavePage(Browser* browser); 105 bool CanSavePage(const Browser* browser); 106 void ShowFindBar(Browser* browser); 107 void ShowWebsiteSettings(Browser* browser, 108 content::WebContents* web_contents, 109 const GURL& url, 110 const content::SSLStatus& ssl); 111 void Print(Browser* browser); 112 bool CanPrint(Browser* browser); 113 #if !defined(DISABLE_BASIC_PRINTING) 114 void BasicPrint(Browser* browser); 115 bool CanBasicPrint(Browser* browser); 116 #endif // !DISABLE_BASIC_PRINTING 117 void EmailPageLocation(Browser* browser); 118 bool CanEmailPageLocation(const Browser* browser); 119 void Cut(Browser* browser); 120 void Copy(Browser* browser); 121 void Paste(Browser* browser); 122 void Find(Browser* browser); 123 void FindNext(Browser* browser); 124 void FindPrevious(Browser* browser); 125 void FindInPage(Browser* browser, bool find_next, bool forward_direction); 126 void Zoom(Browser* browser, content::PageZoom zoom); 127 void FocusToolbar(Browser* browser); 128 void FocusLocationBar(Browser* browser); 129 void FocusSearch(Browser* browser); 130 void FocusAppMenu(Browser* browser); 131 void FocusBookmarksToolbar(Browser* browser); 132 void FocusInfobars(Browser* browser); 133 void FocusNextPane(Browser* browser); 134 void FocusPreviousPane(Browser* browser); 135 void ToggleDevToolsWindow(Browser* browser, DevToolsToggleAction action); 136 bool CanOpenTaskManager(); 137 void OpenTaskManager(Browser* browser); 138 void OpenFeedbackDialog(Browser* browser); 139 void ToggleBookmarkBar(Browser* browser); 140 void ShowAppMenu(Browser* browser); 141 void ShowAvatarMenu(Browser* browser); 142 void OpenUpdateChromeDialog(Browser* browser); 143 void ToggleSpeechInput(Browser* browser); 144 void DistillCurrentPage(Browser* browser); 145 bool CanRequestTabletSite(content::WebContents* current_tab); 146 bool IsRequestingTabletSite(Browser* browser); 147 void ToggleRequestTabletSite(Browser* browser); 148 void ToggleFullscreenMode(Browser* browser); 149 void ClearCache(Browser* browser); 150 bool IsDebuggerAttachedToCurrentTab(Browser* browser); 151 152 // Opens a view-source tab for a given web contents. 153 void ViewSource(Browser* browser, content::WebContents* tab); 154 155 // Opens a view-source tab for any frame within a given web contents. 156 void ViewSource(Browser* browser, 157 content::WebContents* tab, 158 const GURL& url, 159 const content::PageState& page_state); 160 161 void ViewSelectedSource(Browser* browser); 162 bool CanViewSource(const Browser* browser); 163 164 void CreateApplicationShortcuts(Browser* browser); 165 void CreateBookmarkAppFromCurrentWebContents(Browser* browser); 166 bool CanCreateApplicationShortcuts(const Browser* browser); 167 bool CanCreateBookmarkApp(const Browser* browser); 168 169 void ConvertTabToAppWindow(Browser* browser, content::WebContents* contents); 170 171 } // namespace chrome 172 173 #endif // CHROME_BROWSER_UI_BROWSER_COMMANDS_H_ 174