OLD | NEW |
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/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar_view.h" |
6 | 6 |
7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 static const int kPulsateEveryMs = 8000; | 72 static const int kPulsateEveryMs = 8000; |
73 | 73 |
74 static const int kPopupTopSpacingNonGlass = 3; | 74 static const int kPopupTopSpacingNonGlass = 3; |
75 static const int kPopupBottomSpacingNonGlass = 2; | 75 static const int kPopupBottomSpacingNonGlass = 2; |
76 static const int kPopupBottomSpacingGlass = 1; | 76 static const int kPopupBottomSpacingGlass = 1; |
77 | 77 |
78 // Top margin for the wrench menu badges (badge is placed in the upper right | 78 // Top margin for the wrench menu badges (badge is placed in the upper right |
79 // corner of the wrench menu). | 79 // corner of the wrench menu). |
80 static const int kBadgeTopMargin = 2; | 80 static const int kBadgeTopMargin = 2; |
81 | 81 |
82 #if defined(TOUCH_UI) | |
83 // Extra vertical padding above the location bar. | |
84 static const int kExtraVerticalPadding = 3; | |
85 #endif | |
86 | |
87 static SkBitmap* kPopupBackgroundEdge = NULL; | 82 static SkBitmap* kPopupBackgroundEdge = NULL; |
88 | 83 |
89 //////////////////////////////////////////////////////////////////////////////// | 84 //////////////////////////////////////////////////////////////////////////////// |
90 // ToolbarView, public: | 85 // ToolbarView, public: |
91 | 86 |
92 ToolbarView::ToolbarView(Browser* browser) | 87 ToolbarView::ToolbarView(Browser* browser) |
93 : model_(browser->toolbar_model()), | 88 : model_(browser->toolbar_model()), |
94 back_(NULL), | 89 back_(NULL), |
95 forward_(NULL), | 90 forward_(NULL), |
96 reload_(NULL), | 91 reload_(NULL), |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 } else { | 529 } else { |
535 home_->SetVisible(false); | 530 home_->SetVisible(false); |
536 home_->SetBounds(reload_->x() + reload_->width(), child_y, 0, child_height); | 531 home_->SetBounds(reload_->x() + reload_->width(), child_y, 0, child_height); |
537 } | 532 } |
538 | 533 |
539 int browser_actions_width = browser_actions_->GetPreferredSize().width(); | 534 int browser_actions_width = browser_actions_->GetPreferredSize().width(); |
540 int app_menu_width = app_menu_->GetPreferredSize().width(); | 535 int app_menu_width = app_menu_->GetPreferredSize().width(); |
541 int location_x = home_->x() + home_->width() + kStandardSpacing; | 536 int location_x = home_->x() + home_->width() + kStandardSpacing; |
542 int available_width = width() - kEdgeSpacing - app_menu_width - | 537 int available_width = width() - kEdgeSpacing - app_menu_width - |
543 browser_actions_width - location_x; | 538 browser_actions_width - location_x; |
544 | |
545 #if defined(TOUCH_UI) | |
546 // Center the location bar vertically. | |
547 int location_y = std::min(child_y + kExtraVerticalPadding, height()); | |
548 int location_bar_height = std::max(height() - 2 * location_y, 0); | |
549 #else | |
550 int location_y = child_y; | 539 int location_y = child_y; |
551 int location_bar_height = child_height; | 540 int location_bar_height = child_height; |
552 #endif | |
553 | 541 |
554 location_bar_->SetBounds(location_x, location_y, std::max(available_width, 0), | 542 location_bar_->SetBounds(location_x, location_y, std::max(available_width, 0), |
555 location_bar_height); | 543 location_bar_height); |
556 | 544 |
557 browser_actions_->SetBounds(location_bar_->x() + location_bar_->width(), 0, | 545 browser_actions_->SetBounds(location_bar_->x() + location_bar_->width(), 0, |
558 browser_actions_width, height()); | 546 browser_actions_width, height()); |
559 // The browser actions need to do a layout explicitly, because when an | 547 // The browser actions need to do a layout explicitly, because when an |
560 // extension is loaded/unloaded/changed, BrowserActionContainer removes and | 548 // extension is loaded/unloaded/changed, BrowserActionContainer removes and |
561 // re-adds everything, regardless of whether it has a page action. For a | 549 // re-adds everything, regardless of whether it has a page action. For a |
562 // page action, browser action bounds do not change, as a result of which | 550 // page action, browser action bounds do not change, as a result of which |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 accname_app = l10n_util::GetStringFUTF16( | 730 accname_app = l10n_util::GetStringFUTF16( |
743 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 731 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
744 } | 732 } |
745 app_menu_->SetAccessibleName(accname_app); | 733 app_menu_->SetAccessibleName(accname_app); |
746 | 734 |
747 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 735 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
748 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 736 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
749 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 737 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
750 SchedulePaint(); | 738 SchedulePaint(); |
751 } | 739 } |
OLD | NEW |