| 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 "chrome/browser/guest_view/web_view/web_view_guest.h" | 8 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 9 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h" | 9 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h" |
| 10 | 10 |
| 11 #if defined(OS_CHROMEOS) | 11 #if defined(OS_CHROMEOS) |
| 12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 class RenderViewContextMenu; | 15 class RenderViewContextMenu; |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 class SimpleMenuModel; | 18 class SimpleMenuModel; |
| 19 } // namespace ui | 19 } // namespace ui |
| 20 | 20 |
| 21 class ChromeWebViewGuestDelegate : public extensions::WebViewGuestDelegate { | 21 class ChromeWebViewGuestDelegate : public extensions::WebViewGuestDelegate { |
| 22 public : | 22 public : |
| 23 explicit ChromeWebViewGuestDelegate( | 23 explicit ChromeWebViewGuestDelegate( |
| 24 extensions::WebViewGuest* web_view_guest); | 24 extensions::WebViewGuest* web_view_guest); |
| 25 virtual ~ChromeWebViewGuestDelegate(); | 25 virtual ~ChromeWebViewGuestDelegate(); |
| 26 | 26 |
| 27 // WebViewGuestDelegate implementation. | 27 // WebViewGuestDelegate implementation. |
| 28 virtual double GetZoom() OVERRIDE; | 28 virtual double GetZoom() OVERRIDE; |
| 29 virtual bool HandleContextMenu( | 29 virtual bool HandleContextMenu( |
| 30 const content::ContextMenuParams& params) OVERRIDE; | 30 const content::ContextMenuParams& params) OVERRIDE; |
| 31 virtual void OnAttachWebViewHelpers(content::WebContents* contents) OVERRIDE; | 31 virtual void OnAttachWebViewHelpers(content::WebContents* contents) OVERRIDE; |
| 32 virtual void OnEmbedderDestroyed() OVERRIDE; |
| 32 virtual void OnDidCommitProvisionalLoadForFrame(bool is_main_frame) OVERRIDE; | 33 virtual void OnDidCommitProvisionalLoadForFrame(bool is_main_frame) OVERRIDE; |
| 33 virtual void OnDidInitialize() OVERRIDE; | 34 virtual void OnDidInitialize() OVERRIDE; |
| 34 virtual void OnDocumentLoadedInFrame( | 35 virtual void OnDocumentLoadedInFrame( |
| 35 content::RenderFrameHost* render_frame_host) OVERRIDE; | 36 content::RenderFrameHost* render_frame_host) OVERRIDE; |
| 36 virtual void OnGuestDestroyed() OVERRIDE; | 37 virtual void OnGuestDestroyed() OVERRIDE; |
| 37 virtual void OnSetZoom(double zoom_factor) OVERRIDE; | 38 virtual void OnSetZoom(double zoom_factor) OVERRIDE; |
| 38 virtual void OnShowContextMenu( | 39 virtual void OnShowContextMenu( |
| 39 int request_id, | 40 int request_id, |
| 40 const MenuItemVector* items) OVERRIDE; | 41 const MenuItemVector* items) OVERRIDE; |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 content::WebContents* guest_web_contents() const { | 44 content::WebContents* guest_web_contents() const { |
| 44 return web_view_guest_->guest_web_contents(); | 45 return web_view_guest()->guest_web_contents(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 // Returns the top level items (ignoring submenus) as Value. | 48 // Returns the top level items (ignoring submenus) as Value. |
| 48 static scoped_ptr<base::ListValue> MenuModelToValue( | 49 static scoped_ptr<base::ListValue> MenuModelToValue( |
| 49 const ui::SimpleMenuModel& menu_model); | 50 const ui::SimpleMenuModel& menu_model); |
| 50 | 51 |
| 51 void InjectChromeVoxIfNeeded(content::RenderViewHost* render_view_host); | 52 void InjectChromeVoxIfNeeded(content::RenderViewHost* render_view_host); |
| 52 | 53 |
| 53 #if defined(OS_CHROMEOS) | 54 #if defined(OS_CHROMEOS) |
| 54 // Notification of a change in the state of an accessibility setting. | 55 // Notification of a change in the state of an accessibility setting. |
| 55 void OnAccessibilityStatusChanged( | 56 void OnAccessibilityStatusChanged( |
| 56 const chromeos::AccessibilityStatusEventDetails& details); | 57 const chromeos::AccessibilityStatusEventDetails& details); |
| 57 #endif | 58 #endif |
| 58 | 59 |
| 59 // A counter to generate a unique request id for a context menu request. | 60 // A counter to generate a unique request id for a context menu request. |
| 60 // We only need the ids to be unique for a given WebViewGuest. | 61 // We only need the ids to be unique for a given WebViewGuest. |
| 61 int pending_context_menu_request_id_; | 62 int pending_context_menu_request_id_; |
| 62 | 63 |
| 63 // Set to |true| if ChromeVox was already injected in main frame. | 64 // Set to |true| if ChromeVox was already injected in main frame. |
| 64 bool chromevox_injected_; | 65 bool chromevox_injected_; |
| 65 | 66 |
| 66 // Stores the current zoom factor. | 67 // Stores the current zoom factor. |
| 67 double current_zoom_factor_; | 68 double current_zoom_factor_; |
| 68 | 69 |
| 69 // Holds the RenderViewContextMenu that has been built but yet to be | 70 // Holds the RenderViewContextMenu that has been built but yet to be |
| 70 // shown. This is .Reset() after ShowContextMenu(). | 71 // shown. This is .Reset() after ShowContextMenu(). |
| 71 scoped_ptr<RenderViewContextMenu> pending_menu_; | 72 scoped_ptr<RenderViewContextMenu> pending_menu_; |
| 72 | 73 |
| 73 extensions::WebViewGuest* web_view_guest_; | |
| 74 | |
| 75 #if defined(OS_CHROMEOS) | 74 #if defined(OS_CHROMEOS) |
| 76 // Subscription to receive notifications on changes to a11y settings. | 75 // Subscription to receive notifications on changes to a11y settings. |
| 77 scoped_ptr<chromeos::AccessibilityStatusSubscription> | 76 scoped_ptr<chromeos::AccessibilityStatusSubscription> |
| 78 accessibility_subscription_; | 77 accessibility_subscription_; |
| 79 #endif | 78 #endif |
| 80 | 79 |
| 81 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewGuestDelegate); | 80 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewGuestDelegate); |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ | 83 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ |
| 85 | 84 |
| OLD | NEW |