| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_ | 5 #ifndef CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_ |
| 6 #define CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_ | 6 #define CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/download/test_download_shelf.h" | 11 #include "chrome/browser/download/test_download_shelf.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/location_bar/location_bar.h" | 14 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 15 | 15 |
| 16 class LocationBarTesting; | 16 class LocationBarTesting; |
| 17 class OmniboxView; | 17 class OmniboxView; |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 class Extension; | 20 class Extension; |
| 21 } | 21 } |
| 22 | 22 |
| 23 // An implementation of BrowserWindow used for testing. TestBrowserWindow only | 23 // An implementation of BrowserWindow used for testing. TestBrowserWindow only |
| 24 // contains a valid LocationBar, all other getters return NULL. | 24 // contains a valid LocationBar, all other getters return NULL. |
| 25 // See BrowserWithTestWindowTest for an example of using this class. | 25 // See BrowserWithTestWindowTest for an example of using this class. |
| 26 class TestBrowserWindow : public BrowserWindow { | 26 class TestBrowserWindow : public BrowserWindow { |
| 27 public: | 27 public: |
| 28 TestBrowserWindow(); | 28 TestBrowserWindow(); |
| 29 virtual ~TestBrowserWindow(); | 29 ~TestBrowserWindow() override; |
| 30 | 30 |
| 31 // BrowserWindow: | 31 // BrowserWindow: |
| 32 virtual void Show() override {} | 32 void Show() override {} |
| 33 virtual void ShowInactive() override {} | 33 void ShowInactive() override {} |
| 34 virtual void Hide() override {} | 34 void Hide() override {} |
| 35 virtual void SetBounds(const gfx::Rect& bounds) override {} | 35 void SetBounds(const gfx::Rect& bounds) override {} |
| 36 virtual void Close() override {} | 36 void Close() override {} |
| 37 virtual void Activate() override {} | 37 void Activate() override {} |
| 38 virtual void Deactivate() override {} | 38 void Deactivate() override {} |
| 39 virtual bool IsActive() const override; | 39 bool IsActive() const override; |
| 40 virtual void FlashFrame(bool flash) override {} | 40 void FlashFrame(bool flash) override {} |
| 41 virtual bool IsAlwaysOnTop() const override; | 41 bool IsAlwaysOnTop() const override; |
| 42 virtual void SetAlwaysOnTop(bool always_on_top) override {} | 42 void SetAlwaysOnTop(bool always_on_top) override {} |
| 43 virtual gfx::NativeWindow GetNativeWindow() override; | 43 gfx::NativeWindow GetNativeWindow() override; |
| 44 virtual BrowserWindowTesting* GetBrowserWindowTesting() override; | 44 BrowserWindowTesting* GetBrowserWindowTesting() override; |
| 45 virtual StatusBubble* GetStatusBubble() override; | 45 StatusBubble* GetStatusBubble() override; |
| 46 virtual void UpdateTitleBar() override {} | 46 void UpdateTitleBar() override {} |
| 47 virtual void BookmarkBarStateChanged( | 47 void BookmarkBarStateChanged( |
| 48 BookmarkBar::AnimateChangeType change_type) override {} | 48 BookmarkBar::AnimateChangeType change_type) override {} |
| 49 virtual void UpdateDevTools() override {} | 49 void UpdateDevTools() override {} |
| 50 virtual void UpdateLoadingAnimations(bool should_animate) override {} | 50 void UpdateLoadingAnimations(bool should_animate) override {} |
| 51 virtual void SetStarredState(bool is_starred) override {} | 51 void SetStarredState(bool is_starred) override {} |
| 52 virtual void SetTranslateIconToggled(bool is_lit) override {} | 52 void SetTranslateIconToggled(bool is_lit) override {} |
| 53 virtual void OnActiveTabChanged(content::WebContents* old_contents, | 53 void OnActiveTabChanged(content::WebContents* old_contents, |
| 54 content::WebContents* new_contents, | 54 content::WebContents* new_contents, |
| 55 int index, | 55 int index, |
| 56 int reason) override {} | 56 int reason) override {} |
| 57 virtual void ZoomChangedForActiveTab(bool can_show_bubble) override {} | 57 void ZoomChangedForActiveTab(bool can_show_bubble) override {} |
| 58 virtual gfx::Rect GetRestoredBounds() const override; | 58 gfx::Rect GetRestoredBounds() const override; |
| 59 virtual ui::WindowShowState GetRestoredState() const override; | 59 ui::WindowShowState GetRestoredState() const override; |
| 60 virtual gfx::Rect GetBounds() const override; | 60 gfx::Rect GetBounds() const override; |
| 61 virtual bool IsMaximized() const override; | 61 bool IsMaximized() const override; |
| 62 virtual bool IsMinimized() const override; | 62 bool IsMinimized() const override; |
| 63 virtual void Maximize() override {} | 63 void Maximize() override {} |
| 64 virtual void Minimize() override {} | 64 void Minimize() override {} |
| 65 virtual void Restore() override {} | 65 void Restore() override {} |
| 66 virtual void EnterFullscreen( | 66 void EnterFullscreen(const GURL& url, |
| 67 const GURL& url, FullscreenExitBubbleType type) override {} | 67 FullscreenExitBubbleType type) override {} |
| 68 virtual void ExitFullscreen() override {} | 68 void ExitFullscreen() override {} |
| 69 virtual void UpdateFullscreenExitBubbleContent( | 69 void UpdateFullscreenExitBubbleContent( |
| 70 const GURL& url, | 70 const GURL& url, |
| 71 FullscreenExitBubbleType bubble_type) override {} | 71 FullscreenExitBubbleType bubble_type) override {} |
| 72 virtual bool ShouldHideUIForFullscreen() const override; | 72 bool ShouldHideUIForFullscreen() const override; |
| 73 virtual bool IsFullscreen() const override; | 73 bool IsFullscreen() const override; |
| 74 #if defined(OS_WIN) | 74 #if defined(OS_WIN) |
| 75 virtual void SetMetroSnapMode(bool enable) override {} | 75 virtual void SetMetroSnapMode(bool enable) override {} |
| 76 virtual bool IsInMetroSnapMode() const; | 76 virtual bool IsInMetroSnapMode() const; |
| 77 #endif | 77 #endif |
| 78 virtual bool IsFullscreenBubbleVisible() const override; | 78 bool IsFullscreenBubbleVisible() const override; |
| 79 virtual LocationBar* GetLocationBar() const override; | 79 LocationBar* GetLocationBar() const override; |
| 80 virtual void SetFocusToLocationBar(bool select_all) override {} | 80 void SetFocusToLocationBar(bool select_all) override {} |
| 81 virtual void UpdateReloadStopState(bool is_loading, bool force) override {} | 81 void UpdateReloadStopState(bool is_loading, bool force) override {} |
| 82 virtual void UpdateToolbar(content::WebContents* contents) override {} | 82 void UpdateToolbar(content::WebContents* contents) override {} |
| 83 virtual void FocusToolbar() override {} | 83 void FocusToolbar() override {} |
| 84 virtual void FocusAppMenu() override {} | 84 void FocusAppMenu() override {} |
| 85 virtual void FocusBookmarksToolbar() override {} | 85 void FocusBookmarksToolbar() override {} |
| 86 virtual void FocusInfobars() override {} | 86 void FocusInfobars() override {} |
| 87 virtual void RotatePaneFocus(bool forwards) override {} | 87 void RotatePaneFocus(bool forwards) override {} |
| 88 virtual void ShowAppMenu() override {} | 88 void ShowAppMenu() override {} |
| 89 virtual bool PreHandleKeyboardEvent( | 89 bool PreHandleKeyboardEvent(const content::NativeWebKeyboardEvent& event, |
| 90 const content::NativeWebKeyboardEvent& event, | 90 bool* is_keyboard_shortcut) override; |
| 91 bool* is_keyboard_shortcut) override; | 91 void HandleKeyboardEvent( |
| 92 virtual void HandleKeyboardEvent( | |
| 93 const content::NativeWebKeyboardEvent& event) override {} | 92 const content::NativeWebKeyboardEvent& event) override {} |
| 94 | 93 |
| 95 virtual bool IsBookmarkBarVisible() const override; | 94 bool IsBookmarkBarVisible() const override; |
| 96 virtual bool IsBookmarkBarAnimating() const override; | 95 bool IsBookmarkBarAnimating() const override; |
| 97 virtual bool IsTabStripEditable() const override; | 96 bool IsTabStripEditable() const override; |
| 98 virtual bool IsToolbarVisible() const override; | 97 bool IsToolbarVisible() const override; |
| 99 virtual gfx::Rect GetRootWindowResizerRect() const override; | 98 gfx::Rect GetRootWindowResizerRect() const override; |
| 100 virtual void ConfirmAddSearchProvider(TemplateURL* template_url, | 99 void ConfirmAddSearchProvider(TemplateURL* template_url, |
| 101 Profile* profile) override {} | 100 Profile* profile) override {} |
| 102 virtual void ShowUpdateChromeDialog() override {} | 101 void ShowUpdateChromeDialog() override {} |
| 103 virtual void ShowBookmarkBubble(const GURL& url, | 102 void ShowBookmarkBubble(const GURL& url, bool already_bookmarked) override {} |
| 104 bool already_bookmarked) override {} | 103 void ShowBookmarkAppBubble(const WebApplicationInfo& web_app_info, |
| 105 virtual void ShowBookmarkAppBubble( | 104 const std::string& extension_id) override {} |
| 106 const WebApplicationInfo& web_app_info, | 105 void ShowTranslateBubble(content::WebContents* contents, |
| 107 const std::string& extension_id) override {} | 106 translate::TranslateStep step, |
| 108 virtual void ShowTranslateBubble( | 107 translate::TranslateErrors::Type error_type, |
| 109 content::WebContents* contents, | 108 bool is_user_gesture) override {} |
| 110 translate::TranslateStep step, | |
| 111 translate::TranslateErrors::Type error_type, | |
| 112 bool is_user_gesture) override {} | |
| 113 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 109 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 114 virtual void ShowOneClickSigninBubble( | 110 void ShowOneClickSigninBubble( |
| 115 OneClickSigninBubbleType type, | 111 OneClickSigninBubbleType type, |
| 116 const base::string16& email, | 112 const base::string16& email, |
| 117 const base::string16& error_message, | 113 const base::string16& error_message, |
| 118 const StartSyncCallback& start_sync_callback) override {} | 114 const StartSyncCallback& start_sync_callback) override {} |
| 119 #endif | 115 #endif |
| 120 virtual bool IsDownloadShelfVisible() const override; | 116 bool IsDownloadShelfVisible() const override; |
| 121 virtual DownloadShelf* GetDownloadShelf() override; | 117 DownloadShelf* GetDownloadShelf() override; |
| 122 virtual void ConfirmBrowserCloseWithPendingDownloads( | 118 void ConfirmBrowserCloseWithPendingDownloads( |
| 123 int download_count, | 119 int download_count, |
| 124 Browser::DownloadClosePreventionType dialog_type, | 120 Browser::DownloadClosePreventionType dialog_type, |
| 125 bool app_modal, | 121 bool app_modal, |
| 126 const base::Callback<void(bool)>& callback) override {} | 122 const base::Callback<void(bool)>& callback) override {} |
| 127 virtual void UserChangedTheme() override {} | 123 void UserChangedTheme() override {} |
| 128 virtual int GetExtraRenderViewHeight() const override; | 124 int GetExtraRenderViewHeight() const override; |
| 129 virtual void WebContentsFocused(content::WebContents* contents) override {} | 125 void WebContentsFocused(content::WebContents* contents) override {} |
| 130 virtual void ShowWebsiteSettings(Profile* profile, | 126 void ShowWebsiteSettings(Profile* profile, |
| 131 content::WebContents* web_contents, | 127 content::WebContents* web_contents, |
| 132 const GURL& url, | 128 const GURL& url, |
| 133 const content::SSLStatus& ssl) override {} | 129 const content::SSLStatus& ssl) override {} |
| 134 virtual void Cut() override {} | 130 void Cut() override {} |
| 135 virtual void Copy() override {} | 131 void Copy() override {} |
| 136 virtual void Paste() override {} | 132 void Paste() override {} |
| 137 #if defined(OS_MACOSX) | 133 #if defined(OS_MACOSX) |
| 138 virtual void EnterFullscreenWithChrome() override {} | 134 void EnterFullscreenWithChrome() override {} |
| 139 virtual void EnterFullscreenWithoutChrome() override {} | 135 void EnterFullscreenWithoutChrome() override {} |
| 140 virtual bool IsFullscreenWithChrome() override; | 136 bool IsFullscreenWithChrome() override; |
| 141 virtual bool IsFullscreenWithoutChrome() override; | 137 bool IsFullscreenWithoutChrome() override; |
| 142 #endif | 138 #endif |
| 143 | 139 |
| 144 virtual WindowOpenDisposition GetDispositionForPopupBounds( | 140 WindowOpenDisposition GetDispositionForPopupBounds( |
| 145 const gfx::Rect& bounds) override; | 141 const gfx::Rect& bounds) override; |
| 146 virtual FindBar* CreateFindBar() override; | 142 FindBar* CreateFindBar() override; |
| 147 virtual web_modal::WebContentsModalDialogHost* | 143 web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() |
| 148 GetWebContentsModalDialogHost() override; | 144 override; |
| 149 virtual void ShowAvatarBubble(content::WebContents* web_contents, | 145 void ShowAvatarBubble(content::WebContents* web_contents, |
| 150 const gfx::Rect& rect) override {} | 146 const gfx::Rect& rect) override {} |
| 151 virtual void ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode, | 147 void ShowAvatarBubbleFromAvatarButton( |
| 148 AvatarBubbleMode mode, |
| 152 const signin::ManageAccountsParams& manage_accounts_params) override {} | 149 const signin::ManageAccountsParams& manage_accounts_params) override {} |
| 153 virtual int GetRenderViewHeightInsetWithDetachedBookmarkBar() override; | 150 int GetRenderViewHeightInsetWithDetachedBookmarkBar() override; |
| 154 virtual void ExecuteExtensionCommand( | 151 void ExecuteExtensionCommand(const extensions::Extension* extension, |
| 155 const extensions::Extension* extension, | 152 const extensions::Command& command) override; |
| 156 const extensions::Command& command) override; | |
| 157 | 153 |
| 158 protected: | 154 protected: |
| 159 virtual void DestroyBrowser() override {} | 155 void DestroyBrowser() override {} |
| 160 | 156 |
| 161 private: | 157 private: |
| 162 class TestLocationBar : public LocationBar { | 158 class TestLocationBar : public LocationBar { |
| 163 public: | 159 public: |
| 164 TestLocationBar() : LocationBar(NULL) {} | 160 TestLocationBar() : LocationBar(NULL) {} |
| 165 virtual ~TestLocationBar() {} | 161 ~TestLocationBar() override {} |
| 166 | 162 |
| 167 // LocationBar: | 163 // LocationBar: |
| 168 virtual void ShowFirstRunBubble() override {} | 164 void ShowFirstRunBubble() override {} |
| 169 virtual GURL GetDestinationURL() const override; | 165 GURL GetDestinationURL() const override; |
| 170 virtual WindowOpenDisposition GetWindowOpenDisposition() const override; | 166 WindowOpenDisposition GetWindowOpenDisposition() const override; |
| 171 virtual ui::PageTransition GetPageTransition() const override; | 167 ui::PageTransition GetPageTransition() const override; |
| 172 virtual void AcceptInput() override {} | 168 void AcceptInput() override {} |
| 173 virtual void FocusLocation(bool select_all) override {} | 169 void FocusLocation(bool select_all) override {} |
| 174 virtual void FocusSearch() override {} | 170 void FocusSearch() override {} |
| 175 virtual void UpdateContentSettingsIcons() override {} | 171 void UpdateContentSettingsIcons() override {} |
| 176 virtual void UpdateManagePasswordsIconAndBubble() override {} | 172 void UpdateManagePasswordsIconAndBubble() override {} |
| 177 virtual void UpdatePageActions() override {} | 173 void UpdatePageActions() override {} |
| 178 virtual void InvalidatePageActions() override {} | 174 void InvalidatePageActions() override {} |
| 179 virtual void UpdateBookmarkStarVisibility() override {} | 175 void UpdateBookmarkStarVisibility() override {} |
| 180 virtual bool ShowPageActionPopup(const extensions::Extension* extension, | 176 bool ShowPageActionPopup(const extensions::Extension* extension, |
| 181 bool grant_active_tab) override; | 177 bool grant_active_tab) override; |
| 182 virtual void UpdateOpenPDFInReaderPrompt() override {} | 178 void UpdateOpenPDFInReaderPrompt() override {} |
| 183 virtual void UpdateGeneratedCreditCardView() override {} | 179 void UpdateGeneratedCreditCardView() override {} |
| 184 virtual void SaveStateToContents(content::WebContents* contents) override {} | 180 void SaveStateToContents(content::WebContents* contents) override {} |
| 185 virtual void Revert() override {} | 181 void Revert() override {} |
| 186 virtual const OmniboxView* GetOmniboxView() const override; | 182 const OmniboxView* GetOmniboxView() const override; |
| 187 virtual OmniboxView* GetOmniboxView() override; | 183 OmniboxView* GetOmniboxView() override; |
| 188 virtual LocationBarTesting* GetLocationBarForTesting() override; | 184 LocationBarTesting* GetLocationBarForTesting() override; |
| 189 | 185 |
| 190 private: | 186 private: |
| 191 DISALLOW_COPY_AND_ASSIGN(TestLocationBar); | 187 DISALLOW_COPY_AND_ASSIGN(TestLocationBar); |
| 192 }; | 188 }; |
| 193 | 189 |
| 194 TestDownloadShelf download_shelf_; | 190 TestDownloadShelf download_shelf_; |
| 195 TestLocationBar location_bar_; | 191 TestLocationBar location_bar_; |
| 196 | 192 |
| 197 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindow); | 193 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindow); |
| 198 }; | 194 }; |
| 199 | 195 |
| 200 namespace chrome { | 196 namespace chrome { |
| 201 | 197 |
| 202 // Helper that handle the lifetime of TestBrowserWindow instances. | 198 // Helper that handle the lifetime of TestBrowserWindow instances. |
| 203 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params); | 199 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params); |
| 204 | 200 |
| 205 } // namespace chrome | 201 } // namespace chrome |
| 206 | 202 |
| 207 #endif // CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_ | 203 #endif // CHROME_TEST_BASE_TEST_BROWSER_WINDOW_H_ |
| OLD | NEW |