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