OLD | NEW |
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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 contents_container_(NULL), | 188 contents_container_(NULL), |
189 initialized_(false), | 189 initialized_(false), |
190 fullscreen_(false), | 190 fullscreen_(false), |
191 can_drop_(false), | 191 can_drop_(false), |
192 hung_window_detector_(&hung_plugin_action_), | 192 hung_window_detector_(&hung_plugin_action_), |
193 ticker_(0), | 193 ticker_(0), |
194 #ifdef CHROME_PERSONALIZATION | 194 #ifdef CHROME_PERSONALIZATION |
195 personalization_enabled_(false), | 195 personalization_enabled_(false), |
196 personalization_(NULL), | 196 personalization_(NULL), |
197 #endif | 197 #endif |
198 forwarding_to_tab_strip_(false), | 198 forwarding_to_tab_strip_(false) { |
199 is_removing_bookmark_bar_(false) { | |
200 InitClass(); | 199 InitClass(); |
201 browser_->tabstrip_model()->AddObserver(this); | 200 browser_->tabstrip_model()->AddObserver(this); |
202 } | 201 } |
203 | 202 |
204 BrowserView::~BrowserView() { | 203 BrowserView::~BrowserView() { |
205 browser_->tabstrip_model()->RemoveObserver(this); | 204 browser_->tabstrip_model()->RemoveObserver(this); |
206 | 205 |
207 // Stop hung plugin monitoring. | 206 // Stop hung plugin monitoring. |
208 ticker_.Stop(); | 207 ticker_.Stop(); |
209 ticker_.UnregisterTickHandler(&hung_window_detector_); | 208 ticker_.UnregisterTickHandler(&hung_window_detector_); |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 void BrowserView::DestroyBrowser() { | 693 void BrowserView::DestroyBrowser() { |
695 // Explicitly delete the BookmarkBarView now. That way we don't have to | 694 // Explicitly delete the BookmarkBarView now. That way we don't have to |
696 // worry about the BookmarkBarView potentially outliving the Browser & | 695 // worry about the BookmarkBarView potentially outliving the Browser & |
697 // Profile. | 696 // Profile. |
698 bookmark_bar_view_.reset(); | 697 bookmark_bar_view_.reset(); |
699 browser_.reset(); | 698 browser_.reset(); |
700 } | 699 } |
701 | 700 |
702 bool BrowserView::IsBookmarkBarVisible() const { | 701 bool BrowserView::IsBookmarkBarVisible() const { |
703 return SupportsWindowFeature(FEATURE_BOOKMARKBAR) && | 702 return SupportsWindowFeature(FEATURE_BOOKMARKBAR) && |
704 bookmark_bar_view_.get() && | 703 active_bookmark_bar_ && |
705 (bookmark_bar_view_->GetPreferredSize().height() != 0); | 704 (active_bookmark_bar_->GetPreferredSize().height() != 0); |
706 } | 705 } |
707 | 706 |
708 gfx::Rect BrowserView::GetRootWindowResizerRect() const { | 707 gfx::Rect BrowserView::GetRootWindowResizerRect() const { |
709 // There is no resize corner when we are maximized | 708 // There is no resize corner when we are maximized |
710 if (IsMaximized()) | 709 if (IsMaximized()) |
711 return gfx::Rect(); | 710 return gfx::Rect(); |
712 | 711 |
713 // We don't specify a resize corner size if we have a bottom shelf either. | 712 // We don't specify a resize corner size if we have a bottom shelf either. |
714 // This is because we take care of drawing the resize corner on top of that | 713 // This is because we take care of drawing the resize corner on top of that |
715 // shelf, so we don't want others to do it for us in this case. | 714 // shelf, so we don't want others to do it for us in this case. |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 int y = top - | 1346 int y = top - |
1348 ((visible && IsTabStripVisible()) ? kToolbarTabStripVerticalOverlap : 0); | 1347 ((visible && IsTabStripVisible()) ? kToolbarTabStripVerticalOverlap : 0); |
1349 int height = visible ? toolbar_->GetPreferredSize().height() : 0; | 1348 int height = visible ? toolbar_->GetPreferredSize().height() : 0; |
1350 toolbar_->SetVisible(visible); | 1349 toolbar_->SetVisible(visible); |
1351 toolbar_->SetBounds(0, y, browser_view_width, height); | 1350 toolbar_->SetBounds(0, y, browser_view_width, height); |
1352 return y + height; | 1351 return y + height; |
1353 } | 1352 } |
1354 | 1353 |
1355 int BrowserView::LayoutBookmarkAndInfoBars(int top) { | 1354 int BrowserView::LayoutBookmarkAndInfoBars(int top) { |
1356 find_bar_y_ = top + y() - 1; | 1355 find_bar_y_ = top + y() - 1; |
1357 if (bookmark_bar_view_.get()) { | 1356 if (active_bookmark_bar_) { |
1358 // If we're showing the Bookmark bar in detached style, then we need to show | 1357 // If we're showing the Bookmark bar in detached style, then we need to show |
1359 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled | 1358 // any Info bar _above_ the Bookmark bar, since the Bookmark bar is styled |
1360 // to look like it's part of the page. | 1359 // to look like it's part of the page. |
1361 if (bookmark_bar_view_->IsDetachedStyle()) | 1360 if (bookmark_bar_view_->IsDetachedStyle()) |
1362 return LayoutBookmarkBar(LayoutInfoBar(top)); | 1361 return LayoutBookmarkBar(LayoutInfoBar(top)); |
1363 // Otherwise, Bookmark bar first, Info bar second. | 1362 // Otherwise, Bookmark bar first, Info bar second. |
1364 top = LayoutBookmarkBar(top); | 1363 top = LayoutBookmarkBar(top); |
1365 } | 1364 } |
1366 find_bar_y_ = top + y() - 1; | 1365 find_bar_y_ = top + y() - 1; |
1367 return LayoutInfoBar(top); | 1366 return LayoutInfoBar(top); |
1368 } | 1367 } |
1369 | 1368 |
1370 int BrowserView::LayoutBookmarkBar(int top) { | 1369 int BrowserView::LayoutBookmarkBar(int top) { |
1371 DCHECK(bookmark_bar_view_.get()); | 1370 DCHECK(active_bookmark_bar_); |
1372 bool visible = IsBookmarkBarVisible(); | 1371 bool visible = IsBookmarkBarVisible(); |
1373 int height, y = top; | 1372 int height, y = top; |
1374 if (visible) { | 1373 if (visible) { |
1375 y -= kSeparationLineHeight + (bookmark_bar_view_->IsDetachedStyle() ? | 1374 y -= kSeparationLineHeight + (bookmark_bar_view_->IsDetachedStyle() ? |
1376 0 : bookmark_bar_view_->GetToolbarOverlap()); | 1375 0 : bookmark_bar_view_->GetToolbarOverlap()); |
1377 height = bookmark_bar_view_->GetPreferredSize().height(); | 1376 height = bookmark_bar_view_->GetPreferredSize().height(); |
1378 } else { | 1377 } else { |
1379 height = 0; | 1378 height = 0; |
1380 } | 1379 } |
1381 bookmark_bar_view_->SetVisible(visible); | 1380 bookmark_bar_view_->SetVisible(visible); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 int overlap = kStatusBubbleOverlap + | 1414 int overlap = kStatusBubbleOverlap + |
1416 (IsMaximized() ? 0 : views::NonClientView::kClientEdgeThickness); | 1415 (IsMaximized() ? 0 : views::NonClientView::kClientEdgeThickness); |
1417 gfx::Point origin(-overlap, top - kStatusBubbleHeight + overlap); | 1416 gfx::Point origin(-overlap, top - kStatusBubbleHeight + overlap); |
1418 ConvertPointToView(this, GetParent(), &origin); | 1417 ConvertPointToView(this, GetParent(), &origin); |
1419 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, | 1418 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, |
1420 kStatusBubbleHeight); | 1419 kStatusBubbleHeight); |
1421 } | 1420 } |
1422 | 1421 |
1423 bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) { | 1422 bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) { |
1424 views::View* new_bookmark_bar_view = NULL; | 1423 views::View* new_bookmark_bar_view = NULL; |
1425 views::View* old_bookmark_bar_view = bookmark_bar_view_.get(); | |
1426 if (SupportsWindowFeature(FEATURE_BOOKMARKBAR) && contents) { | 1424 if (SupportsWindowFeature(FEATURE_BOOKMARKBAR) && contents) { |
1427 if (!old_bookmark_bar_view) { | 1425 if (!bookmark_bar_view_.get()) { |
1428 bookmark_bar_view_.reset(new BookmarkBarView(contents->profile(), | 1426 bookmark_bar_view_.reset(new BookmarkBarView(contents->profile(), |
1429 browser_.get())); | 1427 browser_.get())); |
1430 bookmark_bar_view_->SetParentOwned(false); | 1428 bookmark_bar_view_->SetParentOwned(false); |
1431 } else { | 1429 } else { |
1432 bookmark_bar_view_->SetProfile(contents->profile()); | 1430 bookmark_bar_view_->SetProfile(contents->profile()); |
1433 } | 1431 } |
1434 bookmark_bar_view_->SetPageNavigator(contents); | 1432 bookmark_bar_view_->SetPageNavigator(contents); |
1435 new_bookmark_bar_view = bookmark_bar_view_.get(); | 1433 new_bookmark_bar_view = bookmark_bar_view_.get(); |
1436 } | 1434 } |
1437 is_removing_bookmark_bar_ = true; | 1435 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); |
1438 bool result = UpdateChildViewAndLayout(new_bookmark_bar_view, | |
1439 &old_bookmark_bar_view); | |
1440 is_removing_bookmark_bar_ = false; | |
1441 return result; | |
1442 } | 1436 } |
1443 | 1437 |
1444 bool BrowserView::MaybeShowInfoBar(TabContents* contents) { | 1438 bool BrowserView::MaybeShowInfoBar(TabContents* contents) { |
1445 // TODO(beng): Remove this function once the interface between | 1439 // TODO(beng): Remove this function once the interface between |
1446 // InfoBarContainer, DownloadShelfView and TabContents and this | 1440 // InfoBarContainer, DownloadShelfView and TabContents and this |
1447 // view is sorted out. | 1441 // view is sorted out. |
1448 return true; | 1442 return true; |
1449 } | 1443 } |
1450 | 1444 |
1451 bool BrowserView::MaybeShowDownloadShelf(TabContents* contents) { | 1445 bool BrowserView::MaybeShowDownloadShelf(TabContents* contents) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 | 1650 |
1657 // static | 1651 // static |
1658 void BrowserView::InitClass() { | 1652 void BrowserView::InitClass() { |
1659 static bool initialized = false; | 1653 static bool initialized = false; |
1660 if (!initialized) { | 1654 if (!initialized) { |
1661 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1655 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
1662 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); | 1656 default_favicon_ = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); |
1663 initialized = true; | 1657 initialized = true; |
1664 } | 1658 } |
1665 } | 1659 } |
OLD | NEW |