blob: 9320c7dcb9ce0f38fe5ca0884a2c2f6e15410b28 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/test/base/test_browser_window.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "ui/gfx/geometry/rect.h"
// Helpers --------------------------------------------------------------------
std::unique_ptr<Browser> CreateBrowserWithTestWindowForParams(
Browser::CreateParams* params) {
TestBrowserWindow* window = new TestBrowserWindow;
new TestBrowserWindowOwner(window);
params->window = window;
return std::make_unique<Browser>(*params);
}
// TestBrowserWindow::TestLocationBar -----------------------------------------
GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
return GURL();
}
WindowOpenDisposition
TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {
return WindowOpenDisposition::CURRENT_TAB;
}
ui::PageTransition
TestBrowserWindow::TestLocationBar::GetPageTransition() const {
return ui::PAGE_TRANSITION_LINK;
}
base::TimeTicks TestBrowserWindow::TestLocationBar::GetMatchSelectionTimestamp()
const {
return base::TimeTicks();
}
const OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() const {
return NULL;
}
OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() {
return NULL;
}
LocationBarTesting*
TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() {
return NULL;
}
// TestBrowserWindow ----------------------------------------------------------
TestBrowserWindow::TestBrowserWindow() {}
TestBrowserWindow::~TestBrowserWindow() {}
bool TestBrowserWindow::IsActive() const {
return false;
}
bool TestBrowserWindow::IsAlwaysOnTop() const {
return false;
}
gfx::NativeWindow TestBrowserWindow::GetNativeWindow() const {
return NULL;
}
void TestBrowserWindow::SetTopControlsShownRatio(
content::WebContents* web_contents,
float ratio) {}
bool TestBrowserWindow::DoBrowserControlsShrinkRendererSize(
const content::WebContents* contents) const {
return false;
}
int TestBrowserWindow::GetTopControlsHeight() const {
return 0;
}
void TestBrowserWindow::SetTopControlsGestureScrollInProgress(
bool in_progress) {}
StatusBubble* TestBrowserWindow::GetStatusBubble() {
return NULL;
}
gfx::Rect TestBrowserWindow::GetRestoredBounds() const {
return gfx::Rect();
}
ui::WindowShowState TestBrowserWindow::GetRestoredState() const {
return ui::SHOW_STATE_DEFAULT;
}
gfx::Rect TestBrowserWindow::GetBounds() const {
return gfx::Rect();
}
gfx::Size TestBrowserWindow::GetContentsSize() const {
return gfx::Size();
}
bool TestBrowserWindow::IsMaximized() const {
return false;
}
bool TestBrowserWindow::IsMinimized() const {
return false;
}
bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
return false;
}
bool TestBrowserWindow::IsFullscreen() const {
return false;
}
bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
return false;
}
bool TestBrowserWindow::IsVisible() const {
return true;
}
LocationBar* TestBrowserWindow::GetLocationBar() const {
return const_cast<TestLocationBar*>(&location_bar_);
}
PageActionIconContainer* TestBrowserWindow::GetPageActionIconContainer() {
return &page_action_icon_container_;
}
ToolbarActionsBar* TestBrowserWindow::GetToolbarActionsBar() {
return nullptr;
}
content::KeyboardEventProcessingResult
TestBrowserWindow::PreHandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
return content::KeyboardEventProcessingResult::NOT_HANDLED;
}
bool TestBrowserWindow::HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
return false;
}
bool TestBrowserWindow::IsBookmarkBarVisible() const {
return false;
}
bool TestBrowserWindow::IsBookmarkBarAnimating() const {
return false;
}
bool TestBrowserWindow::IsTabStripEditable() const {
return false;
}
bool TestBrowserWindow::IsToolbarVisible() const {
return false;
}
bool TestBrowserWindow::IsToolbarShowing() const {
return false;
}
#if !defined(OS_CHROMEOS)
BadgeServiceDelegate* TestBrowserWindow::GetBadgeServiceDelegate() const {
return nullptr;
}
#endif
ShowTranslateBubbleResult TestBrowserWindow::ShowTranslateBubble(
content::WebContents* contents,
translate::TranslateStep step,
translate::TranslateErrors::Type error_type,
bool is_user_gesture) {
return ShowTranslateBubbleResult::SUCCESS;
}
autofill::SaveCardBubbleView* TestBrowserWindow::ShowSaveCreditCardBubble(
content::WebContents* contents,
autofill::SaveCardBubbleController* controller,
bool user_gesture) {
return nullptr;
}
autofill::LocalCardMigrationBubble*
TestBrowserWindow::ShowLocalCardMigrationBubble(
content::WebContents* contents,
autofill::LocalCardMigrationBubbleController* controller,
bool user_gesture) {
return nullptr;
}
bool TestBrowserWindow::IsDownloadShelfVisible() const {
return false;
}
DownloadShelf* TestBrowserWindow::GetDownloadShelf() {
return &download_shelf_;
}
FindBar* TestBrowserWindow::CreateFindBar() {
return NULL;
}
web_modal::WebContentsModalDialogHost*
TestBrowserWindow::GetWebContentsModalDialogHost() {
return NULL;
}
int TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
return 0;
}
void TestBrowserWindow::ExecuteExtensionCommand(
const extensions::Extension* extension,
const extensions::Command& command) {}
ExclusiveAccessContext* TestBrowserWindow::GetExclusiveAccessContext() {
return nullptr;
}
std::string TestBrowserWindow::GetWorkspace() const {
return std::string();
}
bool TestBrowserWindow::IsVisibleOnAllWorkspaces() const {
return false;
}
// TestBrowserWindowOwner -----------------------------------------------------
TestBrowserWindowOwner::TestBrowserWindowOwner(TestBrowserWindow* window)
: window_(window) {
BrowserList::AddObserver(this);
}
TestBrowserWindowOwner::~TestBrowserWindowOwner() {
BrowserList::RemoveObserver(this);
}
void TestBrowserWindowOwner::OnBrowserRemoved(Browser* browser) {
if (browser->window() == window_.get())
delete this;
}