| 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/bookmark_bar_instructions_view.h" | 5 #include "chrome/browser/ui/views/bookmark_bar_instructions_view.h" | 
| 6 | 6 | 
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" | 
| 8 #include "chrome/browser/defaults.h" | 8 #include "chrome/browser/defaults.h" | 
| 9 #include "chrome/browser/themes/browser_theme_provider.h" | 9 #include "chrome/browser/themes/browser_theme_provider.h" | 
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 31         UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_IMPORT_LINK))); | 31         UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_IMPORT_LINK))); | 
| 32     // We don't want the link to alter tab navigation. | 32     // We don't want the link to alter tab navigation. | 
| 33     import_link_->SetFocusable(false); | 33     import_link_->SetFocusable(false); | 
| 34     import_link_->SetController(this); | 34     import_link_->SetController(this); | 
| 35     AddChildView(import_link_); | 35     AddChildView(import_link_); | 
| 36   } | 36   } | 
| 37 } | 37 } | 
| 38 | 38 | 
| 39 gfx::Size BookmarkBarInstructionsView::GetPreferredSize() { | 39 gfx::Size BookmarkBarInstructionsView::GetPreferredSize() { | 
| 40   int ascent = 0, descent = 0, height = 0, width = 0; | 40   int ascent = 0, descent = 0, height = 0, width = 0; | 
| 41   for (int i = 0; i < GetChildViewCount(); ++i) { | 41   for (int i = 0; i < child_count(); ++i) { | 
| 42     View* view = GetChildViewAt(i); | 42     View* view = GetChildViewAt(i); | 
| 43     gfx::Size pref = view->GetPreferredSize(); | 43     gfx::Size pref = view->GetPreferredSize(); | 
| 44     int baseline = view->GetBaseline(); | 44     int baseline = view->GetBaseline(); | 
| 45     if (baseline != -1) { | 45     if (baseline != -1) { | 
| 46       ascent = std::max(ascent, baseline); | 46       ascent = std::max(ascent, baseline); | 
| 47       descent = std::max(descent, pref.height() - baseline); | 47       descent = std::max(descent, pref.height() - baseline); | 
| 48     } else { | 48     } else { | 
| 49       height = std::max(pref.height(), height); | 49       height = std::max(pref.height(), height); | 
| 50     } | 50     } | 
| 51     width += pref.width(); | 51     width += pref.width(); | 
| 52   } | 52   } | 
| 53   width += (GetChildViewCount() - 1) * kViewPadding; | 53   width += (child_count() - 1) * kViewPadding; | 
| 54   if (ascent != 0) | 54   if (ascent != 0) | 
| 55     height = std::max(ascent + descent, height); | 55     height = std::max(ascent + descent, height); | 
| 56   return gfx::Size(width, height); | 56   return gfx::Size(width, height); | 
| 57 } | 57 } | 
| 58 | 58 | 
| 59 void BookmarkBarInstructionsView::Layout() { | 59 void BookmarkBarInstructionsView::Layout() { | 
| 60   int remaining_width = width(); | 60   int remaining_width = width(); | 
| 61   int x = 0; | 61   int x = 0; | 
| 62   for (int i = 0; i < GetChildViewCount(); ++i) { | 62   for (int i = 0; i < child_count(); ++i) { | 
| 63     View* view = GetChildViewAt(i); | 63     View* view = GetChildViewAt(i); | 
| 64     gfx::Size pref = view->GetPreferredSize(); | 64     gfx::Size pref = view->GetPreferredSize(); | 
| 65     int baseline = view->GetBaseline(); | 65     int baseline = view->GetBaseline(); | 
| 66     int y; | 66     int y; | 
| 67     if (baseline != -1 && baseline_ != -1) | 67     if (baseline != -1 && baseline_ != -1) | 
| 68       y = baseline_ - baseline; | 68       y = baseline_ - baseline; | 
| 69     else | 69     else | 
| 70       y = (height() - pref.height()) / 2; | 70       y = (height() - pref.height()) / 2; | 
| 71     int view_width = std::min(remaining_width, pref.width()); | 71     int view_width = std::min(remaining_width, pref.width()); | 
| 72     view->SetBounds(x, y, view_width, pref.height()); | 72     view->SetBounds(x, y, view_width, pref.height()); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 100   const ui::ThemeProvider* theme_provider = GetThemeProvider(); | 100   const ui::ThemeProvider* theme_provider = GetThemeProvider(); | 
| 101   if (!theme_provider) | 101   if (!theme_provider) | 
| 102     return; | 102     return; | 
| 103   updated_colors_ = true; | 103   updated_colors_ = true; | 
| 104   SkColor text_color = | 104   SkColor text_color = | 
| 105       theme_provider->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); | 105       theme_provider->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT); | 
| 106   instructions_->SetColor(text_color); | 106   instructions_->SetColor(text_color); | 
| 107   if (import_link_) | 107   if (import_link_) | 
| 108     import_link_->SetColor(text_color); | 108     import_link_->SetColor(text_color); | 
| 109 } | 109 } | 
| OLD | NEW | 
|---|