OLD | NEW |
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 | 5 |
6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h" | 6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h" |
7 | 7 |
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
9 #include "chrome/browser/favicon/favicon_helper.h" | 9 #include "chrome/browser/favicon/favicon_helper.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #endif // defined(ENABLE_PRINT_PREVIEW) | 28 #endif // defined(ENABLE_PRINT_PREVIEW) |
29 #endif // defined(ENABLE_PRINTING) | 29 #endif // defined(ENABLE_PRINTING) |
30 | 30 |
31 using guest_view::GuestViewEvent; | 31 using guest_view::GuestViewEvent; |
32 | 32 |
33 namespace extensions { | 33 namespace extensions { |
34 | 34 |
35 ChromeWebViewGuestDelegate::ChromeWebViewGuestDelegate( | 35 ChromeWebViewGuestDelegate::ChromeWebViewGuestDelegate( |
36 WebViewGuest* web_view_guest) | 36 WebViewGuest* web_view_guest) |
37 : pending_context_menu_request_id_(0), | 37 : pending_context_menu_request_id_(0), |
| 38 chromevox_injected_(false), |
38 web_view_guest_(web_view_guest), | 39 web_view_guest_(web_view_guest), |
39 weak_ptr_factory_(this) { | 40 weak_ptr_factory_(this) { |
40 } | 41 } |
41 | 42 |
42 ChromeWebViewGuestDelegate::~ChromeWebViewGuestDelegate() { | 43 ChromeWebViewGuestDelegate::~ChromeWebViewGuestDelegate() { |
43 } | 44 } |
44 | 45 |
45 bool ChromeWebViewGuestDelegate::HandleContextMenu( | 46 bool ChromeWebViewGuestDelegate::HandleContextMenu( |
46 const content::ContextMenuParams& params) { | 47 const content::ContextMenuParams& params) { |
47 ContextMenuDelegate* menu_delegate = | 48 ContextMenuDelegate* menu_delegate = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 #else | 81 #else |
81 printing::PrintViewManagerBasic::CreateForWebContents(contents); | 82 printing::PrintViewManagerBasic::CreateForWebContents(contents); |
82 #endif // defined(ENABLE_PRINT_PREVIEW) | 83 #endif // defined(ENABLE_PRINT_PREVIEW) |
83 #endif // defined(ENABLE_PRINTING) | 84 #endif // defined(ENABLE_PRINTING) |
84 pdf::PDFWebContentsHelper::CreateForWebContentsWithClient( | 85 pdf::PDFWebContentsHelper::CreateForWebContentsWithClient( |
85 contents, | 86 contents, |
86 scoped_ptr<pdf::PDFWebContentsHelperClient>( | 87 scoped_ptr<pdf::PDFWebContentsHelperClient>( |
87 new ChromePDFWebContentsHelperClient())); | 88 new ChromePDFWebContentsHelperClient())); |
88 } | 89 } |
89 | 90 |
| 91 void ChromeWebViewGuestDelegate::OnDidInitialize() { |
| 92 #if defined(OS_CHROMEOS) |
| 93 chromeos::AccessibilityManager* accessibility_manager = |
| 94 chromeos::AccessibilityManager::Get(); |
| 95 CHECK(accessibility_manager); |
| 96 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
| 97 base::Bind(&ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged, |
| 98 weak_ptr_factory_.GetWeakPtr())); |
| 99 #endif |
| 100 } |
| 101 |
90 void ChromeWebViewGuestDelegate::OnGuestDestroyed() { | 102 void ChromeWebViewGuestDelegate::OnGuestDestroyed() { |
91 // Clean up custom context menu items for this guest. | 103 // Clean up custom context menu items for this guest. |
92 MenuManager* menu_manager = MenuManager::Get( | 104 MenuManager* menu_manager = MenuManager::Get( |
93 Profile::FromBrowserContext(web_view_guest()->browser_context())); | 105 Profile::FromBrowserContext(web_view_guest()->browser_context())); |
94 menu_manager->RemoveAllContextItems(MenuItem::ExtensionKey( | 106 menu_manager->RemoveAllContextItems(MenuItem::ExtensionKey( |
95 web_view_guest()->owner_host(), | 107 web_view_guest()->owner_host(), |
96 web_view_guest()->view_instance_id())); | 108 web_view_guest()->view_instance_id())); |
97 } | 109 } |
98 | 110 |
99 // static | 111 // static |
(...skipping 23 matching lines...) Expand all Loading... |
123 return; | 135 return; |
124 | 136 |
125 // TODO(lazyboy): Implement. | 137 // TODO(lazyboy): Implement. |
126 DCHECK(!items); | 138 DCHECK(!items); |
127 | 139 |
128 ContextMenuDelegate* menu_delegate = | 140 ContextMenuDelegate* menu_delegate = |
129 ContextMenuDelegate::FromWebContents(guest_web_contents()); | 141 ContextMenuDelegate::FromWebContents(guest_web_contents()); |
130 menu_delegate->ShowMenu(pending_menu_.Pass()); | 142 menu_delegate->ShowMenu(pending_menu_.Pass()); |
131 } | 143 } |
132 | 144 |
| 145 void ChromeWebViewGuestDelegate::InjectChromeVoxIfNeeded( |
| 146 content::RenderViewHost* render_view_host) { |
| 147 #if defined(OS_CHROMEOS) |
| 148 if (!chromevox_injected_) { |
| 149 chromeos::AccessibilityManager* manager = |
| 150 chromeos::AccessibilityManager::Get(); |
| 151 if (manager && manager->IsSpokenFeedbackEnabled()) { |
| 152 manager->InjectChromeVox(render_view_host); |
| 153 chromevox_injected_ = true; |
| 154 } |
| 155 } |
| 156 #endif |
| 157 } |
| 158 |
| 159 #if defined(OS_CHROMEOS) |
| 160 void ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged( |
| 161 const chromeos::AccessibilityStatusEventDetails& details) { |
| 162 if (details.notification_type == chromeos::ACCESSIBILITY_MANAGER_SHUTDOWN) { |
| 163 accessibility_subscription_.reset(); |
| 164 } else if (details.notification_type == |
| 165 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { |
| 166 if (details.enabled) |
| 167 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); |
| 168 else |
| 169 chromevox_injected_ = false; |
| 170 } |
| 171 } |
| 172 #endif |
| 173 |
133 } // namespace extensions | 174 } // namespace extensions |
OLD | NEW |