Chromium Code Reviews| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 } | 217 } |
| 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) { |
| 227 DCHECK(find_text_); | |
|
Finnur
2010/11/15 14:49:12
This is redundant and just adds cruft to debug bui
altimofeev
2010/11/15 15:36:19
Done.
| |
| 226 find_text_->RequestFocus(); | 228 find_text_->RequestFocus(); |
| 229 // Storing is needed here because view that has focus before wrench menu | |
| 230 // activation will be activated just after wrench menu is closed. FindBar | |
| 231 // has it's own focus tracker, so it will focus correct view on close. | |
|
Finnur
2010/11/15 14:49:12
nit: I count four instances of the word 'the' bein
altimofeev
2010/11/15 15:36:19
Thanks, will try to improve my grammar.
| |
| 232 DCHECK(find_text_->GetFocusManager()); | |
|
Finnur
2010/11/15 14:49:12
Same here (don't need the DCHECK)
altimofeev
2010/11/15 15:36:19
Done.
| |
| 233 find_text_->GetFocusManager()->StoreFocusedView(); | |
|
Finnur
2010/11/15 14:49:12
Make sure the following use case works (I think yo
altimofeev
2010/11/15 15:36:19
I have tried your use case. The focus behaves as i
| |
| 227 if (select_all && !find_text_->text().empty()) | 234 if (select_all && !find_text_->text().empty()) |
| 228 find_text_->SelectAll(); | 235 find_text_->SelectAll(); |
| 229 } | 236 } |
| 230 | 237 |
| 231 /////////////////////////////////////////////////////////////////////////////// | 238 /////////////////////////////////////////////////////////////////////////////// |
| 232 // FindBarView, views::View overrides: | 239 // FindBarView, views::View overrides: |
| 233 | 240 |
| 234 void FindBarView::Paint(gfx::Canvas* canvas) { | 241 void FindBarView::Paint(gfx::Canvas* canvas) { |
| 235 SkPaint paint; | 242 SkPaint paint; |
| 236 | 243 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 | 525 |
| 519 void FindBarView::OnThemeChanged() { | 526 void FindBarView::OnThemeChanged() { |
| 520 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 527 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 521 if (GetThemeProvider()) { | 528 if (GetThemeProvider()) { |
| 522 close_button_->SetBackground( | 529 close_button_->SetBackground( |
| 523 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), | 530 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), |
| 524 rb.GetBitmapNamed(IDR_CLOSE_BAR), | 531 rb.GetBitmapNamed(IDR_CLOSE_BAR), |
| 525 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); | 532 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); |
| 526 } | 533 } |
| 527 } | 534 } |
| OLD | NEW |