Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1100)

Side by Side Diff: chrome/browser/chromeos/ui/idle_app_name_notification_view.cc

Issue 2477463003: Replace ui::AXViewState with AXNodeData and AXActionData (Closed)
Patch Set: Fix test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/ui/idle_app_name_notification_view.h" 5 #include "chrome/browser/chromeos/ui/idle_app_name_notification_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/public/cpp/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/wm/window_animations.h" 11 #include "ash/wm/window_animations.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
18 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
19 #include "ui/accessibility/ax_view_state.h" 19 #include "ui/accessibility/ax_node_data.h"
20 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
21 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/compositor/layer_animation_observer.h" 23 #include "ui/compositor/layer_animation_observer.h"
24 #include "ui/compositor/scoped_layer_animation_settings.h" 24 #include "ui/compositor/scoped_layer_animation_settings.h"
25 #include "ui/gfx/canvas.h" 25 #include "ui/gfx/canvas.h"
26 #include "ui/gfx/font_list.h" 26 #include "ui/gfx/font_list.h"
27 #include "ui/gfx/text_utils.h" 27 #include "ui/gfx/text_utils.h"
28 #include "ui/views/controls/label.h" 28 #include "ui/views/controls/label.h"
29 #include "ui/views/layout/box_layout.h" 29 #include "ui/views/layout/box_layout.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 void OnPaint(gfx::Canvas* canvas) override { 168 void OnPaint(gfx::Canvas* canvas) override {
169 SkPaint paint; 169 SkPaint paint;
170 paint.setStyle(SkPaint::kFill_Style); 170 paint.setStyle(SkPaint::kFill_Style);
171 paint.setColor(kWindowBackgroundColor); 171 paint.setColor(kWindowBackgroundColor);
172 canvas->DrawRoundRect(GetLocalBounds(), kWindowCornerRadius, paint); 172 canvas->DrawRoundRect(GetLocalBounds(), kWindowCornerRadius, paint);
173 views::WidgetDelegateView::OnPaint(canvas); 173 views::WidgetDelegateView::OnPaint(canvas);
174 } 174 }
175 175
176 void GetAccessibleState(ui::AXViewState* state) override { 176 void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
177 state->name = spoken_text_; 177 node_data->SetName(spoken_text_);
178 state->role = ui::AX_ROLE_ALERT; 178 node_data->role = ui::AX_ROLE_ALERT;
179 } 179 }
180 180
181 // ImplicitAnimationObserver overrides 181 // ImplicitAnimationObserver overrides
182 void OnImplicitAnimationsCompleted() override { Close(); } 182 void OnImplicitAnimationsCompleted() override { Close(); }
183 183
184 private: 184 private:
185 // Adds the label to the view, using |text| with a |font| and a |text_color|. 185 // Adds the label to the view, using |text| with a |font| and a |text_color|.
186 void AddLabel(const base::string16& text, 186 void AddLabel(const base::string16& text,
187 const gfx::FontList& font, 187 const gfx::FontList& font,
188 SkColor text_color) { 188 SkColor text_color) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 view_ = NULL; 230 view_ = NULL;
231 view->Close(); 231 view->Close();
232 } 232 }
233 } 233 }
234 234
235 bool IdleAppNameNotificationView::IsVisible() { 235 bool IdleAppNameNotificationView::IsVisible() {
236 return view_ != NULL; 236 return view_ != NULL;
237 } 237 }
238 238
239 base::string16 IdleAppNameNotificationView::GetShownTextForTest() { 239 base::string16 IdleAppNameNotificationView::GetShownTextForTest() {
240 ui::AXViewState state; 240 ui::AXNodeData node_data;
241 DCHECK(view_); 241 DCHECK(view_);
242 view_->GetAccessibleState(&state); 242 view_->GetAccessibleNodeData(&node_data);
243 return state.name; 243 return node_data.GetString16Attribute(ui::AX_ATTR_NAME);
244 } 244 }
245 245
246 void IdleAppNameNotificationView::ShowMessage( 246 void IdleAppNameNotificationView::ShowMessage(
247 int message_visibility_time_in_ms, 247 int message_visibility_time_in_ms,
248 int animation_time_ms, 248 int animation_time_ms,
249 const extensions::Extension* extension) { 249 const extensions::Extension* extension) {
250 DCHECK(!view_); 250 DCHECK(!view_);
251 251
252 base::string16 app_name; 252 base::string16 app_name;
253 bool error = false; 253 bool error = false;
254 if (extension && 254 if (extension &&
255 !base::ContainsOnlyChars(extension->name(), base::kWhitespaceASCII)) { 255 !base::ContainsOnlyChars(extension->name(), base::kWhitespaceASCII)) {
256 app_name = base::UTF8ToUTF16(extension->name()); 256 app_name = base::UTF8ToUTF16(extension->name());
257 } else { 257 } else {
258 error = true; 258 error = true;
259 app_name = l10n_util::GetStringUTF16( 259 app_name = l10n_util::GetStringUTF16(
260 IDS_IDLE_APP_NAME_UNKNOWN_APPLICATION_NOTIFICATION); 260 IDS_IDLE_APP_NAME_UNKNOWN_APPLICATION_NOTIFICATION);
261 } 261 }
262 262
263 view_ = new IdleAppNameNotificationDelegateView( 263 view_ = new IdleAppNameNotificationDelegateView(
264 this, 264 this,
265 app_name, 265 app_name,
266 error, 266 error,
267 message_visibility_time_in_ms + animation_time_ms); 267 message_visibility_time_in_ms + animation_time_ms);
268 CreateAndShowWidget(view_, animation_time_ms); 268 CreateAndShowWidget(view_, animation_time_ms);
269 } 269 }
270 270
271 } // namespace chromeos 271 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/options/network_config_view.cc ('k') | chrome/browser/download/download_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698