| 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 "chrome/browser/ui/zoom/zoom_observer.h" | 9 #include "chrome/browser/ui/zoom/zoom_observer.h" |
| 10 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 10 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 11 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h" | 11 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h" |
| 12 | 12 |
| 13 #if defined(OS_CHROMEOS) | 13 #if defined(OS_CHROMEOS) |
| 14 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 14 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 class RenderViewContextMenu; | 17 class RenderViewContextMenu; |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 class SimpleMenuModel; | 20 class SimpleMenuModel; |
| 21 } // namespace ui | 21 } // namespace ui |
| 22 | 22 |
| 23 class ChromeWebViewGuestDelegate : public extensions::WebViewGuestDelegate, | 23 namespace extensions { |
| 24 |
| 25 class ChromeWebViewGuestDelegate : public WebViewGuestDelegate, |
| 24 public ZoomObserver { | 26 public ZoomObserver { |
| 25 public : | 27 public : |
| 26 explicit ChromeWebViewGuestDelegate( | 28 explicit ChromeWebViewGuestDelegate(WebViewGuest* web_view_guest); |
| 27 extensions::WebViewGuest* web_view_guest); | |
| 28 ~ChromeWebViewGuestDelegate() override; | 29 ~ChromeWebViewGuestDelegate() override; |
| 29 | 30 |
| 30 // WebViewGuestDelegate implementation. | 31 // WebViewGuestDelegate implementation. |
| 31 double GetZoom() override; | 32 double GetZoom() override; |
| 32 bool HandleContextMenu(const content::ContextMenuParams& params) override; | 33 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
| 33 void OnAttachWebViewHelpers(content::WebContents* contents) override; | 34 void OnAttachWebViewHelpers(content::WebContents* contents) override; |
| 34 void OnDidAttachToEmbedder() override; | 35 void OnDidAttachToEmbedder() override; |
| 35 void OnDidCommitProvisionalLoadForFrame(bool is_main_frame) override; | 36 void OnDidCommitProvisionalLoadForFrame(bool is_main_frame) override; |
| 36 void OnDidInitialize() override; | 37 void OnDidInitialize() override; |
| 37 void OnDocumentLoadedInFrame( | 38 void OnDocumentLoadedInFrame( |
| 38 content::RenderFrameHost* render_frame_host) override; | 39 content::RenderFrameHost* render_frame_host) override; |
| 39 void OnGuestReady() override; | 40 void OnGuestReady() override; |
| 40 void OnGuestDestroyed() override; | 41 void OnGuestDestroyed() override; |
| 41 void OnSetZoom(double zoom_factor) override; | 42 void OnSetZoom(double zoom_factor) override; |
| 42 void OnShowContextMenu(int request_id, const MenuItemVector* items) override; | 43 void OnShowContextMenu(int request_id, const MenuItemVector* items) override; |
| 43 | 44 |
| 44 // ZoomObserver implementation. | 45 // ZoomObserver implementation. |
| 45 void OnZoomChanged(const ZoomController::ZoomChangedEventData& data) override; | 46 void OnZoomChanged(const ZoomController::ZoomChangedEventData& data) override; |
| 46 | 47 |
| 47 extensions::WebViewGuest* web_view_guest() const { return web_view_guest_; } | 48 WebViewGuest* web_view_guest() const { return web_view_guest_; } |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 content::WebContents* guest_web_contents() const { | 51 content::WebContents* guest_web_contents() const { |
| 51 return web_view_guest()->web_contents(); | 52 return web_view_guest()->web_contents(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 // Returns the top level items (ignoring submenus) as Value. | 55 // Returns the top level items (ignoring submenus) as Value. |
| 55 static scoped_ptr<base::ListValue> MenuModelToValue( | 56 static scoped_ptr<base::ListValue> MenuModelToValue( |
| 56 const ui::SimpleMenuModel& menu_model); | 57 const ui::SimpleMenuModel& menu_model); |
| 57 | 58 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 76 // Holds the RenderViewContextMenu that has been built but yet to be | 77 // Holds the RenderViewContextMenu that has been built but yet to be |
| 77 // shown. This is .Reset() after ShowContextMenu(). | 78 // shown. This is .Reset() after ShowContextMenu(). |
| 78 scoped_ptr<RenderViewContextMenu> pending_menu_; | 79 scoped_ptr<RenderViewContextMenu> pending_menu_; |
| 79 | 80 |
| 80 #if defined(OS_CHROMEOS) | 81 #if defined(OS_CHROMEOS) |
| 81 // Subscription to receive notifications on changes to a11y settings. | 82 // Subscription to receive notifications on changes to a11y settings. |
| 82 scoped_ptr<chromeos::AccessibilityStatusSubscription> | 83 scoped_ptr<chromeos::AccessibilityStatusSubscription> |
| 83 accessibility_subscription_; | 84 accessibility_subscription_; |
| 84 #endif | 85 #endif |
| 85 | 86 |
| 86 extensions::WebViewGuest* const web_view_guest_; | 87 WebViewGuest* const web_view_guest_; |
| 87 | 88 |
| 88 // This is used to ensure pending tasks will not fire after this object is | 89 // This is used to ensure pending tasks will not fire after this object is |
| 89 // destroyed. | 90 // destroyed. |
| 90 base::WeakPtrFactory<ChromeWebViewGuestDelegate> weak_ptr_factory_; | 91 base::WeakPtrFactory<ChromeWebViewGuestDelegate> weak_ptr_factory_; |
| 91 | 92 |
| 92 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewGuestDelegate); | 93 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewGuestDelegate); |
| 93 }; | 94 }; |
| 94 | 95 |
| 96 } // namespace extensions |
| 97 |
| 95 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ | 98 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_ |
| 96 | 99 |
| OLD | NEW |