| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/compact_location_bar_host.h" | 5 #include "chrome/browser/chromeos/compact_location_bar_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | |
| 10 #include "app/slide_animation.h" | 9 #include "app/slide_animation.h" |
| 10 #include "base/i18n/rtl.h" |
| 11 #include "base/keyboard_codes.h" | 11 #include "base/keyboard_codes.h" |
| 12 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chromeos/compact_location_bar_view.h" | 14 #include "chrome/browser/chromeos/compact_location_bar_view.h" |
| 15 #include "chrome/browser/find_bar_controller.h" | 15 #include "chrome/browser/find_bar_controller.h" |
| 16 #include "chrome/browser/renderer_host/render_view_host.h" | 16 #include "chrome/browser/renderer_host/render_view_host.h" |
| 17 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
| 18 #include "chrome/browser/tab_contents/tab_contents_view.h" | 18 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 19 #include "chrome/browser/view_ids.h" | 19 #include "chrome/browser/view_ids.h" |
| 20 #include "chrome/browser/views/bookmark_bar_view.h" | 20 #include "chrome/browser/views/bookmark_bar_view.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 gfx::Rect CompactLocationBarHost::GetBoundsUnderTab(int index) const { | 210 gfx::Rect CompactLocationBarHost::GetBoundsUnderTab(int index) const { |
| 211 // Get the position of the left-bottom corner of the tab on the | 211 // Get the position of the left-bottom corner of the tab on the |
| 212 // widget. The widget of the tab is same as the widget of the | 212 // widget. The widget of the tab is same as the widget of the |
| 213 // BrowserView which is the parent of the host. | 213 // BrowserView which is the parent of the host. |
| 214 TabStrip* tabstrip = browser_view()->tabstrip()->AsTabStrip(); | 214 TabStrip* tabstrip = browser_view()->tabstrip()->AsTabStrip(); |
| 215 gfx::Rect bounds = tabstrip->GetIdealBounds(index); | 215 gfx::Rect bounds = tabstrip->GetIdealBounds(index); |
| 216 gfx::Rect navbar_bounds(gfx::Point(bounds.x(), bounds.height()), | 216 gfx::Rect navbar_bounds(gfx::Point(bounds.x(), bounds.height()), |
| 217 view()->GetPreferredSize()); | 217 view()->GetPreferredSize()); |
| 218 | 218 |
| 219 // For RTL case x() defines tab right corner. | 219 // For RTL case x() defines tab right corner. |
| 220 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { | 220 if (base::i18n::IsRTL()) |
| 221 navbar_bounds.set_x(navbar_bounds.x() + bounds.width()); | 221 navbar_bounds.set_x(navbar_bounds.x() + bounds.width()); |
| 222 } | |
| 223 navbar_bounds.set_x(navbar_bounds.x() + tabstrip->x()); | 222 navbar_bounds.set_x(navbar_bounds.x() + tabstrip->x()); |
| 224 navbar_bounds.set_y(navbar_bounds.y() + tabstrip->y()); | 223 navbar_bounds.set_y(navbar_bounds.y() + tabstrip->y()); |
| 225 | 224 |
| 226 // The compact location bar must be smaller than browser_width. | 225 // The compact location bar must be smaller than browser_width. |
| 227 int width = std::min(browser_view()->width(), | 226 int width = std::min(browser_view()->width(), |
| 228 view()->GetPreferredSize().width()); | 227 view()->GetPreferredSize().width()); |
| 229 | 228 |
| 230 // Try to center around the tab. | 229 // Try to center around the tab. |
| 231 navbar_bounds.set_x(browser_view()->MirroredXCoordinateInsideView( | 230 navbar_bounds.set_x(browser_view()->MirroredXCoordinateInsideView( |
| 232 navbar_bounds.x()) - ((width - bounds.width()) / 2)); | 231 navbar_bounds.x()) - ((width - bounds.width()) / 2)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 287 |
| 289 CompactLocationBarView* CompactLocationBarHost::GetClbView() { | 288 CompactLocationBarView* CompactLocationBarHost::GetClbView() { |
| 290 return static_cast<CompactLocationBarView*>(view()); | 289 return static_cast<CompactLocationBarView*>(view()); |
| 291 } | 290 } |
| 292 | 291 |
| 293 bool CompactLocationBarHost::IsCurrentTabIndex(int index) { | 292 bool CompactLocationBarHost::IsCurrentTabIndex(int index) { |
| 294 return current_tab_index_ == index; | 293 return current_tab_index_ == index; |
| 295 } | 294 } |
| 296 | 295 |
| 297 } // namespace chromeos | 296 } // namespace chromeos |
| OLD | NEW |