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

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

Issue 27247: Non-functional cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/command_line.h" 5 #include "base/command_line.h"
6 6
7 #include "chrome/browser/views/frame/browser_view.h" 7 #include "chrome/browser/views/frame/browser_view.h"
8 8
9 #include "base/file_version_info.h" 9 #include "base/file_version_info.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 { false, IDC_RELOAD, IDS_APP_MENU_RELOAD }, 119 { false, IDC_RELOAD, IDS_APP_MENU_RELOAD },
120 { false, IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD }, 120 { false, IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD },
121 { false, IDC_BACK, IDS_CONTENT_CONTEXT_BACK } 121 { false, IDC_BACK, IDS_CONTENT_CONTEXT_BACK }
122 }; 122 };
123 123
124 /////////////////////////////////////////////////////////////////////////////// 124 ///////////////////////////////////////////////////////////////////////////////
125 // ResizeCorner, private: 125 // ResizeCorner, private:
126 126
127 class ResizeCorner : public views::View { 127 class ResizeCorner : public views::View {
128 public: 128 public:
129 ResizeCorner(const BrowserWindow* parent) 129 explicit ResizeCorner(const BrowserView* parent)
130 : parent_(parent) { 130 : parent_(parent) {
131 } 131 }
132 132
133 virtual void Paint(ChromeCanvas* canvas) { 133 virtual void Paint(ChromeCanvas* canvas) {
134 if (parent_ && (parent_->IsMaximized() || parent_->IsFullscreen())) 134 if (parent_ && !parent_->CanCurrentlyResize())
135 return; 135 return;
136 136
137 SkBitmap * bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( 137 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
138 IDR_TEXTAREA_RESIZER); 138 IDR_TEXTAREA_RESIZER);
139 bitmap->buildMipMap(false); 139 bitmap->buildMipMap(false);
140 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); 140 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT);
141 if (rtl_dir) { 141 if (rtl_dir) {
142 canvas->TranslateInt(width(), 0); 142 canvas->TranslateInt(width(), 0);
143 canvas->ScaleInt(-1, 1); 143 canvas->ScaleInt(-1, 1);
144 canvas->save(); 144 canvas->save();
145 } 145 }
146 canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(), 146 canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(),
147 height() - bitmap->height()); 147 height() - bitmap->height());
148 if (rtl_dir) 148 if (rtl_dir)
149 canvas->restore(); 149 canvas->restore();
150 } 150 }
151 151
152 static gfx::Size GetSize() { 152 static gfx::Size GetSize() {
153 return gfx::Size(views::NativeScrollBar::GetVerticalScrollBarWidth(), 153 return gfx::Size(views::NativeScrollBar::GetVerticalScrollBarWidth(),
154 views::NativeScrollBar::GetHorizontalScrollBarHeight()); 154 views::NativeScrollBar::GetHorizontalScrollBarHeight());
155 } 155 }
156 156
157 virtual gfx::Size GetPreferredSize() { 157 virtual gfx::Size GetPreferredSize() {
158 if (parent_ && (parent_->IsMaximized() || parent_->IsFullscreen())) 158 return (parent_ && !parent_->CanCurrentlyResize()) ?
159 return gfx::Size(); 159 gfx::Size() : GetSize();
160 return GetSize();
161 } 160 }
162 161
163 virtual void Layout() { 162 virtual void Layout() {
164 views::View* parent_view = GetParent(); 163 views::View* parent_view = GetParent();
165 if (parent_view) { 164 if (parent_view) {
166 gfx::Size ps = GetPreferredSize(); 165 gfx::Size ps = GetPreferredSize();
167 // No need to handle Right to left text direction here, 166 // No need to handle Right to left text direction here,
168 // our parent must take care of it for us... 167 // our parent must take care of it for us...
169 SetBounds(parent_view->width() - ps.width(), 168 SetBounds(parent_view->width() - ps.width(),
170 parent_view->height() - ps.height(), ps.width(), ps.height()); 169 parent_view->height() - ps.height(), ps.width(), ps.height());
171 } 170 }
172 } 171 }
173 172
174 private: 173 private:
175 const BrowserWindow* parent_; 174 const BrowserView* parent_;
176 DISALLOW_COPY_AND_ASSIGN(ResizeCorner); 175 DISALLOW_COPY_AND_ASSIGN(ResizeCorner);
177 }; 176 };
178 177
179 178
180 /////////////////////////////////////////////////////////////////////////////// 179 ///////////////////////////////////////////////////////////////////////////////
181 // BrowserView, public: 180 // BrowserView, public:
182 181
183 // static 182 // static
184 void BrowserView::SetShowState(int state) { 183 void BrowserView::SetShowState(int state) {
185 explicit_show_state = state; 184 explicit_show_state = state;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (toolbar_->GetLocationBarView()) 252 if (toolbar_->GetLocationBarView())
254 toolbar_->GetLocationBarView()->location_entry()->ClosePopup(); 253 toolbar_->GetLocationBarView()->location_entry()->ClosePopup();
255 } 254 }
256 255
257 void BrowserView::WindowMoveOrResizeStarted() { 256 void BrowserView::WindowMoveOrResizeStarted() {
258 TabContents* tab_contents = GetSelectedTabContents(); 257 TabContents* tab_contents = GetSelectedTabContents();
259 if (tab_contents && tab_contents->AsWebContents()) 258 if (tab_contents && tab_contents->AsWebContents())
260 tab_contents->AsWebContents()->WindowMoveOrResizeStarted(); 259 tab_contents->AsWebContents()->WindowMoveOrResizeStarted();
261 } 260 }
262 261
262 bool BrowserView::CanCurrentlyResize() const {
263 return !IsMaximized() && !IsFullscreen();
264 }
265
263 gfx::Rect BrowserView::GetToolbarBounds() const { 266 gfx::Rect BrowserView::GetToolbarBounds() const {
264 return toolbar_->bounds(); 267 return toolbar_->bounds();
265 } 268 }
266 269
267 gfx::Rect BrowserView::GetClientAreaBounds() const { 270 gfx::Rect BrowserView::GetClientAreaBounds() const {
268 gfx::Rect container_bounds = contents_container_->bounds(); 271 gfx::Rect container_bounds = contents_container_->bounds();
269 gfx::Point container_origin = container_bounds.origin(); 272 gfx::Point container_origin = container_bounds.origin();
270 ConvertPointToView(this, GetParent(), &container_origin); 273 ConvertPointToView(this, GetParent(), &container_origin);
271 container_bounds.set_origin(container_origin); 274 container_bounds.set_origin(container_origin);
272 return container_bounds; 275 return container_bounds;
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 browser_.reset(); 709 browser_.reset();
707 } 710 }
708 711
709 bool BrowserView::IsBookmarkBarVisible() const { 712 bool BrowserView::IsBookmarkBarVisible() const {
710 return SupportsWindowFeature(FEATURE_BOOKMARKBAR) && 713 return SupportsWindowFeature(FEATURE_BOOKMARKBAR) &&
711 bookmark_bar_view_.get() && 714 bookmark_bar_view_.get() &&
712 (bookmark_bar_view_->GetPreferredSize().height() != 0); 715 (bookmark_bar_view_->GetPreferredSize().height() != 0);
713 } 716 }
714 717
715 gfx::Rect BrowserView::GetRootWindowResizerRect() const { 718 gfx::Rect BrowserView::GetRootWindowResizerRect() const {
716 // There is no resize corner when we are maximized or full screen 719 if (!CanCurrentlyResize())
717 if (IsMaximized() || IsFullscreen())
718 return gfx::Rect(); 720 return gfx::Rect();
719 721
720 // We don't specify a resize corner size if we have a bottom shelf either. 722 // We don't specify a resize corner size if we have a bottom shelf either.
721 // This is because we take care of drawing the resize corner on top of that 723 // This is because we take care of drawing the resize corner on top of that
722 // shelf, so we don't want others to do it for us in this case. 724 // shelf, so we don't want others to do it for us in this case.
723 // Currently, the only visible bottom shelf is the download shelf. 725 // Currently, the only visible bottom shelf is the download shelf.
724 // Other tests should be added here if we add more bottom shelves. 726 // Other tests should be added here if we add more bottom shelves.
725 TabContents* current_tab = browser_->GetSelectedTabContents(); 727 TabContents* current_tab = browser_->GetSelectedTabContents();
726 if (current_tab && current_tab->IsDownloadShelfVisible()) { 728 if (current_tab && current_tab->IsDownloadShelfVisible()) {
727 DownloadShelfView* download_shelf = current_tab->GetDownloadShelfView(); 729 DownloadShelfView* download_shelf = current_tab->GetDownloadShelfView();
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 NotificationService::NoDetails()); 1101 NotificationService::NoDetails());
1100 return true; 1102 return true;
1101 } 1103 }
1102 1104
1103 int BrowserView::NonClientHitTest(const gfx::Point& point) { 1105 int BrowserView::NonClientHitTest(const gfx::Point& point) {
1104 // Since the TabStrip only renders in some parts of the top of the window, 1106 // Since the TabStrip only renders in some parts of the top of the window,
1105 // the un-obscured area is considered to be part of the non-client caption 1107 // the un-obscured area is considered to be part of the non-client caption
1106 // area of the window. So we need to treat hit-tests in these regions as 1108 // area of the window. So we need to treat hit-tests in these regions as
1107 // hit-tests of the titlebar. 1109 // hit-tests of the titlebar.
1108 1110
1109 // There is not resize corner when we are maximised 1111 if (CanCurrentlyResize()) {
1110 if (!IsMaximized() && !IsFullscreen()) {
1111 CRect client_rect; 1112 CRect client_rect;
1112 ::GetClientRect(frame_->GetWindow()->GetHWND(), &client_rect); 1113 ::GetClientRect(frame_->GetWindow()->GetHWND(), &client_rect);
1113 gfx::Size resize_corner_size = ResizeCorner::GetSize(); 1114 gfx::Size resize_corner_size = ResizeCorner::GetSize();
1114 gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(), 1115 gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(),
1115 client_rect.bottom - resize_corner_size.height(), 1116 client_rect.bottom - resize_corner_size.height(),
1116 resize_corner_size.width(), resize_corner_size.height()); 1117 resize_corner_size.width(), resize_corner_size.height());
1117 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); 1118 bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT);
1118 if (rtl_dir) 1119 if (rtl_dir)
1119 resize_corner_rect.set_x(0); 1120 resize_corner_rect.set_x(0);
1120 if (resize_corner_rect.Contains(point)) { 1121 if (resize_corner_rect.Contains(point)) {
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 1664
1664 // static 1665 // static
1665 void BrowserView::InitClass() { 1666 void BrowserView::InitClass() {
1666 static bool initialized = false; 1667 static bool initialized = false;
1667 if (!initialized) { 1668 if (!initialized) {
1668 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1669 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1669 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); 1670 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
1670 initialized = true; 1671 initialized = true;
1671 } 1672 }
1672 } 1673 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/browser_view.h ('k') | chrome/browser/views/frame/opaque_non_client_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698