Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

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

Powered by Google App Engine
This is Rietveld 408576698