OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/frame/browser_view.h" | 5 #include "chrome/browser/views/frame/browser_view.h" |
6 | 6 |
7 #include "app/drag_drop_types.h" | 7 #include "app/drag_drop_types.h" |
8 #include "app/gfx/canvas.h" | 8 #include "app/gfx/canvas.h" |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/os_exchange_data.h" | 10 #include "app/os_exchange_data.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // Returned from BrowserView::GetClassName. | 120 // Returned from BrowserView::GetClassName. |
121 static const char kBrowserViewClassName[] = "browser/views/BrowserView"; | 121 static const char kBrowserViewClassName[] = "browser/views/BrowserView"; |
122 | 122 |
123 | 123 |
124 /////////////////////////////////////////////////////////////////////////////// | 124 /////////////////////////////////////////////////////////////////////////////// |
125 // BookmarkExtensionBackground, private: | 125 // BookmarkExtensionBackground, private: |
126 // This object serves as the views::Background object which is used to layout | 126 // This object serves as the views::Background object which is used to layout |
127 // and paint the bookmark bar. | 127 // and paint the bookmark bar. |
128 class BookmarkExtensionBackground : public views::Background { | 128 class BookmarkExtensionBackground : public views::Background { |
129 public: | 129 public: |
130 explicit BookmarkExtensionBackground(BrowserView* browser_view); | 130 explicit BookmarkExtensionBackground(BrowserView* browser_view, |
| 131 DetachableToolbarView* host_view); |
131 | 132 |
132 // View methods overridden from views:Background. | 133 // View methods overridden from views:Background. |
133 virtual void Paint(gfx::Canvas* canvas, views::View* view) const; | 134 virtual void Paint(gfx::Canvas* canvas, views::View* view) const; |
134 | 135 |
135 private: | 136 private: |
136 // Paint the theme background with the proper alignment. | 137 BrowserView* browser_view_; |
137 void PaintThemeBackgroundTopAligned(gfx::Canvas* canvas, | |
138 SkBitmap* ntp_background, int tiling, int alignment) const; | |
139 void PaintThemeBackgroundBottomAligned(gfx::Canvas* canvas, | |
140 SkBitmap* ntp_background, int tiling, int alignment) const; | |
141 | 138 |
142 BrowserView* browser_view_; | 139 // The view hosting this background. |
| 140 DetachableToolbarView* host_view_; |
143 | 141 |
144 DISALLOW_COPY_AND_ASSIGN(BookmarkExtensionBackground); | 142 DISALLOW_COPY_AND_ASSIGN(BookmarkExtensionBackground); |
145 }; | 143 }; |
146 | 144 |
147 BookmarkExtensionBackground::BookmarkExtensionBackground( | 145 BookmarkExtensionBackground::BookmarkExtensionBackground( |
148 BrowserView* browser_view) | 146 BrowserView* browser_view, |
149 : browser_view_(browser_view) { | 147 DetachableToolbarView* host_view) |
| 148 : browser_view_(browser_view), |
| 149 host_view_(host_view) { |
150 } | 150 } |
151 | 151 |
152 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, | 152 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, |
153 views::View* view) const { | 153 views::View* view) const { |
154 // Paint the bookmark bar. | 154 ThemeProvider* tp = host_view_->GetThemeProvider(); |
155 BookmarkBarView* bookmark_bar_view = browser_view_->GetBookmarkBarView(); | 155 if (host_view_->IsDetached()) { |
156 if (bookmark_bar_view->IsDetachedStyle()) { | |
157 // Draw the background to match the new tab page. | 156 // Draw the background to match the new tab page. |
158 ThemeProvider* tp = bookmark_bar_view->GetThemeProvider(); | 157 DetachableToolbarView::PaintBackgroundDetachedMode(canvas, host_view_); |
159 canvas->FillRectInt( | |
160 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND), | |
161 0, 0, bookmark_bar_view->width(), bookmark_bar_view->height()); | |
162 | |
163 if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { | |
164 int tiling = BrowserThemeProvider::NO_REPEAT; | |
165 tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_TILING, | |
166 &tiling); | |
167 int alignment; | |
168 if (tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, | |
169 &alignment)) { | |
170 SkBitmap* ntp_background = tp->GetBitmapNamed( | |
171 IDR_THEME_NTP_BACKGROUND); | |
172 | |
173 if (alignment & BrowserThemeProvider::ALIGN_TOP) { | |
174 PaintThemeBackgroundTopAligned(canvas, ntp_background, tiling, | |
175 alignment); | |
176 } else { | |
177 PaintThemeBackgroundBottomAligned(canvas, ntp_background, tiling, | |
178 alignment); | |
179 } | |
180 } | |
181 } | |
182 | |
183 // Draw the 'bottom' of the toolbar above our bubble. | |
184 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 0, 0, | |
185 bookmark_bar_view->width(), 1); | |
186 | 158 |
187 SkRect rect; | 159 SkRect rect; |
188 | 160 |
189 // As 'hidden' according to the animation is the full in-tab state, | 161 // As 'hidden' according to the animation is the full in-tab state, |
190 // we invert the value - when current_state is at '0', we expect the | 162 // we invert the value - when current_state is at '0', we expect the |
191 // bar to be docked. | 163 // bar to be docked. |
192 double current_state = 1 - bookmark_bar_view->GetSizeAnimationValue(); | 164 double current_state = 1 - host_view_->GetAnimationValue(); |
193 | 165 |
194 // The 0.5 is to correct for Skia's "draw on pixel boundaries"ness. | 166 // The 0.5 is to correct for Skia's "draw on pixel boundaries"ness. |
195 double h_padding = static_cast<double> | 167 double h_padding = static_cast<double> |
196 (BookmarkBarView::kNewtabHorizontalPadding) * current_state; | 168 (BookmarkBarView::kNewtabHorizontalPadding) * current_state; |
197 double v_padding = static_cast<double> | 169 double v_padding = static_cast<double> |
198 (BookmarkBarView::kNewtabVerticalPadding) * current_state; | 170 (BookmarkBarView::kNewtabVerticalPadding) * current_state; |
199 rect.set(SkDoubleToScalar(h_padding - 0.5), | 171 double roundness = 0; |
200 SkDoubleToScalar(v_padding - 0.5), | |
201 SkDoubleToScalar(bookmark_bar_view->width() - h_padding - 0.5), | |
202 SkDoubleToScalar(bookmark_bar_view->height() - v_padding - 0.5)); | |
203 | 172 |
204 double roundness = static_cast<double> | 173 DetachableToolbarView::CalculateContentArea(current_state, |
205 (kNewtabBarRoundness) * current_state; | 174 h_padding, v_padding, |
206 | 175 &rect, &roundness, host_view_); |
207 // Draw our background. | 176 DetachableToolbarView::PaintContentAreaBackground( |
208 SkPaint paint; | 177 canvas, tp, rect, roundness); |
209 paint.setAntiAlias(true); | 178 DetachableToolbarView::PaintContentAreaBorder(canvas, tp, rect, roundness); |
210 paint.setColor(bookmark_bar_view->GetThemeProvider()->GetColor( | 179 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); |
211 BrowserThemeProvider::COLOR_TOOLBAR)); | |
212 | |
213 canvas->drawRoundRect(rect, | |
214 SkDoubleToScalar(roundness), | |
215 SkDoubleToScalar(roundness), paint); | |
216 | |
217 // Draw border | |
218 SkPaint border_paint; | |
219 border_paint.setColor(bookmark_bar_view->GetThemeProvider()->GetColor( | |
220 BrowserThemeProvider::COLOR_NTP_HEADER)); | |
221 border_paint.setStyle(SkPaint::kStroke_Style); | |
222 border_paint.setAlpha(96); | |
223 border_paint.setAntiAlias(true); | |
224 | |
225 canvas->drawRoundRect(rect, | |
226 SkDoubleToScalar(roundness), | |
227 SkDoubleToScalar(roundness), border_paint); | |
228 } else { | 180 } else { |
229 gfx::Rect bounds = bookmark_bar_view->GetBounds(views::View:: | 181 DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_); |
230 APPLY_MIRRORING_TRANSFORMATION); | 182 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); |
231 | |
232 SkColor theme_toolbar_color = | |
233 bookmark_bar_view->GetThemeProvider()->GetColor(BrowserThemeProvider:: | |
234 COLOR_TOOLBAR); | |
235 canvas->FillRectInt(theme_toolbar_color, 0, 0, | |
236 bookmark_bar_view->width(), | |
237 bookmark_bar_view->height()); | |
238 | |
239 canvas->TileImageInt( | |
240 *browser_view_->GetBookmarkBarView()->GetThemeProvider()-> | |
241 GetBitmapNamed(IDR_THEME_TOOLBAR), | |
242 bookmark_bar_view->GetParent()->GetBounds(views:: | |
243 View::APPLY_MIRRORING_TRANSFORMATION).x() + bounds.x(), bounds.y(), | |
244 0, 0, | |
245 bookmark_bar_view->width(), | |
246 bookmark_bar_view->height()); | |
247 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, | |
248 0, | |
249 bookmark_bar_view->height() - 1, | |
250 bookmark_bar_view->width(), 1); | |
251 } | |
252 } | |
253 | |
254 void BookmarkExtensionBackground::PaintThemeBackgroundTopAligned( | |
255 gfx::Canvas* canvas, SkBitmap* ntp_background, int tiling, | |
256 int alignment) const { | |
257 BookmarkBarView* bookmark_bar_view = browser_view_->GetBookmarkBarView(); | |
258 if (alignment & BrowserThemeProvider::ALIGN_LEFT) { | |
259 if (tiling == BrowserThemeProvider::REPEAT) | |
260 canvas->TileImageInt(*ntp_background, 0, 0, | |
261 bookmark_bar_view->width(), bookmark_bar_view->height()); | |
262 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
263 canvas->TileImageInt(*ntp_background, 0, 0, | |
264 bookmark_bar_view->width(), | |
265 ntp_background->height()); | |
266 else | |
267 canvas->TileImageInt(*ntp_background, 0, 0, | |
268 ntp_background->width(), ntp_background->height()); | |
269 | |
270 } else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) { | |
271 int x_pos = bookmark_bar_view->width() % ntp_background->width() - | |
272 ntp_background->width(); | |
273 if (tiling == BrowserThemeProvider::REPEAT) | |
274 canvas->TileImageInt(*ntp_background, x_pos, 0, | |
275 bookmark_bar_view->width() + ntp_background->width(), | |
276 bookmark_bar_view->height()); | |
277 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
278 canvas->TileImageInt(*ntp_background, x_pos, | |
279 0, bookmark_bar_view->width() + ntp_background->width(), | |
280 ntp_background->height()); | |
281 else | |
282 canvas->TileImageInt(*ntp_background, | |
283 bookmark_bar_view->width() - ntp_background->width(), 0, | |
284 ntp_background->width(), ntp_background->height()); | |
285 | |
286 } else { // ALIGN == CENTER | |
287 int x_pos = bookmark_bar_view->width() > ntp_background->width() ? | |
288 ((bookmark_bar_view->width() / 2 - ntp_background->width() / 2) % | |
289 ntp_background->width()) - ntp_background->width() : | |
290 bookmark_bar_view->width() / 2 - ntp_background->width() / 2; | |
291 if (tiling == BrowserThemeProvider::REPEAT) | |
292 canvas->TileImageInt(*ntp_background, x_pos, 0, | |
293 bookmark_bar_view->width() + ntp_background->width(), | |
294 bookmark_bar_view->height()); | |
295 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
296 canvas->TileImageInt(*ntp_background, x_pos, 0, | |
297 bookmark_bar_view->width() + ntp_background->width(), | |
298 ntp_background->height()); | |
299 else | |
300 canvas->TileImageInt(*ntp_background, | |
301 bookmark_bar_view->width() / 2 - ntp_background->width() / 2, | |
302 0, ntp_background->width(), ntp_background->height()); | |
303 } | |
304 } | |
305 | |
306 void BookmarkExtensionBackground::PaintThemeBackgroundBottomAligned( | |
307 gfx::Canvas* canvas, SkBitmap* ntp_background, int tiling, | |
308 int alignment) const { | |
309 BookmarkBarView* bookmark_bar_view = browser_view_->GetBookmarkBarView(); | |
310 int browser_height = bookmark_bar_view->GetParent()->GetBounds( | |
311 views::View::APPLY_MIRRORING_TRANSFORMATION).height(); | |
312 int border_width = 5; | |
313 int y_pos = ((tiling == BrowserThemeProvider::REPEAT_X) || | |
314 (tiling == BrowserThemeProvider::NO_REPEAT)) ? | |
315 browser_height - ntp_background->height() - bookmark_bar_view->height() - | |
316 border_width : | |
317 browser_height % ntp_background->height() - bookmark_bar_view->height() - | |
318 border_width - ntp_background->height(); | |
319 | |
320 if (alignment & BrowserThemeProvider::ALIGN_LEFT) { | |
321 if (tiling == BrowserThemeProvider::REPEAT) | |
322 canvas->TileImageInt(*ntp_background, 0, y_pos, | |
323 bookmark_bar_view->width(), | |
324 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
325 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
326 canvas->TileImageInt(*ntp_background, 0, y_pos, | |
327 bookmark_bar_view->width(), ntp_background->height()); | |
328 else if (tiling == BrowserThemeProvider::REPEAT_Y) | |
329 canvas->TileImageInt(*ntp_background, 0, y_pos, | |
330 ntp_background->width(), | |
331 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
332 else | |
333 canvas->TileImageInt(*ntp_background, 0, y_pos, ntp_background->width(), | |
334 ntp_background->height()); | |
335 | |
336 } else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) { | |
337 int x_pos = bookmark_bar_view->width() % ntp_background->width() - | |
338 ntp_background->width(); | |
339 if (tiling == BrowserThemeProvider::REPEAT) | |
340 canvas->TileImageInt(*ntp_background, x_pos, y_pos, | |
341 bookmark_bar_view->width() + ntp_background->width(), | |
342 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
343 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
344 canvas->TileImageInt(*ntp_background, x_pos, y_pos, | |
345 bookmark_bar_view->width() + ntp_background->width(), | |
346 ntp_background->height()); | |
347 else if (tiling == BrowserThemeProvider::REPEAT_Y) | |
348 canvas->TileImageInt(*ntp_background, bookmark_bar_view->width() - | |
349 ntp_background->width(), y_pos, ntp_background->width(), | |
350 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
351 else | |
352 canvas->TileImageInt(*ntp_background, | |
353 bookmark_bar_view->width() - ntp_background->width(), | |
354 y_pos, ntp_background->width(), ntp_background->height()); | |
355 | |
356 } else { // ALIGN == CENTER | |
357 int x_pos = bookmark_bar_view->width() > ntp_background->width() ? | |
358 ((bookmark_bar_view->width() / 2 - ntp_background->width() / 2) % | |
359 ntp_background->width()) - ntp_background->width() : | |
360 bookmark_bar_view->width() / 2 - ntp_background->width() / 2; | |
361 if (tiling == BrowserThemeProvider::REPEAT) | |
362 canvas->TileImageInt(*ntp_background, x_pos, y_pos, | |
363 bookmark_bar_view->width() + ntp_background->width(), | |
364 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
365 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
366 canvas->TileImageInt(*ntp_background, x_pos, y_pos, | |
367 bookmark_bar_view->width() + ntp_background->width(), | |
368 ntp_background->height()); | |
369 else if (tiling == BrowserThemeProvider::REPEAT_Y) | |
370 canvas->TileImageInt(*ntp_background, | |
371 bookmark_bar_view->width() / 2 - ntp_background->width() / 2, | |
372 y_pos, ntp_background->width(), | |
373 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
374 else | |
375 canvas->TileImageInt(*ntp_background, | |
376 bookmark_bar_view->width() / 2 - ntp_background->width() / 2, | |
377 y_pos, ntp_background->width(), ntp_background->height()); | |
378 } | 183 } |
379 } | 184 } |
380 | 185 |
381 /////////////////////////////////////////////////////////////////////////////// | 186 /////////////////////////////////////////////////////////////////////////////// |
382 // ResizeCorner, private: | 187 // ResizeCorner, private: |
383 | 188 |
384 class ResizeCorner : public views::View { | 189 class ResizeCorner : public views::View { |
385 public: | 190 public: |
386 ResizeCorner() { } | 191 ResizeCorner() { } |
387 | 192 |
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 1627 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
1823 contents_split_->set_background( | 1628 contents_split_->set_background( |
1824 views::Background::CreateSolidBackground(bg_color)); | 1629 views::Background::CreateSolidBackground(bg_color)); |
1825 AddChildView(contents_split_); | 1630 AddChildView(contents_split_); |
1826 set_contents_view(contents_split_); | 1631 set_contents_view(contents_split_); |
1827 | 1632 |
1828 status_bubble_.reset(new StatusBubbleViews(GetWidget())); | 1633 status_bubble_.reset(new StatusBubbleViews(GetWidget())); |
1829 | 1634 |
1830 if (browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF)) { | 1635 if (browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF)) { |
1831 extension_shelf_ = new ExtensionShelf(browser_.get()); | 1636 extension_shelf_ = new ExtensionShelf(browser_.get()); |
| 1637 extension_shelf_->set_background( |
| 1638 new BookmarkExtensionBackground(this, extension_shelf_)); |
1832 extension_shelf_-> | 1639 extension_shelf_-> |
1833 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_EXTENSIONS)); | 1640 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_EXTENSIONS)); |
1834 AddChildView(extension_shelf_); | 1641 AddChildView(extension_shelf_); |
1835 } | 1642 } |
1836 | 1643 |
1837 #if defined(OS_WIN) | 1644 #if defined(OS_WIN) |
1838 InitSystemMenu(); | 1645 InitSystemMenu(); |
1839 | 1646 |
1840 // Create a custom JumpList and add it to an observer of TabRestoreService | 1647 // Create a custom JumpList and add it to an observer of TabRestoreService |
1841 // so we can update the custom JumpList when a tab is added or removed. | 1648 // so we can update the custom JumpList when a tab is added or removed. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 toolbar_->SetBounds(0, y, browser_view_width, height); | 1700 toolbar_->SetBounds(0, y, browser_view_width, height); |
1894 return y + height; | 1701 return y + height; |
1895 } | 1702 } |
1896 | 1703 |
1897 int BrowserView::LayoutBookmarkAndInfoBars(int top) { | 1704 int BrowserView::LayoutBookmarkAndInfoBars(int top) { |
1898 find_bar_y_ = top + y() - 1; | 1705 find_bar_y_ = top + y() - 1; |
1899 if (active_bookmark_bar_) { | 1706 if (active_bookmark_bar_) { |
1900 // If we're showing the Bookmark bar in detached style, then we need to show | 1707 // If we're showing the Bookmark bar in detached style, then we need to show |
1901 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled | 1708 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled |
1902 // to look like it's part of the page. | 1709 // to look like it's part of the page. |
1903 if (bookmark_bar_view_->IsDetachedStyle()) | 1710 if (bookmark_bar_view_->IsDetached()) |
1904 return LayoutTopBar(LayoutInfoBar(top)); | 1711 return LayoutTopBar(LayoutInfoBar(top)); |
1905 // Otherwise, Bookmark bar first, Info bar second. | 1712 // Otherwise, Bookmark bar first, Info bar second. |
1906 top = LayoutTopBar(top); | 1713 top = LayoutTopBar(top); |
1907 } | 1714 } |
1908 find_bar_y_ = top + y() - 1; | 1715 find_bar_y_ = top + y() - 1; |
1909 return LayoutInfoBar(top); | 1716 return LayoutInfoBar(top); |
1910 } | 1717 } |
1911 | 1718 |
1912 int BrowserView::LayoutTopBar(int top) { | 1719 int BrowserView::LayoutTopBar(int top) { |
1913 // This method lays out the the bookmark bar, and, if required, the extension | 1720 // This method lays out the the bookmark bar, and, if required, the extension |
1914 // shelf by its side. The bookmark bar appears on the right of the extension | 1721 // shelf by its side. The bookmark bar appears on the right of the extension |
1915 // shelf. If there are too many bookmark items and extension toolstrips to fit | 1722 // shelf. If there are too many bookmark items and extension toolstrips to fit |
1916 // in the single bar, some compromises are made as follows: | 1723 // in the single bar, some compromises are made as follows: |
1917 // 1. The bookmark bar is shrunk till it reaches the minimum width. | 1724 // 1. The bookmark bar is shrunk till it reaches the minimum width. |
1918 // 2. After reaching the minimum width, the bookmark bar width is kept fixed - | 1725 // 2. After reaching the minimum width, the bookmark bar width is kept fixed - |
1919 // the extension shelf bar width is reduced. | 1726 // the extension shelf bar width is reduced. |
1920 DCHECK(active_bookmark_bar_); | 1727 DCHECK(active_bookmark_bar_); |
1921 int y = top, x = 0; | 1728 int y = top, x = 0; |
1922 if (!IsBookmarkBarVisible()) { | 1729 if (!IsBookmarkBarVisible()) { |
1923 bookmark_bar_view_->SetVisible(false); | 1730 bookmark_bar_view_->SetVisible(false); |
1924 bookmark_bar_view_->SetBounds(0, y, width(), 0); | 1731 bookmark_bar_view_->SetBounds(0, y, width(), 0); |
1925 if (ShowExtensionsOnTop()) | 1732 if (extension_shelf_->IsOnTop()) |
1926 extension_shelf_->SetVisible(false); | 1733 extension_shelf_->SetVisible(false); |
1927 return y; | 1734 return y; |
1928 } | 1735 } |
1929 | 1736 |
1930 int bookmark_bar_height = bookmark_bar_view_->GetPreferredSize().height(); | 1737 int bookmark_bar_height = bookmark_bar_view_->GetPreferredSize().height(); |
1931 y -= kSeparationLineHeight + (bookmark_bar_view_->IsDetachedStyle() ? | 1738 y -= kSeparationLineHeight + (bookmark_bar_view_->IsDetached() ? |
1932 0 : bookmark_bar_view_->GetToolbarOverlap(false)); | 1739 0 : bookmark_bar_view_->GetToolbarOverlap(false)); |
1933 | 1740 |
1934 if (ShowExtensionsOnTop()) { | 1741 if (extension_shelf_->IsOnTop()) { |
1935 if (!bookmark_bar_view_->IsDetachedStyle()) { | 1742 if (!bookmark_bar_view_->IsDetached()) { |
1936 int extension_shelf_width = | 1743 int extension_shelf_width = |
1937 extension_shelf_->GetPreferredSize().width(); | 1744 extension_shelf_->GetPreferredSize().width(); |
1938 int bookmark_bar_given_width = width() - extension_shelf_width; | 1745 int bookmark_bar_given_width = width() - extension_shelf_width; |
1939 int minimum_allowed_bookmark_bar_width = | 1746 int minimum_allowed_bookmark_bar_width = |
1940 bookmark_bar_view_->GetMinimumSize().width(); | 1747 bookmark_bar_view_->GetMinimumSize().width(); |
1941 if (bookmark_bar_given_width < minimum_allowed_bookmark_bar_width) { | 1748 if (bookmark_bar_given_width < minimum_allowed_bookmark_bar_width) { |
1942 // The bookmark bar cannot compromise on its width any more. The | 1749 // The bookmark bar cannot compromise on its width any more. The |
1943 // extension shelf needs to shrink now. | 1750 // extension shelf needs to shrink now. |
1944 extension_shelf_width = | 1751 extension_shelf_width = |
1945 width() - minimum_allowed_bookmark_bar_width; | 1752 width() - minimum_allowed_bookmark_bar_width; |
1946 } | 1753 } |
1947 extension_shelf_->SetVisible(true); | 1754 extension_shelf_->SetVisible(true); |
1948 extension_shelf_->SetBounds(x, y, extension_shelf_width, | 1755 extension_shelf_->SetBounds(x, y, extension_shelf_width, |
1949 bookmark_bar_height); | 1756 bookmark_bar_height); |
1950 x += extension_shelf_width; | 1757 x += extension_shelf_width; |
1951 } else { | 1758 } else { |
1952 // TODO (sidchat): For detached style bookmark bar, set the extensions | 1759 // TODO(sidchat): For detached style bookmark bar, set the extensions |
1953 // shelf in a better position. Issue = 20741. | 1760 // shelf in a better position. Issue = 20741. |
1954 extension_shelf_->SetVisible(false); | 1761 extension_shelf_->SetVisible(false); |
1955 } | 1762 } |
1956 } | 1763 } |
1957 | 1764 |
1958 bookmark_bar_view_->SetVisible(true); | 1765 bookmark_bar_view_->SetVisible(true); |
1959 bookmark_bar_view_->SetBounds(x, y, width() - x, bookmark_bar_height); | 1766 bookmark_bar_view_->SetBounds(x, y, width() - x, bookmark_bar_height); |
1960 return y + bookmark_bar_height; | 1767 return y + bookmark_bar_height; |
1961 } | 1768 } |
1962 | 1769 |
1963 int BrowserView::LayoutInfoBar(int top) { | 1770 int BrowserView::LayoutInfoBar(int top) { |
1964 bool visible = browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR); | 1771 bool visible = browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR); |
1965 int height = visible ? infobar_container_->GetPreferredSize().height() : 0; | 1772 int height = visible ? infobar_container_->GetPreferredSize().height() : 0; |
1966 infobar_container_->SetVisible(visible); | 1773 infobar_container_->SetVisible(visible); |
1967 infobar_container_->SetBounds(0, top, width(), height); | 1774 infobar_container_->SetBounds(0, top, width(), height); |
1968 return top + height; | 1775 return top + height; |
1969 } | 1776 } |
1970 | 1777 |
1971 void BrowserView::LayoutTabContents(int top, int bottom) { | 1778 void BrowserView::LayoutTabContents(int top, int bottom) { |
1972 contents_split_->SetBounds(0, top, width(), bottom - top); | 1779 contents_split_->SetBounds(0, top, width(), bottom - top); |
1973 } | 1780 } |
1974 | 1781 |
1975 int BrowserView::LayoutExtensionAndDownloadShelves() { | 1782 int BrowserView::LayoutExtensionAndDownloadShelves() { |
1976 // If we're showing the Bookmark bar in detached style, then we need to show | 1783 // If we're showing the Bookmark bar in detached style, then we need to show |
1977 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled | 1784 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled |
1978 // to look like it's part of the page. | 1785 // to look like it's part of the page. |
1979 int bottom = height(); | 1786 int bottom = height(); |
1980 if (extension_shelf_) { | 1787 if (extension_shelf_) { |
1981 if (extension_shelf_->IsDetachedStyle()) { | 1788 if (extension_shelf_->IsDetached()) { |
1982 bottom = LayoutDownloadShelf(bottom); | 1789 bottom = LayoutDownloadShelf(bottom); |
1983 return LayoutExtensionShelf(bottom); | 1790 return LayoutExtensionShelf(bottom); |
1984 } | 1791 } |
1985 // Otherwise, Extension shelf first, Download shelf second. | 1792 // Otherwise, Extension shelf first, Download shelf second. |
1986 bottom = LayoutExtensionShelf(bottom); | 1793 bottom = LayoutExtensionShelf(bottom); |
1987 } | 1794 } |
1988 return LayoutDownloadShelf(bottom); | 1795 return LayoutDownloadShelf(bottom); |
1989 } | 1796 } |
1990 | 1797 |
1991 int BrowserView::LayoutDownloadShelf(int bottom) { | 1798 int BrowserView::LayoutDownloadShelf(int bottom) { |
(...skipping 18 matching lines...) Expand all Loading... |
2010 // frame. | 1817 // frame. |
2011 int overlap = StatusBubbleViews::kShadowThickness + | 1818 int overlap = StatusBubbleViews::kShadowThickness + |
2012 (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness); | 1819 (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness); |
2013 int height = status_bubble_->GetPreferredSize().height(); | 1820 int height = status_bubble_->GetPreferredSize().height(); |
2014 gfx::Point origin(-overlap, top - height + overlap); | 1821 gfx::Point origin(-overlap, top - height + overlap); |
2015 ConvertPointToView(this, GetParent(), &origin); | 1822 ConvertPointToView(this, GetParent(), &origin); |
2016 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height); | 1823 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height); |
2017 } | 1824 } |
2018 | 1825 |
2019 int BrowserView::LayoutExtensionShelf(int bottom) { | 1826 int BrowserView::LayoutExtensionShelf(int bottom) { |
2020 if (ShowExtensionsOnTop()) | 1827 if (!extension_shelf_ || extension_shelf_->IsOnTop()) |
2021 return bottom; | 1828 return bottom; |
2022 | 1829 |
2023 if (extension_shelf_) { | 1830 if (extension_shelf_) { |
2024 bool visible = browser_->SupportsWindowFeature( | 1831 bool visible = browser_->SupportsWindowFeature( |
2025 Browser::FEATURE_EXTENSIONSHELF); | 1832 Browser::FEATURE_EXTENSIONSHELF); |
2026 int height = | 1833 int height = |
2027 visible ? extension_shelf_->GetPreferredSize().height() : 0; | 1834 visible ? extension_shelf_->GetPreferredSize().height() : 0; |
2028 extension_shelf_->SetVisible(visible); | 1835 extension_shelf_->SetVisible(visible); |
2029 extension_shelf_->SetBounds(0, bottom - height, width(), height); | 1836 extension_shelf_->SetBounds(0, bottom - height, width(), height); |
2030 extension_shelf_->Layout(); | 1837 extension_shelf_->Layout(); |
2031 bottom -= height; | 1838 bottom -= height; |
2032 } | 1839 } |
2033 return bottom; | 1840 return bottom; |
2034 } | 1841 } |
2035 | 1842 |
2036 bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) { | 1843 bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) { |
2037 views::View* new_bookmark_bar_view = NULL; | 1844 views::View* new_bookmark_bar_view = NULL; |
2038 if (browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) | 1845 if (browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) |
2039 && contents) { | 1846 && contents) { |
2040 if (!bookmark_bar_view_.get()) { | 1847 if (!bookmark_bar_view_.get()) { |
2041 bookmark_bar_view_.reset(new BookmarkBarView(contents->profile(), | 1848 bookmark_bar_view_.reset(new BookmarkBarView(contents->profile(), |
2042 browser_.get())); | 1849 browser_.get())); |
2043 bookmark_bar_view_->SetParentOwned(false); | 1850 bookmark_bar_view_->SetParentOwned(false); |
2044 bookmark_bar_view_->set_background(new BookmarkExtensionBackground(this)); | 1851 bookmark_bar_view_->set_background( |
| 1852 new BookmarkExtensionBackground(this, bookmark_bar_view_.get())); |
2045 } else { | 1853 } else { |
2046 bookmark_bar_view_->SetProfile(contents->profile()); | 1854 bookmark_bar_view_->SetProfile(contents->profile()); |
2047 } | 1855 } |
2048 bookmark_bar_view_->SetPageNavigator(contents); | 1856 bookmark_bar_view_->SetPageNavigator(contents); |
2049 bookmark_bar_view_-> | 1857 bookmark_bar_view_-> |
2050 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_BOOKMARKS)); | 1858 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_BOOKMARKS)); |
2051 new_bookmark_bar_view = bookmark_bar_view_.get(); | 1859 new_bookmark_bar_view = bookmark_bar_view_.get(); |
2052 } | 1860 } |
2053 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); | 1861 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); |
2054 } | 1862 } |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 ticker_.Start(); | 2128 ticker_.Start(); |
2321 | 2129 |
2322 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout, | 2130 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout, |
2323 plugin_message_response_timeout); | 2131 plugin_message_response_timeout); |
2324 pref_service->SetInteger(prefs::kHungPluginDetectFrequency, | 2132 pref_service->SetInteger(prefs::kHungPluginDetectFrequency, |
2325 hung_plugin_detect_freq); | 2133 hung_plugin_detect_freq); |
2326 } | 2134 } |
2327 #endif | 2135 #endif |
2328 } | 2136 } |
2329 | 2137 |
2330 bool BrowserView::ShowExtensionsOnTop() { | |
2331 return extension_shelf_ && CommandLine::ForCurrentProcess()->HasSwitch( | |
2332 switches::kShowExtensionsOnTop); | |
2333 } | |
2334 | |
2335 // static | 2138 // static |
2336 void BrowserView::InitClass() { | 2139 void BrowserView::InitClass() { |
2337 static bool initialized = false; | 2140 static bool initialized = false; |
2338 if (!initialized) { | 2141 if (!initialized) { |
2339 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 2142 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
2340 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); | 2143 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
2341 initialized = true; | 2144 initialized = true; |
2342 } | 2145 } |
2343 } | 2146 } |
2344 | 2147 |
2345 // static | 2148 // static |
2346 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2149 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
2347 // Create the view and the frame. The frame will attach itself via the view | 2150 // Create the view and the frame. The frame will attach itself via the view |
2348 // so we don't need to do anything with the pointer. | 2151 // so we don't need to do anything with the pointer. |
2349 BrowserView* view = new BrowserView(browser); | 2152 BrowserView* view = new BrowserView(browser); |
2350 BrowserFrame::Create(view, browser->profile()); | 2153 BrowserFrame::Create(view, browser->profile()); |
2351 return view; | 2154 return view; |
2352 } | 2155 } |
2353 | 2156 |
2354 // static | 2157 // static |
2355 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2158 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
2356 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2159 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
2357 } | 2160 } |
2358 | 2161 |
2359 // static | 2162 // static |
2360 void BrowserList::AllBrowsersClosed() { | 2163 void BrowserList::AllBrowsersClosed() { |
2361 views::Window::CloseAllSecondaryWindows(); | 2164 views::Window::CloseAllSecondaryWindows(); |
2362 } | 2165 } |
OLD | NEW |