OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/find_bar_view.h" | 5 #include "chrome/browser/ui/views/find_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 14 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
15 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 15 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
16 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" | 16 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" |
17 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 17 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
18 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 18 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
19 #include "chrome/browser/ui/view_ids.h" | 19 #include "chrome/browser/ui/view_ids.h" |
20 #include "chrome/browser/ui/views/find_bar_host.h" | 20 #include "chrome/browser/ui/views/find_bar_host.h" |
21 #include "chrome/browser/ui/views/frame/browser_view.h" | 21 #include "chrome/browser/ui/views/frame/browser_view.h" |
22 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
23 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
24 #include "third_party/skia/include/core/SkPaint.h" | 24 #include "third_party/skia/include/core/SkPaint.h" |
25 #include "ui/base/ime/input_method.h" | |
25 #include "ui/base/ime/text_input_flags.h" | 26 #include "ui/base/ime/text_input_flags.h" |
26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
28 #include "ui/base/theme_provider.h" | 29 #include "ui/base/theme_provider.h" |
29 #include "ui/events/event.h" | 30 #include "ui/events/event.h" |
30 #include "ui/gfx/canvas.h" | 31 #include "ui/gfx/canvas.h" |
31 #include "ui/resources/grit/ui_resources.h" | 32 #include "ui/resources/grit/ui_resources.h" |
32 #include "ui/views/border.h" | 33 #include "ui/views/border.h" |
33 #include "ui/views/controls/button/image_button.h" | 34 #include "ui/views/controls/button/image_button.h" |
34 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
35 #include "ui/views/ime/input_method.h" | |
36 #include "ui/views/painter.h" | 36 #include "ui/views/painter.h" |
37 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
38 | 38 |
39 namespace { | 39 namespace { |
40 | 40 |
41 // The margins around the UI controls, derived from assets and design specs. | 41 // The margins around the UI controls, derived from assets and design specs. |
42 const int kMarginLeftOfCloseButton = 3; | 42 const int kMarginLeftOfCloseButton = 3; |
43 const int kMarginRightOfCloseButton = 7; | 43 const int kMarginRightOfCloseButton = 7; |
44 const int kMarginLeftOfMatchCountLabel = 3; | 44 const int kMarginLeftOfMatchCountLabel = 3; |
45 const int kMarginRightOfMatchCountLabel = 1; | 45 const int kMarginRightOfMatchCountLabel = 1; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 | 227 |
228 void FindBarView::ClearMatchCount() { | 228 void FindBarView::ClearMatchCount() { |
229 match_count_text_->SetText(base::string16()); | 229 match_count_text_->SetText(base::string16()); |
230 UpdateMatchCountAppearance(false); | 230 UpdateMatchCountAppearance(false); |
231 Layout(); | 231 Layout(); |
232 SchedulePaint(); | 232 SchedulePaint(); |
233 } | 233 } |
234 | 234 |
235 void FindBarView::SetFocusAndSelection(bool select_all) { | 235 void FindBarView::SetFocusAndSelection(bool select_all) { |
236 find_text_->RequestFocus(); | 236 find_text_->RequestFocus(); |
237 GetInputMethod()->ShowImeIfNeeded(); | 237 GetWidget()->GetInputMethod()->ShowImeIfNeeded(); |
sky
2015/06/29 02:17:41
Shouldn't focusing find_text_ take care of showing
Shu Chen
2015/06/29 02:56:34
Textfield::ShowImeIfNeeded() is only called for fo
sky
2015/06/30 16:32:31
That makes sense, but I couldn't readily determine
Shu Chen
2015/07/01 02:38:57
For mouse/touch events, Textfield can take care of
| |
238 if (select_all && !find_text_->text().empty()) | 238 if (select_all && !find_text_->text().empty()) |
239 find_text_->SelectAll(true); | 239 find_text_->SelectAll(true); |
240 } | 240 } |
241 | 241 |
242 /////////////////////////////////////////////////////////////////////////////// | 242 /////////////////////////////////////////////////////////////////////////////// |
243 // FindBarView, views::View overrides: | 243 // FindBarView, views::View overrides: |
244 | 244 |
245 void FindBarView::OnPaint(gfx::Canvas* canvas) { | 245 void FindBarView::OnPaint(gfx::Canvas* canvas) { |
246 // Paint drop down bar border and background. | 246 // Paint drop down bar border and background. |
247 DropdownBarView::OnPaint(canvas); | 247 DropdownBarView::OnPaint(canvas); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 | 503 |
504 void FindBarView::OnThemeChanged() { | 504 void FindBarView::OnThemeChanged() { |
505 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 505 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
506 if (GetThemeProvider()) { | 506 if (GetThemeProvider()) { |
507 close_button_->SetBackground( | 507 close_button_->SetBackground( |
508 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), | 508 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), |
509 rb.GetImageSkiaNamed(IDR_CLOSE_1), | 509 rb.GetImageSkiaNamed(IDR_CLOSE_1), |
510 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); | 510 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); |
511 } | 511 } |
512 } | 512 } |
OLD | NEW |