| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" | 
| 6 | 6 | 
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) | 
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> | 
| 9 #endif | 9 #endif | 
| 10 | 10 | 
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 254     return gfx::Size(); | 254     return gfx::Size(); | 
| 255   } | 255   } | 
| 256 | 256 | 
| 257   virtual gfx::Size GetPreferredSize() { | 257   virtual gfx::Size GetPreferredSize() { | 
| 258     views::Window* window = GetWindow(); | 258     views::Window* window = GetWindow(); | 
| 259     return (!window || window->IsMaximized() || window->IsFullscreen()) ? | 259     return (!window || window->IsMaximized() || window->IsFullscreen()) ? | 
| 260         gfx::Size() : GetSize(); | 260         gfx::Size() : GetSize(); | 
| 261   } | 261   } | 
| 262 | 262 | 
| 263   virtual void Layout() { | 263   virtual void Layout() { | 
| 264     views::View* parent_view = GetParent(); | 264     if (parent()) { | 
| 265     if (parent_view) { |  | 
| 266       gfx::Size ps = GetPreferredSize(); | 265       gfx::Size ps = GetPreferredSize(); | 
| 267       // No need to handle Right to left text direction here, | 266       // No need to handle Right to left text direction here, | 
| 268       // our parent must take care of it for us... | 267       // our parent must take care of it for us... | 
| 269       // TODO(alekseys): fix it. | 268       // TODO(alekseys): fix it. | 
| 270       SetBounds(parent_view->width() - ps.width(), | 269       SetBounds(parent()->width() - ps.width(), | 
| 271                 parent_view->height() - ps.height(), ps.width(), ps.height()); | 270                 parent()->height() - ps.height(), ps.width(), ps.height()); | 
| 272     } | 271     } | 
| 273   } | 272   } | 
| 274 | 273 | 
| 275  private: | 274  private: | 
| 276   // Returns the WindowWin we're displayed in. Returns NULL if we're not | 275   // Returns the WindowWin we're displayed in. Returns NULL if we're not | 
| 277   // currently in a window. | 276   // currently in a window. | 
| 278   views::Window* GetWindow() { | 277   views::Window* GetWindow() { | 
| 279     views::Widget* widget = GetWidget(); | 278     views::Widget* widget = GetWidget(); | 
| 280     return widget ? widget->GetWindow() : NULL; | 279     return widget ? widget->GetWindow() : NULL; | 
| 281   } | 280   } | 
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 470 #endif | 469 #endif | 
| 471 | 470 | 
| 472   // We destroy the download shelf before |browser_| to remove its child | 471   // We destroy the download shelf before |browser_| to remove its child | 
| 473   // download views from the set of download observers (since the observed | 472   // download views from the set of download observers (since the observed | 
| 474   // downloads can be destroyed along with |browser_| and the observer | 473   // downloads can be destroyed along with |browser_| and the observer | 
| 475   // notifications will call back into deleted objects). | 474   // notifications will call back into deleted objects). | 
| 476   download_shelf_.reset(); | 475   download_shelf_.reset(); | 
| 477 | 476 | 
| 478   // The TabStrip attaches a listener to the model. Make sure we shut down the | 477   // The TabStrip attaches a listener to the model. Make sure we shut down the | 
| 479   // TabStrip first so that it can cleanly remove the listener. | 478   // TabStrip first so that it can cleanly remove the listener. | 
| 480   tabstrip_->GetParent()->RemoveChildView(tabstrip_); | 479   tabstrip_->parent()->RemoveChildView(tabstrip_); | 
| 481   delete tabstrip_; | 480   delete tabstrip_; | 
| 482   tabstrip_ = NULL; | 481   tabstrip_ = NULL; | 
| 483 | 482 | 
| 484   // Child views maintain PrefMember attributes that point to | 483   // Child views maintain PrefMember attributes that point to | 
| 485   // OffTheRecordProfile's PrefService which gets deleted by ~Browser. | 484   // OffTheRecordProfile's PrefService which gets deleted by ~Browser. | 
| 486   RemoveAllChildViews(true); | 485   RemoveAllChildViews(true); | 
| 487   // Explicitly set browser_ to NULL. | 486   // Explicitly set browser_ to NULL. | 
| 488   browser_.reset(); | 487   browser_.reset(); | 
| 489 } | 488 } | 
| 490 | 489 | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 553   if (UseVerticalTabs()) | 552   if (UseVerticalTabs()) | 
| 554     toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0); | 553     toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0); | 
| 555   // The apparent toolbar edges are outside the "real" toolbar edges. | 554   // The apparent toolbar edges are outside the "real" toolbar edges. | 
| 556   toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); | 555   toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); | 
| 557   return toolbar_bounds; | 556   return toolbar_bounds; | 
| 558 } | 557 } | 
| 559 | 558 | 
| 560 gfx::Rect BrowserView::GetClientAreaBounds() const { | 559 gfx::Rect BrowserView::GetClientAreaBounds() const { | 
| 561   gfx::Rect container_bounds = contents_->bounds(); | 560   gfx::Rect container_bounds = contents_->bounds(); | 
| 562   gfx::Point container_origin = container_bounds.origin(); | 561   gfx::Point container_origin = container_bounds.origin(); | 
| 563   ConvertPointToView(this, GetParent(), &container_origin); | 562   ConvertPointToView(this, parent(), &container_origin); | 
| 564   container_bounds.set_origin(container_origin); | 563   container_bounds.set_origin(container_origin); | 
| 565   return container_bounds; | 564   return container_bounds; | 
| 566 } | 565 } | 
| 567 | 566 | 
| 568 gfx::Rect BrowserView::GetFindBarBoundingBox() const { | 567 gfx::Rect BrowserView::GetFindBarBoundingBox() const { | 
| 569   return GetBrowserViewLayout()->GetFindBarBoundingBox(); | 568   return GetBrowserViewLayout()->GetFindBarBoundingBox(); | 
| 570 } | 569 } | 
| 571 | 570 | 
| 572 int BrowserView::GetTabStripHeight() const { | 571 int BrowserView::GetTabStripHeight() const { | 
| 573   // We want to return tabstrip_->height(), but we might be called in the midst | 572   // We want to return tabstrip_->height(), but we might be called in the midst | 
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 956   if (devtools_container_->IsVisible()) | 955   if (devtools_container_->IsVisible()) | 
| 957     accessible_views.push_back(devtools_container_->GetFocusView()); | 956     accessible_views.push_back(devtools_container_->GetFocusView()); | 
| 958   int count = static_cast<int>(accessible_views.size()); | 957   int count = static_cast<int>(accessible_views.size()); | 
| 959 | 958 | 
| 960   // Figure out which view (if any) currently has the focus. | 959   // Figure out which view (if any) currently has the focus. | 
| 961   views::View* focused_view = GetRootView()->GetFocusedView(); | 960   views::View* focused_view = GetRootView()->GetFocusedView(); | 
| 962   int index = -1; | 961   int index = -1; | 
| 963   if (focused_view) { | 962   if (focused_view) { | 
| 964     for (int i = 0; i < count; ++i) { | 963     for (int i = 0; i < count; ++i) { | 
| 965       if (accessible_views[i] == focused_view || | 964       if (accessible_views[i] == focused_view || | 
| 966           accessible_views[i]->IsParentOf(focused_view)) { | 965           accessible_views[i]->Contains(focused_view)) { | 
| 967         index = i; | 966         index = i; | 
| 968         break; | 967         break; | 
| 969       } | 968       } | 
| 970     } | 969     } | 
| 971   } | 970   } | 
| 972 | 971 | 
| 973   // If the focus isn't currently in a pane, save the focus so we | 972   // If the focus isn't currently in a pane, save the focus so we | 
| 974   // can restore it if the user presses Escape. | 973   // can restore it if the user presses Escape. | 
| 975   if (focused_view && index >= pane_count) | 974   if (focused_view && index >= pane_count) | 
| 976     SaveFocusedView(); | 975     SaveFocusedView(); | 
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1812 | 1811 | 
| 1813 AccessibilityTypes::Role BrowserView::GetAccessibleRole() { | 1812 AccessibilityTypes::Role BrowserView::GetAccessibleRole() { | 
| 1814   return AccessibilityTypes::ROLE_CLIENT; | 1813   return AccessibilityTypes::ROLE_CLIENT; | 
| 1815 } | 1814 } | 
| 1816 | 1815 | 
| 1817 void BrowserView::InfoBarContainerSizeChanged(bool is_animating) { | 1816 void BrowserView::InfoBarContainerSizeChanged(bool is_animating) { | 
| 1818   SelectedTabToolbarSizeChanged(is_animating); | 1817   SelectedTabToolbarSizeChanged(is_animating); | 
| 1819 } | 1818 } | 
| 1820 | 1819 | 
| 1821 bool BrowserView::SplitHandleMoved(views::SingleSplitView* view) { | 1820 bool BrowserView::SplitHandleMoved(views::SingleSplitView* view) { | 
| 1822   for (int i = 0; i < view->GetChildViewCount(); ++i) | 1821   for (int i = 0; i < view->child_count(); ++i) | 
| 1823     view->GetChildViewAt(i)->InvalidateLayout(); | 1822     view->GetChildViewAt(i)->InvalidateLayout(); | 
| 1824   SchedulePaint(); | 1823   SchedulePaint(); | 
| 1825   Layout(); | 1824   Layout(); | 
| 1826   return false; | 1825   return false; | 
| 1827 } | 1826 } | 
| 1828 | 1827 | 
| 1829 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 1828 views::LayoutManager* BrowserView::CreateLayoutManager() const { | 
| 1830   return new BrowserViewLayout; | 1829   return new BrowserViewLayout; | 
| 1831 } | 1830 } | 
| 1832 | 1831 | 
| 1833 void BrowserView::InitTabStrip(TabStripModel* model) { | 1832 void BrowserView::InitTabStrip(TabStripModel* model) { | 
| 1834   // Throw away the existing tabstrip if we're switching display modes. | 1833   // Throw away the existing tabstrip if we're switching display modes. | 
| 1835   scoped_ptr<BaseTabStrip> old_strip(tabstrip_); | 1834   scoped_ptr<BaseTabStrip> old_strip(tabstrip_); | 
| 1836   if (tabstrip_) { | 1835   if (tabstrip_) | 
| 1837     tabstrip_->GetParent()->RemoveChildView(tabstrip_); | 1836     tabstrip_->parent()->RemoveChildView(tabstrip_); | 
| 1838   } |  | 
| 1839 | 1837 | 
| 1840   BrowserTabStripController* tabstrip_controller = | 1838   BrowserTabStripController* tabstrip_controller = | 
| 1841       new BrowserTabStripController(browser_.get(), model); | 1839       new BrowserTabStripController(browser_.get(), model); | 
| 1842 | 1840 | 
| 1843   tabstrip_ = CreateTabStrip(tabstrip_controller, UseVerticalTabs()); | 1841   tabstrip_ = CreateTabStrip(tabstrip_controller, UseVerticalTabs()); | 
| 1844 | 1842 | 
| 1845   tabstrip_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TABSTRIP)); | 1843   tabstrip_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_TABSTRIP)); | 
| 1846   AddChildView(tabstrip_); | 1844   AddChildView(tabstrip_); | 
| 1847 | 1845 | 
| 1848   tabstrip_controller->InitFromModel(tabstrip_); | 1846   tabstrip_controller->InitFromModel(tabstrip_); | 
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2557       l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 2555       l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 
| 2558 | 2556 | 
| 2559   return view; | 2557   return view; | 
| 2560 } | 2558 } | 
| 2561 #endif | 2559 #endif | 
| 2562 | 2560 | 
| 2563 // static | 2561 // static | 
| 2564 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2562 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 
| 2565   return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2563   return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 
| 2566 } | 2564 } | 
| OLD | NEW | 
|---|