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 #ifndef CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ |
6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.h" | 10 #include "chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.h" |
11 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 11 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
12 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h" | 12 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h" |
13 | 13 |
14 #if defined(OS_CHROMEOS) | |
15 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | |
16 #endif | |
17 | |
18 class RenderViewContextMenuBase; | 14 class RenderViewContextMenuBase; |
19 | 15 |
20 namespace ui { | 16 namespace ui { |
21 class SimpleMenuModel; | 17 class SimpleMenuModel; |
22 } // namespace ui | 18 } // namespace ui |
23 | 19 |
24 namespace extensions { | 20 namespace extensions { |
25 | 21 |
26 class ChromeWebViewGuestDelegate : public WebViewGuestDelegate { | 22 class ChromeWebViewGuestDelegate : public WebViewGuestDelegate { |
27 public : | 23 public : |
28 explicit ChromeWebViewGuestDelegate(WebViewGuest* web_view_guest); | 24 explicit ChromeWebViewGuestDelegate(WebViewGuest* web_view_guest); |
29 ~ChromeWebViewGuestDelegate() override; | 25 ~ChromeWebViewGuestDelegate() override; |
30 | 26 |
31 // WebViewGuestDelegate implementation. | 27 // WebViewGuestDelegate implementation. |
32 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 28 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
33 void OnDidInitialize() override; | |
34 void OnShowContextMenu(int request_id) override; | 29 void OnShowContextMenu(int request_id) override; |
35 bool ShouldHandleFindRequestsForEmbedder() const override; | 30 bool ShouldHandleFindRequestsForEmbedder() const override; |
36 | 31 |
37 WebViewGuest* web_view_guest() const { return web_view_guest_; } | 32 WebViewGuest* web_view_guest() const { return web_view_guest_; } |
38 | 33 |
39 private: | 34 private: |
40 content::WebContents* guest_web_contents() const { | 35 content::WebContents* guest_web_contents() const { |
41 return web_view_guest()->web_contents(); | 36 return web_view_guest()->web_contents(); |
42 } | 37 } |
43 | 38 |
44 void SetContextMenuPosition(const gfx::Point& position) override; | 39 void SetContextMenuPosition(const gfx::Point& position) override; |
45 | 40 |
46 // Returns the top level items (ignoring submenus) as Value. | 41 // Returns the top level items (ignoring submenus) as Value. |
47 static std::unique_ptr<base::ListValue> MenuModelToValue( | 42 static std::unique_ptr<base::ListValue> MenuModelToValue( |
48 const ui::SimpleMenuModel& menu_model); | 43 const ui::SimpleMenuModel& menu_model); |
49 | 44 |
50 void InjectChromeVoxIfNeeded(content::RenderViewHost* render_view_host); | |
51 | |
52 #if defined(OS_CHROMEOS) | |
53 // Notification of a change in the state of an accessibility setting. | |
54 void OnAccessibilityStatusChanged( | |
55 const chromeos::AccessibilityStatusEventDetails& details); | |
56 #endif | |
57 | |
58 // A counter to generate a unique request id for a context menu request. | 45 // A counter to generate a unique request id for a context menu request. |
59 // We only need the ids to be unique for a given WebViewGuest. | 46 // We only need the ids to be unique for a given WebViewGuest. |
60 int pending_context_menu_request_id_; | 47 int pending_context_menu_request_id_; |
61 | 48 |
62 // Holds the RenderViewContextMenuBase that has been built but yet to be | 49 // Holds the RenderViewContextMenuBase that has been built but yet to be |
63 // shown. This is .reset() after ShowContextMenu(). | 50 // shown. This is .reset() after ShowContextMenu(). |
64 std::unique_ptr<RenderViewContextMenuBase> pending_menu_; | 51 std::unique_ptr<RenderViewContextMenuBase> pending_menu_; |
65 | 52 |
66 #if defined(OS_CHROMEOS) | |
67 // Set to |true| if ChromeVox was already injected in main frame. | |
68 bool chromevox_injected_ = false; | |
69 | |
70 // Subscription to receive notifications on changes to a11y settings. | |
71 std::unique_ptr<chromeos::AccessibilityStatusSubscription> | |
72 accessibility_subscription_; | |
73 #endif | |
74 | |
75 WebViewGuest* const web_view_guest_; | 53 WebViewGuest* const web_view_guest_; |
76 | 54 |
77 std::unique_ptr<gfx::Point> context_menu_position_; | 55 std::unique_ptr<gfx::Point> context_menu_position_; |
78 | 56 |
79 // This is used to ensure pending tasks will not fire after this object is | 57 // This is used to ensure pending tasks will not fire after this object is |
80 // destroyed. | 58 // destroyed. |
81 base::WeakPtrFactory<ChromeWebViewGuestDelegate> weak_ptr_factory_; | 59 base::WeakPtrFactory<ChromeWebViewGuestDelegate> weak_ptr_factory_; |
82 | 60 |
83 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewGuestDelegate); | 61 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewGuestDelegate); |
84 }; | 62 }; |
85 | 63 |
86 } // namespace extensions | 64 } // namespace extensions |
87 | 65 |
88 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ | 66 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ |
OLD | NEW |