| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Returned from BrowserView::GetClassName. | 117 // Returned from BrowserView::GetClassName. |
| 118 static const char kBrowserViewClassName[] = "browser/views/BrowserView"; | 118 static const char kBrowserViewClassName[] = "browser/views/BrowserView"; |
| 119 | 119 |
| 120 | 120 |
| 121 /////////////////////////////////////////////////////////////////////////////// | 121 /////////////////////////////////////////////////////////////////////////////// |
| 122 // BookmarkExtensionBackground, private: | 122 // BookmarkExtensionBackground, private: |
| 123 // This object serves as the views::Background object which is used to layout | 123 // This object serves as the views::Background object which is used to layout |
| 124 // and paint the bookmark bar. | 124 // and paint the bookmark bar. |
| 125 class BookmarkExtensionBackground : public views::Background { | 125 class BookmarkExtensionBackground : public views::Background { |
| 126 public: | 126 public: |
| 127 explicit BookmarkExtensionBackground(BrowserView* browser_view); | 127 explicit BookmarkExtensionBackground(BrowserView* browser_view, |
| 128 DetachableToolbarView* host_view); |
| 128 | 129 |
| 129 // View methods overridden from views:Background. | 130 // View methods overridden from views:Background. |
| 130 virtual void Paint(gfx::Canvas* canvas, views::View* view) const; | 131 virtual void Paint(gfx::Canvas* canvas, views::View* view) const; |
| 131 | 132 |
| 132 private: | 133 private: |
| 133 // Paint the theme background with the proper alignment. | 134 BrowserView* browser_view_; |
| 134 void PaintThemeBackgroundTopAligned(gfx::Canvas* canvas, | |
| 135 SkBitmap* ntp_background, int tiling, int alignment) const; | |
| 136 void PaintThemeBackgroundBottomAligned(gfx::Canvas* canvas, | |
| 137 SkBitmap* ntp_background, int tiling, int alignment) const; | |
| 138 | 135 |
| 139 BrowserView* browser_view_; | 136 // The view hosting this background. |
| 137 DetachableToolbarView* host_view_; |
| 140 | 138 |
| 141 DISALLOW_COPY_AND_ASSIGN(BookmarkExtensionBackground); | 139 DISALLOW_COPY_AND_ASSIGN(BookmarkExtensionBackground); |
| 142 }; | 140 }; |
| 143 | 141 |
| 144 BookmarkExtensionBackground::BookmarkExtensionBackground( | 142 BookmarkExtensionBackground::BookmarkExtensionBackground( |
| 145 BrowserView* browser_view) | 143 BrowserView* browser_view, |
| 146 : browser_view_(browser_view) { | 144 DetachableToolbarView* host_view) |
| 145 : browser_view_(browser_view), |
| 146 host_view_(host_view) { |
| 147 } | 147 } |
| 148 | 148 |
| 149 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, | 149 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, |
| 150 views::View* view) const { | 150 views::View* view) const { |
| 151 // Paint the bookmark bar. | 151 ThemeProvider* tp = host_view_->GetThemeProvider(); |
| 152 BookmarkBarView* bookmark_bar_view = browser_view_->GetBookmarkBarView(); | 152 if (host_view_->IsDetached()) { |
| 153 if (bookmark_bar_view->IsDetachedStyle()) { | |
| 154 // Draw the background to match the new tab page. | 153 // Draw the background to match the new tab page. |
| 155 ThemeProvider* tp = bookmark_bar_view->GetThemeProvider(); | 154 DetachableToolbarView::PaintBackgroundDetachedMode(canvas, host_view_); |
| 156 canvas->FillRectInt( | |
| 157 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND), | |
| 158 0, 0, bookmark_bar_view->width(), bookmark_bar_view->height()); | |
| 159 | |
| 160 if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { | |
| 161 int tiling = BrowserThemeProvider::NO_REPEAT; | |
| 162 tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_TILING, | |
| 163 &tiling); | |
| 164 int alignment; | |
| 165 if (tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, | |
| 166 &alignment)) { | |
| 167 SkBitmap* ntp_background = tp->GetBitmapNamed( | |
| 168 IDR_THEME_NTP_BACKGROUND); | |
| 169 | |
| 170 if (alignment & BrowserThemeProvider::ALIGN_TOP) { | |
| 171 PaintThemeBackgroundTopAligned(canvas, ntp_background, tiling, | |
| 172 alignment); | |
| 173 } else { | |
| 174 PaintThemeBackgroundBottomAligned(canvas, ntp_background, tiling, | |
| 175 alignment); | |
| 176 } | |
| 177 } | |
| 178 } | |
| 179 | |
| 180 // Draw the 'bottom' of the toolbar above our bubble. | |
| 181 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 0, 0, | |
| 182 bookmark_bar_view->width(), 1); | |
| 183 | 155 |
| 184 SkRect rect; | 156 SkRect rect; |
| 185 | 157 |
| 186 // As 'hidden' according to the animation is the full in-tab state, | 158 // As 'hidden' according to the animation is the full in-tab state, |
| 187 // we invert the value - when current_state is at '0', we expect the | 159 // we invert the value - when current_state is at '0', we expect the |
| 188 // bar to be docked. | 160 // bar to be docked. |
| 189 double current_state = 1 - bookmark_bar_view->GetSizeAnimationValue(); | 161 double current_state = 1 - host_view_->GetAnimationValue(); |
| 190 | 162 |
| 191 // The 0.5 is to correct for Skia's "draw on pixel boundaries"ness. | 163 // The 0.5 is to correct for Skia's "draw on pixel boundaries"ness. |
| 192 double h_padding = static_cast<double> | 164 double h_padding = static_cast<double> |
| 193 (BookmarkBarView::kNewtabHorizontalPadding) * current_state; | 165 (BookmarkBarView::kNewtabHorizontalPadding) * current_state; |
| 194 double v_padding = static_cast<double> | 166 double v_padding = static_cast<double> |
| 195 (BookmarkBarView::kNewtabVerticalPadding) * current_state; | 167 (BookmarkBarView::kNewtabVerticalPadding) * current_state; |
| 196 rect.set(SkDoubleToScalar(h_padding - 0.5), | 168 double roundness = 0; |
| 197 SkDoubleToScalar(v_padding - 0.5), | |
| 198 SkDoubleToScalar(bookmark_bar_view->width() - h_padding - 0.5), | |
| 199 SkDoubleToScalar(bookmark_bar_view->height() - v_padding - 0.5)); | |
| 200 | 169 |
| 201 double roundness = static_cast<double> | 170 DetachableToolbarView::CalculateContentArea(current_state, |
| 202 (kNewtabBarRoundness) * current_state; | 171 h_padding, v_padding, |
| 203 | 172 &rect, &roundness, host_view_); |
| 204 // Draw our background. | 173 DetachableToolbarView::PaintContentAreaBackground( |
| 205 SkPaint paint; | 174 canvas, tp, rect, roundness); |
| 206 paint.setAntiAlias(true); | 175 DetachableToolbarView::PaintContentAreaBorder(canvas, tp, rect, roundness); |
| 207 paint.setColor(bookmark_bar_view->GetThemeProvider()->GetColor( | 176 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); |
| 208 BrowserThemeProvider::COLOR_TOOLBAR)); | |
| 209 | |
| 210 canvas->drawRoundRect(rect, | |
| 211 SkDoubleToScalar(roundness), | |
| 212 SkDoubleToScalar(roundness), paint); | |
| 213 | |
| 214 // Draw border | |
| 215 SkPaint border_paint; | |
| 216 border_paint.setColor(bookmark_bar_view->GetThemeProvider()->GetColor( | |
| 217 BrowserThemeProvider::COLOR_NTP_HEADER)); | |
| 218 border_paint.setStyle(SkPaint::kStroke_Style); | |
| 219 border_paint.setAlpha(96); | |
| 220 border_paint.setAntiAlias(true); | |
| 221 | |
| 222 canvas->drawRoundRect(rect, | |
| 223 SkDoubleToScalar(roundness), | |
| 224 SkDoubleToScalar(roundness), border_paint); | |
| 225 } else { | 177 } else { |
| 226 gfx::Rect bounds = bookmark_bar_view->GetBounds(views::View:: | 178 DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_); |
| 227 APPLY_MIRRORING_TRANSFORMATION); | 179 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); |
| 228 | |
| 229 SkColor theme_toolbar_color = | |
| 230 bookmark_bar_view->GetThemeProvider()->GetColor(BrowserThemeProvider:: | |
| 231 COLOR_TOOLBAR); | |
| 232 canvas->FillRectInt(theme_toolbar_color, 0, 0, | |
| 233 bookmark_bar_view->width(), | |
| 234 bookmark_bar_view->height()); | |
| 235 | |
| 236 canvas->TileImageInt( | |
| 237 *browser_view_->GetBookmarkBarView()->GetThemeProvider()-> | |
| 238 GetBitmapNamed(IDR_THEME_TOOLBAR), | |
| 239 bookmark_bar_view->GetParent()->GetBounds(views:: | |
| 240 View::APPLY_MIRRORING_TRANSFORMATION).x() + bounds.x(), bounds.y(), | |
| 241 0, 0, | |
| 242 bookmark_bar_view->width(), | |
| 243 bookmark_bar_view->height()); | |
| 244 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, | |
| 245 0, | |
| 246 bookmark_bar_view->height() - 1, | |
| 247 bookmark_bar_view->width(), 1); | |
| 248 } | |
| 249 } | |
| 250 | |
| 251 void BookmarkExtensionBackground::PaintThemeBackgroundTopAligned( | |
| 252 gfx::Canvas* canvas, SkBitmap* ntp_background, int tiling, | |
| 253 int alignment) const { | |
| 254 BookmarkBarView* bookmark_bar_view = browser_view_->GetBookmarkBarView(); | |
| 255 if (alignment & BrowserThemeProvider::ALIGN_LEFT) { | |
| 256 if (tiling == BrowserThemeProvider::REPEAT) | |
| 257 canvas->TileImageInt(*ntp_background, 0, 0, | |
| 258 bookmark_bar_view->width(), bookmark_bar_view->height()); | |
| 259 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
| 260 canvas->TileImageInt(*ntp_background, 0, 0, | |
| 261 bookmark_bar_view->width(), | |
| 262 ntp_background->height()); | |
| 263 else | |
| 264 canvas->TileImageInt(*ntp_background, 0, 0, | |
| 265 ntp_background->width(), ntp_background->height()); | |
| 266 | |
| 267 } else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) { | |
| 268 int x_pos = bookmark_bar_view->width() % ntp_background->width() - | |
| 269 ntp_background->width(); | |
| 270 if (tiling == BrowserThemeProvider::REPEAT) | |
| 271 canvas->TileImageInt(*ntp_background, x_pos, 0, | |
| 272 bookmark_bar_view->width() + ntp_background->width(), | |
| 273 bookmark_bar_view->height()); | |
| 274 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
| 275 canvas->TileImageInt(*ntp_background, x_pos, | |
| 276 0, bookmark_bar_view->width() + ntp_background->width(), | |
| 277 ntp_background->height()); | |
| 278 else | |
| 279 canvas->TileImageInt(*ntp_background, | |
| 280 bookmark_bar_view->width() - ntp_background->width(), 0, | |
| 281 ntp_background->width(), ntp_background->height()); | |
| 282 | |
| 283 } else { // ALIGN == CENTER | |
| 284 int x_pos = bookmark_bar_view->width() > ntp_background->width() ? | |
| 285 ((bookmark_bar_view->width() / 2 - ntp_background->width() / 2) % | |
| 286 ntp_background->width()) - ntp_background->width() : | |
| 287 bookmark_bar_view->width() / 2 - ntp_background->width() / 2; | |
| 288 if (tiling == BrowserThemeProvider::REPEAT) | |
| 289 canvas->TileImageInt(*ntp_background, x_pos, 0, | |
| 290 bookmark_bar_view->width() + ntp_background->width(), | |
| 291 bookmark_bar_view->height()); | |
| 292 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
| 293 canvas->TileImageInt(*ntp_background, x_pos, 0, | |
| 294 bookmark_bar_view->width() + ntp_background->width(), | |
| 295 ntp_background->height()); | |
| 296 else | |
| 297 canvas->TileImageInt(*ntp_background, | |
| 298 bookmark_bar_view->width() / 2 - ntp_background->width() / 2, | |
| 299 0, ntp_background->width(), ntp_background->height()); | |
| 300 } | |
| 301 } | |
| 302 | |
| 303 void BookmarkExtensionBackground::PaintThemeBackgroundBottomAligned( | |
| 304 gfx::Canvas* canvas, SkBitmap* ntp_background, int tiling, | |
| 305 int alignment) const { | |
| 306 BookmarkBarView* bookmark_bar_view = browser_view_->GetBookmarkBarView(); | |
| 307 int browser_height = bookmark_bar_view->GetParent()->GetBounds( | |
| 308 views::View::APPLY_MIRRORING_TRANSFORMATION).height(); | |
| 309 int border_width = 5; | |
| 310 int y_pos = ((tiling == BrowserThemeProvider::REPEAT_X) || | |
| 311 (tiling == BrowserThemeProvider::NO_REPEAT)) ? | |
| 312 browser_height - ntp_background->height() - bookmark_bar_view->height() - | |
| 313 border_width : | |
| 314 browser_height % ntp_background->height() - bookmark_bar_view->height() - | |
| 315 border_width - ntp_background->height(); | |
| 316 | |
| 317 if (alignment & BrowserThemeProvider::ALIGN_LEFT) { | |
| 318 if (tiling == BrowserThemeProvider::REPEAT) | |
| 319 canvas->TileImageInt(*ntp_background, 0, y_pos, | |
| 320 bookmark_bar_view->width(), | |
| 321 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
| 322 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
| 323 canvas->TileImageInt(*ntp_background, 0, y_pos, | |
| 324 bookmark_bar_view->width(), ntp_background->height()); | |
| 325 else if (tiling == BrowserThemeProvider::REPEAT_Y) | |
| 326 canvas->TileImageInt(*ntp_background, 0, y_pos, | |
| 327 ntp_background->width(), | |
| 328 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
| 329 else | |
| 330 canvas->TileImageInt(*ntp_background, 0, y_pos, ntp_background->width(), | |
| 331 ntp_background->height()); | |
| 332 | |
| 333 } else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) { | |
| 334 int x_pos = bookmark_bar_view->width() % ntp_background->width() - | |
| 335 ntp_background->width(); | |
| 336 if (tiling == BrowserThemeProvider::REPEAT) | |
| 337 canvas->TileImageInt(*ntp_background, x_pos, y_pos, | |
| 338 bookmark_bar_view->width() + ntp_background->width(), | |
| 339 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
| 340 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
| 341 canvas->TileImageInt(*ntp_background, x_pos, y_pos, | |
| 342 bookmark_bar_view->width() + ntp_background->width(), | |
| 343 ntp_background->height()); | |
| 344 else if (tiling == BrowserThemeProvider::REPEAT_Y) | |
| 345 canvas->TileImageInt(*ntp_background, bookmark_bar_view->width() - | |
| 346 ntp_background->width(), y_pos, ntp_background->width(), | |
| 347 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
| 348 else | |
| 349 canvas->TileImageInt(*ntp_background, | |
| 350 bookmark_bar_view->width() - ntp_background->width(), | |
| 351 y_pos, ntp_background->width(), ntp_background->height()); | |
| 352 | |
| 353 } else { // ALIGN == CENTER | |
| 354 int x_pos = bookmark_bar_view->width() > ntp_background->width() ? | |
| 355 ((bookmark_bar_view->width() / 2 - ntp_background->width() / 2) % | |
| 356 ntp_background->width()) - ntp_background->width() : | |
| 357 bookmark_bar_view->width() / 2 - ntp_background->width() / 2; | |
| 358 if (tiling == BrowserThemeProvider::REPEAT) | |
| 359 canvas->TileImageInt(*ntp_background, x_pos, y_pos, | |
| 360 bookmark_bar_view->width() + ntp_background->width(), | |
| 361 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
| 362 else if (tiling == BrowserThemeProvider::REPEAT_X) | |
| 363 canvas->TileImageInt(*ntp_background, x_pos, y_pos, | |
| 364 bookmark_bar_view->width() + ntp_background->width(), | |
| 365 ntp_background->height()); | |
| 366 else if (tiling == BrowserThemeProvider::REPEAT_Y) | |
| 367 canvas->TileImageInt(*ntp_background, | |
| 368 bookmark_bar_view->width() / 2 - ntp_background->width() / 2, | |
| 369 y_pos, ntp_background->width(), | |
| 370 2 * bookmark_bar_view->height() + ntp_background->height() + 5); | |
| 371 else | |
| 372 canvas->TileImageInt(*ntp_background, | |
| 373 bookmark_bar_view->width() / 2 - ntp_background->width() / 2, | |
| 374 y_pos, ntp_background->width(), ntp_background->height()); | |
| 375 } | 180 } |
| 376 } | 181 } |
| 377 | 182 |
| 378 /////////////////////////////////////////////////////////////////////////////// | 183 /////////////////////////////////////////////////////////////////////////////// |
| 379 // ResizeCorner, private: | 184 // ResizeCorner, private: |
| 380 | 185 |
| 381 class ResizeCorner : public views::View { | 186 class ResizeCorner : public views::View { |
| 382 public: | 187 public: |
| 383 ResizeCorner() { } | 188 ResizeCorner() { } |
| 384 | 189 |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1790 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 1595 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
| 1791 contents_split_->set_background( | 1596 contents_split_->set_background( |
| 1792 views::Background::CreateSolidBackground(bg_color)); | 1597 views::Background::CreateSolidBackground(bg_color)); |
| 1793 AddChildView(contents_split_); | 1598 AddChildView(contents_split_); |
| 1794 set_contents_view(contents_split_); | 1599 set_contents_view(contents_split_); |
| 1795 | 1600 |
| 1796 status_bubble_.reset(new StatusBubbleViews(GetWidget())); | 1601 status_bubble_.reset(new StatusBubbleViews(GetWidget())); |
| 1797 | 1602 |
| 1798 if (browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF)) { | 1603 if (browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF)) { |
| 1799 extension_shelf_ = new ExtensionShelf(browser_.get()); | 1604 extension_shelf_ = new ExtensionShelf(browser_.get()); |
| 1605 extension_shelf_->set_background( |
| 1606 new BookmarkExtensionBackground(this, extension_shelf_)); |
| 1800 extension_shelf_-> | 1607 extension_shelf_-> |
| 1801 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_EXTENSIONS)); | 1608 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_EXTENSIONS)); |
| 1802 AddChildView(extension_shelf_); | 1609 AddChildView(extension_shelf_); |
| 1803 } | 1610 } |
| 1804 | 1611 |
| 1805 #if defined(OS_WIN) | 1612 #if defined(OS_WIN) |
| 1806 InitSystemMenu(); | 1613 InitSystemMenu(); |
| 1807 | 1614 |
| 1808 // Create a custom JumpList and add it to an observer of TabRestoreService | 1615 // Create a custom JumpList and add it to an observer of TabRestoreService |
| 1809 // so we can update the custom JumpList when a tab is added or removed. | 1616 // 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... |
| 1861 toolbar_->SetBounds(0, y, browser_view_width, height); | 1668 toolbar_->SetBounds(0, y, browser_view_width, height); |
| 1862 return y + height; | 1669 return y + height; |
| 1863 } | 1670 } |
| 1864 | 1671 |
| 1865 int BrowserView::LayoutBookmarkAndInfoBars(int top) { | 1672 int BrowserView::LayoutBookmarkAndInfoBars(int top) { |
| 1866 find_bar_y_ = top + y() - 1; | 1673 find_bar_y_ = top + y() - 1; |
| 1867 if (active_bookmark_bar_) { | 1674 if (active_bookmark_bar_) { |
| 1868 // If we're showing the Bookmark bar in detached style, then we need to show | 1675 // If we're showing the Bookmark bar in detached style, then we need to show |
| 1869 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled | 1676 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled |
| 1870 // to look like it's part of the page. | 1677 // to look like it's part of the page. |
| 1871 if (bookmark_bar_view_->IsDetachedStyle()) | 1678 if (bookmark_bar_view_->IsDetached()) |
| 1872 return LayoutTopBar(LayoutInfoBar(top)); | 1679 return LayoutTopBar(LayoutInfoBar(top)); |
| 1873 // Otherwise, Bookmark bar first, Info bar second. | 1680 // Otherwise, Bookmark bar first, Info bar second. |
| 1874 top = LayoutTopBar(top); | 1681 top = LayoutTopBar(top); |
| 1875 } | 1682 } |
| 1876 find_bar_y_ = top + y() - 1; | 1683 find_bar_y_ = top + y() - 1; |
| 1877 return LayoutInfoBar(top); | 1684 return LayoutInfoBar(top); |
| 1878 } | 1685 } |
| 1879 | 1686 |
| 1880 int BrowserView::LayoutTopBar(int top) { | 1687 int BrowserView::LayoutTopBar(int top) { |
| 1881 // This method lays out the the bookmark bar, and, if required, the extension | 1688 // This method lays out the the bookmark bar, and, if required, the extension |
| 1882 // shelf by its side. The bookmark bar appears on the right of the extension | 1689 // shelf by its side. The bookmark bar appears on the right of the extension |
| 1883 // shelf. If there are too many bookmark items and extension toolstrips to fit | 1690 // shelf. If there are too many bookmark items and extension toolstrips to fit |
| 1884 // in the single bar, some compromises are made as follows: | 1691 // in the single bar, some compromises are made as follows: |
| 1885 // 1. The bookmark bar is shrunk till it reaches the minimum width. | 1692 // 1. The bookmark bar is shrunk till it reaches the minimum width. |
| 1886 // 2. After reaching the minimum width, the bookmark bar width is kept fixed - | 1693 // 2. After reaching the minimum width, the bookmark bar width is kept fixed - |
| 1887 // the extension shelf bar width is reduced. | 1694 // the extension shelf bar width is reduced. |
| 1888 DCHECK(active_bookmark_bar_); | 1695 DCHECK(active_bookmark_bar_); |
| 1889 int y = top, x = 0; | 1696 int y = top, x = 0; |
| 1890 if (!IsBookmarkBarVisible()) { | 1697 if (!IsBookmarkBarVisible()) { |
| 1891 bookmark_bar_view_->SetVisible(false); | 1698 bookmark_bar_view_->SetVisible(false); |
| 1892 bookmark_bar_view_->SetBounds(0, y, width(), 0); | 1699 bookmark_bar_view_->SetBounds(0, y, width(), 0); |
| 1893 if (ShowExtensionsOnTop()) | 1700 if (extension_shelf_->IsOnTop()) |
| 1894 extension_shelf_->SetVisible(false); | 1701 extension_shelf_->SetVisible(false); |
| 1895 return y; | 1702 return y; |
| 1896 } | 1703 } |
| 1897 | 1704 |
| 1898 int bookmark_bar_height = bookmark_bar_view_->GetPreferredSize().height(); | 1705 int bookmark_bar_height = bookmark_bar_view_->GetPreferredSize().height(); |
| 1899 y -= kSeparationLineHeight + (bookmark_bar_view_->IsDetachedStyle() ? | 1706 y -= kSeparationLineHeight + (bookmark_bar_view_->IsDetached() ? |
| 1900 0 : bookmark_bar_view_->GetToolbarOverlap(false)); | 1707 0 : bookmark_bar_view_->GetToolbarOverlap(false)); |
| 1901 | 1708 |
| 1902 if (ShowExtensionsOnTop()) { | 1709 if (extension_shelf_->IsOnTop()) { |
| 1903 if (!bookmark_bar_view_->IsDetachedStyle()) { | 1710 if (!bookmark_bar_view_->IsDetached()) { |
| 1904 int extension_shelf_width = | 1711 int extension_shelf_width = |
| 1905 extension_shelf_->GetPreferredSize().width(); | 1712 extension_shelf_->GetPreferredSize().width(); |
| 1906 int bookmark_bar_given_width = width() - extension_shelf_width; | 1713 int bookmark_bar_given_width = width() - extension_shelf_width; |
| 1907 int minimum_allowed_bookmark_bar_width = | 1714 int minimum_allowed_bookmark_bar_width = |
| 1908 bookmark_bar_view_->GetMinimumSize().width(); | 1715 bookmark_bar_view_->GetMinimumSize().width(); |
| 1909 if (bookmark_bar_given_width < minimum_allowed_bookmark_bar_width) { | 1716 if (bookmark_bar_given_width < minimum_allowed_bookmark_bar_width) { |
| 1910 // The bookmark bar cannot compromise on its width any more. The | 1717 // The bookmark bar cannot compromise on its width any more. The |
| 1911 // extension shelf needs to shrink now. | 1718 // extension shelf needs to shrink now. |
| 1912 extension_shelf_width = | 1719 extension_shelf_width = |
| 1913 width() - minimum_allowed_bookmark_bar_width; | 1720 width() - minimum_allowed_bookmark_bar_width; |
| 1914 } | 1721 } |
| 1915 extension_shelf_->SetVisible(true); | 1722 extension_shelf_->SetVisible(true); |
| 1916 extension_shelf_->SetBounds(x, y, extension_shelf_width, | 1723 extension_shelf_->SetBounds(x, y, extension_shelf_width, |
| 1917 bookmark_bar_height); | 1724 bookmark_bar_height); |
| 1918 x += extension_shelf_width; | 1725 x += extension_shelf_width; |
| 1919 } else { | 1726 } else { |
| 1920 // TODO (sidchat): For detached style bookmark bar, set the extensions | 1727 // TODO(sidchat): For detached style bookmark bar, set the extensions |
| 1921 // shelf in a better position. Issue = 20741. | 1728 // shelf in a better position. Issue = 20741. |
| 1922 extension_shelf_->SetVisible(false); | 1729 extension_shelf_->SetVisible(false); |
| 1923 } | 1730 } |
| 1924 } | 1731 } |
| 1925 | 1732 |
| 1926 bookmark_bar_view_->SetVisible(true); | 1733 bookmark_bar_view_->SetVisible(true); |
| 1927 bookmark_bar_view_->SetBounds(x, y, width() - x, bookmark_bar_height); | 1734 bookmark_bar_view_->SetBounds(x, y, width() - x, bookmark_bar_height); |
| 1928 return y + bookmark_bar_height; | 1735 return y + bookmark_bar_height; |
| 1929 } | 1736 } |
| 1930 | 1737 |
| 1931 int BrowserView::LayoutInfoBar(int top) { | 1738 int BrowserView::LayoutInfoBar(int top) { |
| 1932 bool visible = browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR); | 1739 bool visible = browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR); |
| 1933 int height = visible ? infobar_container_->GetPreferredSize().height() : 0; | 1740 int height = visible ? infobar_container_->GetPreferredSize().height() : 0; |
| 1934 infobar_container_->SetVisible(visible); | 1741 infobar_container_->SetVisible(visible); |
| 1935 infobar_container_->SetBounds(0, top, width(), height); | 1742 infobar_container_->SetBounds(0, top, width(), height); |
| 1936 return top + height; | 1743 return top + height; |
| 1937 } | 1744 } |
| 1938 | 1745 |
| 1939 void BrowserView::LayoutTabContents(int top, int bottom) { | 1746 void BrowserView::LayoutTabContents(int top, int bottom) { |
| 1940 contents_split_->SetBounds(0, top, width(), bottom - top); | 1747 contents_split_->SetBounds(0, top, width(), bottom - top); |
| 1941 } | 1748 } |
| 1942 | 1749 |
| 1943 int BrowserView::LayoutExtensionAndDownloadShelves() { | 1750 int BrowserView::LayoutExtensionAndDownloadShelves() { |
| 1944 // If we're showing the Bookmark bar in detached style, then we need to show | 1751 // If we're showing the Bookmark bar in detached style, then we need to show |
| 1945 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled | 1752 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled |
| 1946 // to look like it's part of the page. | 1753 // to look like it's part of the page. |
| 1947 int bottom = height(); | 1754 int bottom = height(); |
| 1948 if (extension_shelf_) { | 1755 if (extension_shelf_) { |
| 1949 if (extension_shelf_->IsDetachedStyle()) { | 1756 if (extension_shelf_->IsDetached()) { |
| 1950 bottom = LayoutDownloadShelf(bottom); | 1757 bottom = LayoutDownloadShelf(bottom); |
| 1951 return LayoutExtensionShelf(bottom); | 1758 return LayoutExtensionShelf(bottom); |
| 1952 } | 1759 } |
| 1953 // Otherwise, Extension shelf first, Download shelf second. | 1760 // Otherwise, Extension shelf first, Download shelf second. |
| 1954 bottom = LayoutExtensionShelf(bottom); | 1761 bottom = LayoutExtensionShelf(bottom); |
| 1955 } | 1762 } |
| 1956 return LayoutDownloadShelf(bottom); | 1763 return LayoutDownloadShelf(bottom); |
| 1957 } | 1764 } |
| 1958 | 1765 |
| 1959 int BrowserView::LayoutDownloadShelf(int bottom) { | 1766 int BrowserView::LayoutDownloadShelf(int bottom) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1978 // frame. | 1785 // frame. |
| 1979 int overlap = StatusBubbleViews::kShadowThickness + | 1786 int overlap = StatusBubbleViews::kShadowThickness + |
| 1980 (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness); | 1787 (IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness); |
| 1981 int height = status_bubble_->GetPreferredSize().height(); | 1788 int height = status_bubble_->GetPreferredSize().height(); |
| 1982 gfx::Point origin(-overlap, top - height + overlap); | 1789 gfx::Point origin(-overlap, top - height + overlap); |
| 1983 ConvertPointToView(this, GetParent(), &origin); | 1790 ConvertPointToView(this, GetParent(), &origin); |
| 1984 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height); | 1791 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height); |
| 1985 } | 1792 } |
| 1986 | 1793 |
| 1987 int BrowserView::LayoutExtensionShelf(int bottom) { | 1794 int BrowserView::LayoutExtensionShelf(int bottom) { |
| 1988 if (ShowExtensionsOnTop()) | 1795 if (!extension_shelf_ || extension_shelf_->IsOnTop()) |
| 1989 return bottom; | 1796 return bottom; |
| 1990 | 1797 |
| 1991 if (extension_shelf_) { | 1798 if (extension_shelf_) { |
| 1992 bool visible = browser_->SupportsWindowFeature( | 1799 bool visible = browser_->SupportsWindowFeature( |
| 1993 Browser::FEATURE_EXTENSIONSHELF); | 1800 Browser::FEATURE_EXTENSIONSHELF); |
| 1994 int height = | 1801 int height = |
| 1995 visible ? extension_shelf_->GetPreferredSize().height() : 0; | 1802 visible ? extension_shelf_->GetPreferredSize().height() : 0; |
| 1996 extension_shelf_->SetVisible(visible); | 1803 extension_shelf_->SetVisible(visible); |
| 1997 extension_shelf_->SetBounds(0, bottom - height, width(), height); | 1804 extension_shelf_->SetBounds(0, bottom - height, width(), height); |
| 1998 extension_shelf_->Layout(); | 1805 extension_shelf_->Layout(); |
| 1999 bottom -= height; | 1806 bottom -= height; |
| 2000 } | 1807 } |
| 2001 return bottom; | 1808 return bottom; |
| 2002 } | 1809 } |
| 2003 | 1810 |
| 2004 bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) { | 1811 bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) { |
| 2005 views::View* new_bookmark_bar_view = NULL; | 1812 views::View* new_bookmark_bar_view = NULL; |
| 2006 if (browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) | 1813 if (browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) |
| 2007 && contents) { | 1814 && contents) { |
| 2008 if (!bookmark_bar_view_.get()) { | 1815 if (!bookmark_bar_view_.get()) { |
| 2009 bookmark_bar_view_.reset(new BookmarkBarView(contents->profile(), | 1816 bookmark_bar_view_.reset(new BookmarkBarView(contents->profile(), |
| 2010 browser_.get())); | 1817 browser_.get())); |
| 2011 bookmark_bar_view_->SetParentOwned(false); | 1818 bookmark_bar_view_->SetParentOwned(false); |
| 2012 bookmark_bar_view_->set_background(new BookmarkExtensionBackground(this)); | 1819 bookmark_bar_view_->set_background( |
| 1820 new BookmarkExtensionBackground(this, bookmark_bar_view_.get())); |
| 2013 } else { | 1821 } else { |
| 2014 bookmark_bar_view_->SetProfile(contents->profile()); | 1822 bookmark_bar_view_->SetProfile(contents->profile()); |
| 2015 } | 1823 } |
| 2016 bookmark_bar_view_->SetPageNavigator(contents); | 1824 bookmark_bar_view_->SetPageNavigator(contents); |
| 2017 bookmark_bar_view_-> | 1825 bookmark_bar_view_-> |
| 2018 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_BOOKMARKS)); | 1826 SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_BOOKMARKS)); |
| 2019 new_bookmark_bar_view = bookmark_bar_view_.get(); | 1827 new_bookmark_bar_view = bookmark_bar_view_.get(); |
| 2020 } | 1828 } |
| 2021 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); | 1829 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); |
| 2022 } | 1830 } |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2288 ticker_.Start(); | 2096 ticker_.Start(); |
| 2289 | 2097 |
| 2290 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout, | 2098 pref_service->SetInteger(prefs::kPluginMessageResponseTimeout, |
| 2291 plugin_message_response_timeout); | 2099 plugin_message_response_timeout); |
| 2292 pref_service->SetInteger(prefs::kHungPluginDetectFrequency, | 2100 pref_service->SetInteger(prefs::kHungPluginDetectFrequency, |
| 2293 hung_plugin_detect_freq); | 2101 hung_plugin_detect_freq); |
| 2294 } | 2102 } |
| 2295 #endif | 2103 #endif |
| 2296 } | 2104 } |
| 2297 | 2105 |
| 2298 bool BrowserView::ShowExtensionsOnTop() { | |
| 2299 return extension_shelf_ && CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2300 switches::kShowExtensionsOnTop); | |
| 2301 } | |
| 2302 | |
| 2303 // static | 2106 // static |
| 2304 void BrowserView::InitClass() { | 2107 void BrowserView::InitClass() { |
| 2305 static bool initialized = false; | 2108 static bool initialized = false; |
| 2306 if (!initialized) { | 2109 if (!initialized) { |
| 2307 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 2110 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 2308 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); | 2111 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
| 2309 initialized = true; | 2112 initialized = true; |
| 2310 } | 2113 } |
| 2311 } | 2114 } |
| 2312 | 2115 |
| 2313 // static | 2116 // static |
| 2314 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2117 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2315 // Create the view and the frame. The frame will attach itself via the view | 2118 // Create the view and the frame. The frame will attach itself via the view |
| 2316 // so we don't need to do anything with the pointer. | 2119 // so we don't need to do anything with the pointer. |
| 2317 BrowserView* view = new BrowserView(browser); | 2120 BrowserView* view = new BrowserView(browser); |
| 2318 BrowserFrame::Create(view, browser->profile()); | 2121 BrowserFrame::Create(view, browser->profile()); |
| 2319 return view; | 2122 return view; |
| 2320 } | 2123 } |
| 2321 | 2124 |
| 2322 // static | 2125 // static |
| 2323 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2126 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2324 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2127 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2325 } | 2128 } |
| 2326 | 2129 |
| 2327 // static | 2130 // static |
| 2328 void BrowserList::AllBrowsersClosed() { | 2131 void BrowserList::AllBrowsersClosed() { |
| 2329 views::Window::CloseAllSecondaryWindows(); | 2132 views::Window::CloseAllSecondaryWindows(); |
| 2330 } | 2133 } |
| OLD | NEW |