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/views/find_bar_view.h" | 5 #include "chrome/browser/views/find_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/find_bar_controller.h" | 14 #include "chrome/browser/find_bar_controller.h" |
15 #include "chrome/browser/find_bar_state.h" | 15 #include "chrome/browser/find_bar_state.h" |
16 #include "chrome/browser/profile.h" | 16 #include "chrome/browser/profile.h" |
17 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
18 #include "chrome/browser/themes/browser_theme_provider.h" | 18 #include "chrome/browser/themes/browser_theme_provider.h" |
19 #include "chrome/browser/view_ids.h" | 19 #include "chrome/browser/view_ids.h" |
20 #include "chrome/browser/views/find_bar_host.h" | 20 #include "chrome/browser/views/find_bar_host.h" |
21 #include "chrome/browser/views/frame/browser_view.h" | 21 #include "chrome/browser/views/frame/browser_view.h" |
22 #include "gfx/canvas.h" | 22 #include "gfx/canvas.h" |
23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
24 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
25 #include "third_party/skia/include/effects/SkGradientShader.h" | 25 #include "third_party/skia/include/effects/SkGradientShader.h" |
26 #include "views/background.h" | 26 #include "views/background.h" |
27 #include "views/controls/button/image_button.h" | 27 #include "views/controls/button/image_button.h" |
28 #include "views/controls/label.h" | 28 #include "views/controls/label.h" |
29 #include "views/focus/focus_manager.h" | |
29 #include "views/widget/widget.h" | 30 #include "views/widget/widget.h" |
30 | 31 |
31 // The amount of whitespace to have before the find button. | 32 // The amount of whitespace to have before the find button. |
32 static const int kWhiteSpaceAfterMatchCountLabel = 1; | 33 static const int kWhiteSpaceAfterMatchCountLabel = 1; |
33 | 34 |
34 // The margins around the search field and the close button. | 35 // The margins around the search field and the close button. |
35 static const int kMarginLeftOfCloseButton = 3; | 36 static const int kMarginLeftOfCloseButton = 3; |
36 static const int kMarginRightOfCloseButton = 7; | 37 static const int kMarginRightOfCloseButton = 7; |
37 static const int kMarginLeftOfFindTextfield = 12; | 38 static const int kMarginLeftOfFindTextfield = 12; |
38 | 39 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 | 218 |
218 // The match_count label may have increased/decreased in size so we need to | 219 // The match_count label may have increased/decreased in size so we need to |
219 // do a layout and repaint the dialog so that the find text field doesn't | 220 // do a layout and repaint the dialog so that the find text field doesn't |
220 // partially overlap the match-count label when it increases on no matches. | 221 // partially overlap the match-count label when it increases on no matches. |
221 Layout(); | 222 Layout(); |
222 SchedulePaint(); | 223 SchedulePaint(); |
223 } | 224 } |
224 | 225 |
225 void FindBarView::SetFocusAndSelection(bool select_all) { | 226 void FindBarView::SetFocusAndSelection(bool select_all) { |
226 find_text_->RequestFocus(); | 227 find_text_->RequestFocus(); |
228 // Storing is needed here because the view that has a focus before the wrench | |
Finnur
2010/11/15 16:20:30
nit: 'a focus' implies there might be more than on
altimofeev
2010/11/16 14:28:34
Done.
| |
229 // menu activation will get the focus just after the wrench menu is closed. | |
Finnur
2010/11/15 16:20:30
tiny-nit: 'focus' is enough, 'the focus' is not ne
altimofeev
2010/11/16 14:28:34
Done.
| |
230 // FindBar has it's own focus tracker, so it will focus a correct view on | |
Finnur
2010/11/15 16:20:30
nit: 'The FindBar'
nit: 'the correct view'
altimofeev
2010/11/16 14:28:34
Done.
| |
231 // the close. | |
Finnur
2010/11/15 16:20:30
nit: 'the' is not appropriate here (the pendulum h
altimofeev
2010/11/16 14:28:34
Done.
| |
232 find_text_->GetFocusManager()->StoreFocusedView(); | |
227 if (select_all && !find_text_->text().empty()) | 233 if (select_all && !find_text_->text().empty()) |
228 find_text_->SelectAll(); | 234 find_text_->SelectAll(); |
229 } | 235 } |
230 | 236 |
231 /////////////////////////////////////////////////////////////////////////////// | 237 /////////////////////////////////////////////////////////////////////////////// |
232 // FindBarView, views::View overrides: | 238 // FindBarView, views::View overrides: |
233 | 239 |
234 void FindBarView::Paint(gfx::Canvas* canvas) { | 240 void FindBarView::Paint(gfx::Canvas* canvas) { |
235 SkPaint paint; | 241 SkPaint paint; |
236 | 242 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 | 524 |
519 void FindBarView::OnThemeChanged() { | 525 void FindBarView::OnThemeChanged() { |
520 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 526 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
521 if (GetThemeProvider()) { | 527 if (GetThemeProvider()) { |
522 close_button_->SetBackground( | 528 close_button_->SetBackground( |
523 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), | 529 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), |
524 rb.GetBitmapNamed(IDR_CLOSE_BAR), | 530 rb.GetBitmapNamed(IDR_CLOSE_BAR), |
525 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); | 531 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); |
526 } | 532 } |
527 } | 533 } |
OLD | NEW |