| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_EVENT_H_ |
| 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_EVENT_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "content/browser/accessibility/browser_accessibility.h" |
| 11 #include "content/common/content_export.h" |
| 12 #include "ui/accessibility/ax_enums.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 class BrowserAccessibility; |
| 17 |
| 18 class CONTENT_EXPORT BrowserAccessibilityEvent { |
| 19 public: |
| 20 enum Source { |
| 21 FromBlink, |
| 22 FromChildFrameLoading, |
| 23 FromFindInPageResult, |
| 24 FromRenderFrameHost, |
| 25 FromScroll, |
| 26 FromTreeChange, |
| 27 FromWindowFocusChange, |
| 28 }; |
| 29 |
| 30 enum Result { |
| 31 Sent, |
| 32 NotNeededOnThisPlatform, |
| 33 DiscardedBecauseUserNavigatingAway, |
| 34 DiscardedBecauseLiveRegionBusy, |
| 35 FailedBecauseNoWindow, |
| 36 FailedBecauseNoFocus, |
| 37 FailedBecauseFrameIsDetached, |
| 38 }; |
| 39 |
| 40 // Returns true if the given result indicates that sending the event failed. |
| 41 // Returns false if the event was sent, or if it was not needed (which is |
| 42 // not considered failure). |
| 43 static bool FailedToSend(Result result); |
| 44 |
| 45 static BrowserAccessibilityEvent* Create(Source source, |
| 46 ui::AXEvent event_type, |
| 47 const BrowserAccessibility* target); |
| 48 |
| 49 // Construct a new accessibility event that should be sent via a |
| 50 // platform-specific notification. |
| 51 BrowserAccessibilityEvent(Source source, |
| 52 ui::AXEvent event_type, |
| 53 const BrowserAccessibility* target); |
| 54 virtual ~BrowserAccessibilityEvent(); |
| 55 |
| 56 // Synchronously try to send the native accessibility event notification |
| 57 // and return a result indicating the outcome. This deletes the event. |
| 58 virtual Result Fire(); |
| 59 |
| 60 Source source() { return source_; } |
| 61 ui::AXEvent event_type() { return event_type_; } |
| 62 const BrowserAccessibility* target() { return target_; } |
| 63 void set_target(const BrowserAccessibility* target) { target_ = target; } |
| 64 void set_original_target(BrowserAccessibility* target) { |
| 65 original_target_ = target; |
| 66 } |
| 67 |
| 68 protected: |
| 69 virtual std::string GetEventNameStr(); |
| 70 void VerboseLog(Result result); |
| 71 |
| 72 private: |
| 73 Source source_; |
| 74 ui::AXEvent event_type_; |
| 75 const BrowserAccessibility* target_; |
| 76 const BrowserAccessibility* original_target_; |
| 77 |
| 78 private: |
| 79 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityEvent); |
| 80 }; |
| 81 |
| 82 } // namespace content |
| 83 |
| 84 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_EVENT_H_ |
| OLD | NEW |