diff options
author | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 06:01:48 +0000 |
---|---|---|
committer | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 06:01:48 +0000 |
commit | 867125a08f77a22b770f197d90519a8672af83aa (patch) | |
tree | 3d2ba6406f0932155b333af29bb2d9bff3e2d276 /chrome/browser/browser.h | |
parent | 44d64924960f793fd92f964d1e349216757c1856 (diff) | |
download | chromium_src-867125a08f77a22b770f197d90519a8672af83aa.zip chromium_src-867125a08f77a22b770f197d90519a8672af83aa.tar.gz chromium_src-867125a08f77a22b770f197d90519a8672af83aa.tar.bz2 |
Refactor the keyboard events handling code related to RenderViewHostDelegate::View and TabContentsDelegate interfaces.
Significant changes made by this CL:
1. The keyboard event handling code has been moved from TabContentsView implementation classes into BrowserWindow implementation classes.
Please refer to this discussion thread: http://groups.google.com/group/chromium-dev/browse_thread/thread/e6e0b5cc105659b7/9953c4308bb0000c
This change makes the keyboard event flow comply with the relationship between TabContents/TabContentsView and TabContentsDelegate/BrowserWindow.
Besides it, the code is also simplified a lot, for example, the keyboard event handling code in chrome/browser/views/tab_contents/tab_contents_view_{gtk,win}.cc are now merged into one copy and moved into chrome/browser/views/frame/browser_view.cc.
2. A pre-handle phrase has been added into the keyboard event handling flow. A keyboard event will be first sent to the browser for pre-handling before being sent to the renderer. Then if the event was not handled by the renderer, it'll be sent to the browser again for post-handling.
3. The keyboard accelerator handling code of Windows and Linux ports have been optimized to get rid off extra command lookup.
4. The keyboard event message flow between the browser and the renderer is changed back to full async mode, all complex logics introduced by revision 29857 are removed.
BUG=24479, 26054, 26131, 28839
TEST=See bug reports.
Review URL: http://codereview.chromium.org/400012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.h')
-rw-r--r-- | chrome/browser/browser.h | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 5192bf0..05fa0d8 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -468,6 +468,22 @@ class Browser : public TabStripModelDelegate, // Calls ExecuteCommandWithDisposition with the given disposition. void ExecuteCommandWithDisposition(int id, WindowOpenDisposition); + // Returns whether the |id| is a reserved command, whose keyboard shortcuts + // should not be sent to the renderer. + bool IsReservedCommand(int id); + + // Sets if command execution shall be blocked. If |block| is true then + // following calls to ExecuteCommand() or ExecuteCommandWithDisposition() + // method will not execute the command, and the last blocked command will be + // recorded for retrieval. + void SetBlockCommandExecution(bool block); + + // Gets the last blocked command after calling SetBlockCommandExecution(true). + // Returns the command id or -1 if there is no command blocked. The + // disposition type of the command will be stored in |*disposition| if it's + // not null. + int GetLastBlockedCommand(WindowOpenDisposition* disposition); + // Interface implementations //////////////////////////////////////////////// // Overridden from PageNavigator @@ -570,7 +586,9 @@ class Browser : public TabStripModelDelegate, const GURL& url, const NavigationEntry::SSLStatus& ssl, bool show_history); - virtual bool IsReservedAccelerator(const NativeWebKeyboardEvent& event); + virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, + bool* is_keyboard_shortcut); + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); virtual void ShowRepostFormWarningDialog(TabContents* tab_contents); virtual bool ShouldAddNavigationsToHistory() const; virtual void OnDidGetApplicationInfo(TabContents* tab_contents, @@ -824,6 +842,15 @@ class Browser : public TabStripModelDelegate, // Keep track of the encoding auto detect pref. BooleanPrefMember encoding_auto_detect_; + // Indicates if command execution is blocked. + bool block_command_execution_; + + // Stores the last blocked command id when |block_command_execution_| is true. + int last_blocked_command_id_; + + // Stores the disposition type of the last blocked command. + WindowOpenDisposition last_blocked_command_disposition_; + DISALLOW_COPY_AND_ASSIGN(Browser); }; |