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

Side by Side Diff: chrome/browser/accessibility/accessibility_extension_api.cc

Issue 2298493003: [Extensions] Convert some ChromeSyncExtensionFunctions (Closed)
Patch Set: fix Created 4 years, 3 months 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 (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/accessibility/accessibility_extension_api.h" 5 #include "chrome/browser/accessibility/accessibility_extension_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 30 matching lines...) Expand all
41 // ScreenRect fields. 41 // ScreenRect fields.
42 const char kLeft[] = "left"; 42 const char kLeft[] = "left";
43 const char kTop[] = "top"; 43 const char kTop[] = "top";
44 const char kWidth[] = "width"; 44 const char kWidth[] = "width";
45 const char kHeight[] = "height"; 45 const char kHeight[] = "height";
46 #endif // defined(OS_CHROMEOS) 46 #endif // defined(OS_CHROMEOS)
47 47
48 const char kErrorNotSupported[] = "This API is not supported on this platform."; 48 const char kErrorNotSupported[] = "This API is not supported on this platform.";
49 } // namespace 49 } // namespace
50 50
51 bool AccessibilityPrivateSetNativeAccessibilityEnabledFunction::RunSync() { 51 ExtensionFunction::ResponseAction
52 bool enabled; 52 AccessibilityPrivateSetNativeAccessibilityEnabledFunction::Run() {
53 bool enabled = false;
53 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); 54 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled));
54 if (enabled) { 55 if (enabled) {
55 content::BrowserAccessibilityState::GetInstance()-> 56 content::BrowserAccessibilityState::GetInstance()->
56 EnableAccessibility(); 57 EnableAccessibility();
57 } else { 58 } else {
58 content::BrowserAccessibilityState::GetInstance()-> 59 content::BrowserAccessibilityState::GetInstance()->
59 DisableAccessibility(); 60 DisableAccessibility();
60 } 61 }
61 return true; 62 return RespondNow(NoArguments());
62 } 63 }
63 64
64 bool AccessibilityPrivateSetFocusRingFunction::RunSync() { 65 ExtensionFunction::ResponseAction
66 AccessibilityPrivateSetFocusRingFunction::Run() {
65 #if defined(OS_CHROMEOS) 67 #if defined(OS_CHROMEOS)
66 base::ListValue* rect_values = NULL; 68 base::ListValue* rect_values = NULL;
67 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &rect_values)); 69 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &rect_values));
68 70
69 std::vector<gfx::Rect> rects; 71 std::vector<gfx::Rect> rects;
70 for (size_t i = 0; i < rect_values->GetSize(); ++i) { 72 for (size_t i = 0; i < rect_values->GetSize(); ++i) {
71 base::DictionaryValue* rect_value = NULL; 73 base::DictionaryValue* rect_value = NULL;
72 EXTENSION_FUNCTION_VALIDATE(rect_values->GetDictionary(i, &rect_value)); 74 EXTENSION_FUNCTION_VALIDATE(rect_values->GetDictionary(i, &rect_value));
73 int left, top, width, height; 75 int left, top, width, height;
74 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kLeft, &left)); 76 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kLeft, &left));
75 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kTop, &top)); 77 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kTop, &top));
76 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kWidth, &width)); 78 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kWidth, &width));
77 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kHeight, &height)); 79 EXTENSION_FUNCTION_VALIDATE(rect_value->GetInteger(kHeight, &height));
78 rects.push_back(gfx::Rect(left, top, width, height)); 80 rects.push_back(gfx::Rect(left, top, width, height));
79 } 81 }
80 82
81 // Move the visible focus ring to cover all of these rects. 83 // Move the visible focus ring to cover all of these rects.
82 AccessibilityFocusRingController::GetInstance()->SetFocusRing( 84 AccessibilityFocusRingController::GetInstance()->SetFocusRing(
83 rects, AccessibilityFocusRingController::PERSIST_FOCUS_RING); 85 rects, AccessibilityFocusRingController::PERSIST_FOCUS_RING);
84 86
85 // Also update the touch exploration controller so that synthesized 87 // Also update the touch exploration controller so that synthesized
86 // touch events are anchored within the focused object. 88 // touch events are anchored within the focused object.
87 if (!rects.empty()) { 89 if (!rects.empty()) {
88 chromeos::AccessibilityManager* manager = 90 chromeos::AccessibilityManager* manager =
89 chromeos::AccessibilityManager::Get(); 91 chromeos::AccessibilityManager::Get();
90 manager->SetTouchAccessibilityAnchorPoint(rects[0].CenterPoint()); 92 manager->SetTouchAccessibilityAnchorPoint(rects[0].CenterPoint());
91 } 93 }
92 94
93 return true; 95 return RespondNow(NoArguments());
94 #endif // defined(OS_CHROMEOS) 96 #endif // defined(OS_CHROMEOS)
95 97
96 error_ = kErrorNotSupported; 98 return RespondNow(Error(kErrorNotSupported));
97 return false;
98 } 99 }
99 100
100 ExtensionFunction::ResponseAction 101 ExtensionFunction::ResponseAction
101 AccessibilityPrivateSetKeyboardListenerFunction::Run() { 102 AccessibilityPrivateSetKeyboardListenerFunction::Run() {
102 ChromeExtensionFunctionDetails details(this); 103 ChromeExtensionFunctionDetails details(this);
103 CHECK(extension()); 104 CHECK(extension());
104 105
105 #if defined(OS_CHROMEOS) 106 #if defined(OS_CHROMEOS)
106 bool enabled; 107 bool enabled;
107 bool capture; 108 bool capture;
(...skipping 14 matching lines...) Expand all
122 } else { 123 } else {
123 manager->SetKeyboardListenerExtensionId(std::string(), 124 manager->SetKeyboardListenerExtensionId(std::string(),
124 details.GetProfile()); 125 details.GetProfile());
125 manager->set_keyboard_listener_capture(false); 126 manager->set_keyboard_listener_capture(false);
126 } 127 }
127 return RespondNow(NoArguments()); 128 return RespondNow(NoArguments());
128 #endif // defined OS_CHROMEOS 129 #endif // defined OS_CHROMEOS
129 130
130 return RespondNow(Error(kErrorNotSupported)); 131 return RespondNow(Error(kErrorNotSupported));
131 } 132 }
OLDNEW
« no previous file with comments | « chrome/browser/accessibility/accessibility_extension_api.h ('k') | chrome/browser/chromeos/extensions/echo_private_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698