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