| 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/bookmarks/bookmark_bar_instructions_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_instructions_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | |
| 8 | |
| 9 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/defaults.h" | 8 #include "chrome/browser/defaults.h" |
| 11 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
| 12 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "views/controls/label.h" | 12 #include "views/controls/label.h" |
| 15 #include "views/controls/link.h" | 13 #include "views/controls/link.h" |
| 16 | 14 |
| 17 namespace { | 15 namespace { |
| 18 | 16 |
| 19 // Horizontal padding, in pixels, between the link and label. | 17 // Horizontal padding, in pixels, between the link and label. |
| 20 const int kViewPadding = 6; | 18 const int kViewPadding = 6; |
| 21 | 19 |
| 22 } // namespace | 20 } // namespace |
| 23 | 21 |
| 24 BookmarkBarInstructionsView::BookmarkBarInstructionsView(Delegate* delegate) | 22 BookmarkBarInstructionsView::BookmarkBarInstructionsView(Delegate* delegate) |
| 25 : delegate_(delegate), | 23 : delegate_(delegate), |
| 26 instructions_(NULL), | 24 instructions_(NULL), |
| 27 import_link_(NULL), | 25 import_link_(NULL), |
| 28 baseline_(-1), | 26 baseline_(-1), |
| 29 updated_colors_(false) { | 27 updated_colors_(false) { |
| 30 instructions_ = new views::Label( | 28 instructions_ = new views::Label( |
| 31 l10n_util::GetStringUTF16(IDS_BOOKMARKS_NO_ITEMS)); | 29 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOKMARKS_NO_ITEMS))); |
| 32 AddChildView(instructions_); | 30 AddChildView(instructions_); |
| 33 | 31 |
| 34 if (browser_defaults::kShowImportOnBookmarkBar) { | 32 if (browser_defaults::kShowImportOnBookmarkBar) { |
| 35 import_link_ = new views::Link( | 33 import_link_ = new views::Link( |
| 36 l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_IMPORT_LINK)); | 34 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_IMPORT_LINK))); |
| 37 // We don't want the link to alter tab navigation. | 35 // We don't want the link to alter tab navigation. |
| 38 import_link_->set_focusable(false); | 36 import_link_->set_focusable(false); |
| 39 import_link_->set_listener(this); | 37 import_link_->set_listener(this); |
| 40 AddChildView(import_link_); | 38 AddChildView(import_link_); |
| 41 } | 39 } |
| 42 } | 40 } |
| 43 | 41 |
| 44 gfx::Size BookmarkBarInstructionsView::GetPreferredSize() { | 42 gfx::Size BookmarkBarInstructionsView::GetPreferredSize() { |
| 45 int ascent = 0, descent = 0, height = 0, width = 0; | 43 int ascent = 0, descent = 0, height = 0, width = 0; |
| 46 for (int i = 0; i < child_count(); ++i) { | 44 for (int i = 0; i < child_count(); ++i) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 const ui::ThemeProvider* theme_provider = GetThemeProvider(); | 104 const ui::ThemeProvider* theme_provider = GetThemeProvider(); |
| 107 if (!theme_provider) | 105 if (!theme_provider) |
| 108 return; | 106 return; |
| 109 updated_colors_ = true; | 107 updated_colors_ = true; |
| 110 SkColor text_color = | 108 SkColor text_color = |
| 111 theme_provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); | 109 theme_provider->GetColor(ThemeService::COLOR_BOOKMARK_TEXT); |
| 112 instructions_->SetColor(text_color); | 110 instructions_->SetColor(text_color); |
| 113 if (import_link_) | 111 if (import_link_) |
| 114 import_link_->SetColor(text_color); | 112 import_link_->SetColor(text_color); |
| 115 } | 113 } |
| OLD | NEW |