Home | History | Annotate | Download | only in base
      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 #include "chrome/test/base/test_browser_window.h"
      6 
      7 #include "chrome/browser/ui/browser_list.h"
      8 #include "chrome/browser/ui/browser_list_observer.h"
      9 #include "ui/gfx/rect.h"
     10 
     11 
     12 // Helpers --------------------------------------------------------------------
     13 
     14 namespace chrome {
     15 
     16 namespace {
     17 
     18 // Handles destroying a TestBrowserWindow when the Browser it is attached to is
     19 // destroyed.
     20 class TestBrowserWindowOwner : public chrome::BrowserListObserver {
     21  public:
     22   explicit TestBrowserWindowOwner(TestBrowserWindow* window) : window_(window) {
     23     BrowserList::AddObserver(this);
     24   }
     25   virtual ~TestBrowserWindowOwner() {
     26     BrowserList::RemoveObserver(this);
     27   }
     28 
     29  private:
     30   // Overridden from BrowserListObserver:
     31   virtual void OnBrowserRemoved(Browser* browser) OVERRIDE {
     32     if (browser->window() == window_.get())
     33       delete this;
     34   }
     35 
     36   scoped_ptr<TestBrowserWindow> window_;
     37 
     38   DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowOwner);
     39 };
     40 
     41 }  // namespace
     42 
     43 Browser* CreateBrowserWithTestWindowForParams(Browser::CreateParams* params) {
     44   TestBrowserWindow* window = new TestBrowserWindow;
     45   new TestBrowserWindowOwner(window);
     46   params->window = window;
     47   return new Browser(*params);
     48 }
     49 
     50 }  // namespace chrome
     51 
     52 
     53 // TestBrowserWindow::TestLocationBar -----------------------------------------
     54 
     55 GURL TestBrowserWindow::TestLocationBar::GetDestinationURL() const {
     56   return GURL();
     57 }
     58 
     59 WindowOpenDisposition
     60     TestBrowserWindow::TestLocationBar::GetWindowOpenDisposition() const {
     61   return CURRENT_TAB;
     62 }
     63 
     64 content::PageTransition
     65     TestBrowserWindow::TestLocationBar::GetPageTransition() const {
     66   return content::PAGE_TRANSITION_LINK;
     67 }
     68 
     69 const OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() const {
     70   return NULL;
     71 }
     72 
     73 OmniboxView* TestBrowserWindow::TestLocationBar::GetOmniboxView() {
     74   return NULL;
     75 }
     76 
     77 LocationBarTesting*
     78     TestBrowserWindow::TestLocationBar::GetLocationBarForTesting() {
     79   return NULL;
     80 }
     81 
     82 
     83 // TestBrowserWindow ----------------------------------------------------------
     84 
     85 TestBrowserWindow::TestBrowserWindow() {}
     86 
     87 TestBrowserWindow::~TestBrowserWindow() {}
     88 
     89 bool TestBrowserWindow::IsActive() const {
     90   return false;
     91 }
     92 
     93 bool TestBrowserWindow::IsAlwaysOnTop() const {
     94   return false;
     95 }
     96 
     97 gfx::NativeWindow TestBrowserWindow::GetNativeWindow() {
     98   return NULL;
     99 }
    100 
    101 BrowserWindowTesting* TestBrowserWindow::GetBrowserWindowTesting() {
    102   return NULL;
    103 }
    104 
    105 StatusBubble* TestBrowserWindow::GetStatusBubble() {
    106   return NULL;
    107 }
    108 
    109 gfx::Rect TestBrowserWindow::GetRestoredBounds() const {
    110   return gfx::Rect();
    111 }
    112 
    113 ui::WindowShowState TestBrowserWindow::GetRestoredState() const {
    114   return ui::SHOW_STATE_DEFAULT;
    115 }
    116 
    117 gfx::Rect TestBrowserWindow::GetBounds() const {
    118   return gfx::Rect();
    119 }
    120 
    121 bool TestBrowserWindow::IsMaximized() const {
    122   return false;
    123 }
    124 
    125 bool TestBrowserWindow::IsMinimized() const {
    126   return false;
    127 }
    128 
    129 bool TestBrowserWindow::ShouldHideUIForFullscreen() const {
    130   return false;
    131 }
    132 
    133 bool TestBrowserWindow::IsFullscreen() const {
    134   return false;
    135 }
    136 
    137 #if defined(OS_WIN)
    138 bool TestBrowserWindow::IsInMetroSnapMode() const {
    139   return false;
    140 }
    141 #endif
    142 
    143 bool TestBrowserWindow::IsFullscreenBubbleVisible() const {
    144   return false;
    145 }
    146 
    147 LocationBar* TestBrowserWindow::GetLocationBar() const {
    148   return const_cast<TestLocationBar*>(&location_bar_);
    149 }
    150 
    151 bool TestBrowserWindow::PreHandleKeyboardEvent(
    152     const content::NativeWebKeyboardEvent& event,
    153     bool* is_keyboard_shortcut) {
    154   return false;
    155 }
    156 
    157 bool TestBrowserWindow::IsBookmarkBarVisible() const {
    158   return false;
    159 }
    160 
    161 bool TestBrowserWindow::IsBookmarkBarAnimating() const {
    162   return false;
    163 }
    164 
    165 bool TestBrowserWindow::IsTabStripEditable() const {
    166   return false;
    167 }
    168 
    169 bool TestBrowserWindow::IsToolbarVisible() const {
    170   return false;
    171 }
    172 
    173 gfx::Rect TestBrowserWindow::GetRootWindowResizerRect() const {
    174   return gfx::Rect();
    175 }
    176 
    177 bool TestBrowserWindow::IsDownloadShelfVisible() const {
    178   return false;
    179 }
    180 
    181 DownloadShelf* TestBrowserWindow::GetDownloadShelf() {
    182   return &download_shelf_;
    183 }
    184 
    185 int TestBrowserWindow::GetExtraRenderViewHeight() const {
    186   return 0;
    187 }
    188 
    189 #if defined(OS_MACOSX)
    190 bool TestBrowserWindow::IsFullscreenWithChrome() {
    191   return false;
    192 }
    193 
    194 bool TestBrowserWindow::IsFullscreenWithoutChrome() {
    195   return false;
    196 }
    197 #endif
    198 
    199 WindowOpenDisposition TestBrowserWindow::GetDispositionForPopupBounds(
    200     const gfx::Rect& bounds) {
    201   return NEW_POPUP;
    202 }
    203 
    204 FindBar* TestBrowserWindow::CreateFindBar() {
    205   return NULL;
    206 }
    207 
    208 web_modal::WebContentsModalDialogHost*
    209     TestBrowserWindow::GetWebContentsModalDialogHost() {
    210   return NULL;
    211 }
    212 
    213 int
    214 TestBrowserWindow::GetRenderViewHeightInsetWithDetachedBookmarkBar() {
    215   return 0;
    216 }
    217 
    218 void TestBrowserWindow::ExecuteExtensionCommand(
    219     const extensions::Extension* extension,
    220     const extensions::Command& command) {}
    221 
    222 void TestBrowserWindow::ShowPageActionPopup(
    223     const extensions::Extension* extension) {}
    224 
    225 void TestBrowserWindow::ShowBrowserActionPopup(
    226     const extensions::Extension* extension) {}
    227