| 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 "ui/app_list/views/search_result_view.h" | 5 #include "ui/app_list/views/search_result_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
| 10 #include "ui/app_list/app_list_switches.h" | 11 #include "ui/app_list/app_list_switches.h" |
| 11 #include "ui/app_list/search_result.h" | 12 #include "ui/app_list/search_result.h" |
| 12 #include "ui/app_list/views/progress_bar_view.h" | 13 #include "ui/app_list/views/progress_bar_view.h" |
| 13 #include "ui/app_list/views/search_result_actions_view.h" | 14 #include "ui/app_list/views/search_result_actions_view.h" |
| 14 #include "ui/app_list/views/search_result_list_view.h" | 15 #include "ui/app_list/views/search_result_list_view.h" |
| 15 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 16 #include "ui/gfx/font.h" | 17 #include "ui/gfx/font.h" |
| 17 #include "ui/gfx/image/image_skia_operations.h" | 18 #include "ui/gfx/image/image_skia_operations.h" |
| 18 #include "ui/gfx/render_text.h" | 19 #include "ui/gfx/render_text.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 result_ = NULL; | 110 result_ = NULL; |
| 110 } | 111 } |
| 111 | 112 |
| 112 void SearchResultView::ClearSelectedAction() { | 113 void SearchResultView::ClearSelectedAction() { |
| 113 actions_view_->SetSelectedAction(-1); | 114 actions_view_->SetSelectedAction(-1); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void SearchResultView::UpdateTitleText() { | 117 void SearchResultView::UpdateTitleText() { |
| 117 if (!result_ || result_->title().empty()) { | 118 if (!result_ || result_->title().empty()) { |
| 118 title_text_.reset(); | 119 title_text_.reset(); |
| 119 SetAccessibleName(base::string16()); | |
| 120 } else { | 120 } else { |
| 121 title_text_.reset(CreateRenderText(result_->title(), | 121 title_text_.reset(CreateRenderText(result_->title(), |
| 122 result_->title_tags())); | 122 result_->title_tags())); |
| 123 SetAccessibleName(result_->title()); | |
| 124 } | 123 } |
| 124 |
| 125 UpdateAccessibleName(); |
| 125 } | 126 } |
| 126 | 127 |
| 127 void SearchResultView::UpdateDetailsText() { | 128 void SearchResultView::UpdateDetailsText() { |
| 128 if (!result_ || result_->details().empty()) { | 129 if (!result_ || result_->details().empty()) { |
| 129 details_text_.reset(); | 130 details_text_.reset(); |
| 130 } else { | 131 } else { |
| 131 details_text_.reset(CreateRenderText(result_->details(), | 132 details_text_.reset(CreateRenderText(result_->details(), |
| 132 result_->details_tags())); | 133 result_->details_tags())); |
| 133 } | 134 } |
| 135 |
| 136 UpdateAccessibleName(); |
| 137 } |
| 138 |
| 139 base::string16 SearchResultView::ComputeAccessibleName() const { |
| 140 if (!result_) |
| 141 return base::string16(); |
| 142 |
| 143 base::string16 accessible_name = result_->title(); |
| 144 if (!result_->title().empty() && !result_->details().empty()) |
| 145 accessible_name += base::ASCIIToUTF16(", "); |
| 146 accessible_name += result_->details(); |
| 147 |
| 148 return accessible_name; |
| 149 } |
| 150 |
| 151 void SearchResultView::UpdateAccessibleName() { |
| 152 SetAccessibleName(ComputeAccessibleName()); |
| 134 } | 153 } |
| 135 | 154 |
| 136 const char* SearchResultView::GetClassName() const { | 155 const char* SearchResultView::GetClassName() const { |
| 137 return kViewClassName; | 156 return kViewClassName; |
| 138 } | 157 } |
| 139 | 158 |
| 140 gfx::Size SearchResultView::GetPreferredSize() const { | 159 gfx::Size SearchResultView::GetPreferredSize() const { |
| 141 return gfx::Size(kPreferredWidth, kPreferredHeight); | 160 return gfx::Size(kPreferredWidth, kPreferredHeight); |
| 142 } | 161 } |
| 143 | 162 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 if (context_menu_runner_->RunMenuAt(GetWidget(), | 366 if (context_menu_runner_->RunMenuAt(GetWidget(), |
| 348 NULL, | 367 NULL, |
| 349 gfx::Rect(point, gfx::Size()), | 368 gfx::Rect(point, gfx::Size()), |
| 350 views::MENU_ANCHOR_TOPLEFT, | 369 views::MENU_ANCHOR_TOPLEFT, |
| 351 source_type) == | 370 source_type) == |
| 352 views::MenuRunner::MENU_DELETED) | 371 views::MenuRunner::MENU_DELETED) |
| 353 return; | 372 return; |
| 354 } | 373 } |
| 355 | 374 |
| 356 } // namespace app_list | 375 } // namespace app_list |
| OLD | NEW |