| 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 <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 67 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 68 std::unique_ptr<base::ListValue> items = | 68 std::unique_ptr<base::ListValue> items = |
| 69 MenuModelToValue(pending_menu_->menu_model()); | 69 MenuModelToValue(pending_menu_->menu_model()); |
| 70 args->Set(webview::kContextMenuItems, items.release()); | 70 args->Set(webview::kContextMenuItems, items.release()); |
| 71 args->SetInteger(webview::kRequestId, request_id); | 71 args->SetInteger(webview::kRequestId, request_id); |
| 72 web_view_guest()->DispatchEventToView(base::MakeUnique<GuestViewEvent>( | 72 web_view_guest()->DispatchEventToView(base::MakeUnique<GuestViewEvent>( |
| 73 webview::kEventContextMenuShow, std::move(args))); | 73 webview::kEventContextMenuShow, std::move(args))); |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void ChromeWebViewGuestDelegate::OnDidInitialize() { | |
| 78 #if defined(OS_CHROMEOS) | |
| 79 if (chrome::IsRunningInMash()) { | |
| 80 NOTIMPLEMENTED(); | |
| 81 return; | |
| 82 } | |
| 83 chromeos::AccessibilityManager* accessibility_manager = | |
| 84 chromeos::AccessibilityManager::Get(); | |
| 85 CHECK(accessibility_manager); | |
| 86 accessibility_subscription_ = accessibility_manager->RegisterCallback( | |
| 87 base::Bind(&ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged, | |
| 88 weak_ptr_factory_.GetWeakPtr())); | |
| 89 #endif | |
| 90 } | |
| 91 | |
| 92 // static | 77 // static |
| 93 std::unique_ptr<base::ListValue> ChromeWebViewGuestDelegate::MenuModelToValue( | 78 std::unique_ptr<base::ListValue> ChromeWebViewGuestDelegate::MenuModelToValue( |
| 94 const ui::SimpleMenuModel& menu_model) { | 79 const ui::SimpleMenuModel& menu_model) { |
| 95 std::unique_ptr<base::ListValue> items(new base::ListValue()); | 80 std::unique_ptr<base::ListValue> items(new base::ListValue()); |
| 96 for (int i = 0; i < menu_model.GetItemCount(); ++i) { | 81 for (int i = 0; i < menu_model.GetItemCount(); ++i) { |
| 97 std::unique_ptr<base::DictionaryValue> item_value( | 82 std::unique_ptr<base::DictionaryValue> item_value( |
| 98 new base::DictionaryValue()); | 83 new base::DictionaryValue()); |
| 99 // TODO(lazyboy): We need to expose some kind of enum equivalent of | 84 // TODO(lazyboy): We need to expose some kind of enum equivalent of |
| 100 // |command_id| instead of plain integers. | 85 // |command_id| instead of plain integers. |
| 101 item_value->SetInteger(webview::kMenuItemCommandId, | 86 item_value->SetInteger(webview::kMenuItemCommandId, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 121 menu_delegate->ShowMenu(std::move(pending_menu_)); | 106 menu_delegate->ShowMenu(std::move(pending_menu_)); |
| 122 } | 107 } |
| 123 | 108 |
| 124 bool ChromeWebViewGuestDelegate::ShouldHandleFindRequestsForEmbedder() const { | 109 bool ChromeWebViewGuestDelegate::ShouldHandleFindRequestsForEmbedder() const { |
| 125 // Find requests will be handled by the guest for the Chrome signin page. | 110 // Find requests will be handled by the guest for the Chrome signin page. |
| 126 return web_view_guest_->owner_web_contents()->GetWebUI() != nullptr && | 111 return web_view_guest_->owner_web_contents()->GetWebUI() != nullptr && |
| 127 web_view_guest_->GetOwnerSiteURL().GetOrigin().spec() == | 112 web_view_guest_->GetOwnerSiteURL().GetOrigin().spec() == |
| 128 chrome::kChromeUIChromeSigninURL; | 113 chrome::kChromeUIChromeSigninURL; |
| 129 } | 114 } |
| 130 | 115 |
| 131 void ChromeWebViewGuestDelegate::InjectChromeVoxIfNeeded( | |
| 132 content::RenderViewHost* render_view_host) { | |
| 133 #if defined(OS_CHROMEOS) | |
| 134 if (!chromevox_injected_) { | |
| 135 chromeos::AccessibilityManager* manager = | |
| 136 chromeos::AccessibilityManager::Get(); | |
| 137 if (manager && manager->IsSpokenFeedbackEnabled()) { | |
| 138 manager->InjectChromeVox(render_view_host); | |
| 139 chromevox_injected_ = true; | |
| 140 } | |
| 141 } | |
| 142 #endif | |
| 143 } | |
| 144 | |
| 145 #if defined(OS_CHROMEOS) | |
| 146 void ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged( | |
| 147 const chromeos::AccessibilityStatusEventDetails& details) { | |
| 148 if (details.notification_type == chromeos::ACCESSIBILITY_MANAGER_SHUTDOWN) { | |
| 149 accessibility_subscription_.reset(); | |
| 150 } else if (details.notification_type == | |
| 151 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { | |
| 152 if (details.enabled) | |
| 153 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); | |
| 154 else | |
| 155 chromevox_injected_ = false; | |
| 156 } | |
| 157 } | |
| 158 #endif | |
| 159 | |
| 160 void ChromeWebViewGuestDelegate::SetContextMenuPosition( | 116 void ChromeWebViewGuestDelegate::SetContextMenuPosition( |
| 161 const gfx::Point& position) { | 117 const gfx::Point& position) { |
| 162 if (context_menu_position_ == nullptr) | 118 if (context_menu_position_ == nullptr) |
| 163 context_menu_position_.reset(new gfx::Point()); | 119 context_menu_position_.reset(new gfx::Point()); |
| 164 | 120 |
| 165 *context_menu_position_ = position; | 121 *context_menu_position_ = position; |
| 166 } | 122 } |
| 167 | 123 |
| 168 } // namespace extensions | 124 } // namespace extensions |
| OLD | NEW |