Home | History | Annotate | Download | only in renderer_host
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_DICTIONARY_HELPER_H_
      6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_DICTIONARY_HELPER_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "ui/gfx/vector2d.h"
     10 
     11 namespace content {
     12 
     13 class RenderWidgetHostView;
     14 class RenderWidgetHostViewMac;
     15 class RenderWidgetHostViewPort;
     16 
     17 // A helper class to bring up definition of word for a RWHV.
     18 //
     19 // This is triggered by "Lookup in Dictionary" context menu item.
     20 // Either uses Dictionary.app or a light-weight dictionary panel, based on
     21 // system settings.
     22 class RenderWidgetHostViewMacDictionaryHelper {
     23  public:
     24   explicit RenderWidgetHostViewMacDictionaryHelper(
     25       RenderWidgetHostViewPort* view);
     26 
     27   // Overrides the view to use to bring up dictionary panel.
     28   // This |target_view| can be different from |view_|, |view_| is used to get
     29   // the current selection value where |target_view| is used to bring up the
     30   // cocoa dictionary panel.
     31   void SetTargetView(RenderWidgetHostView* target_view);
     32   void set_offset(const gfx::Vector2d& offset) { offset_ = offset; }
     33 
     34   // Brings up either Dictionary.app or a light-weight dictionary panel,
     35   // depending on system settings.
     36   void ShowDefinitionForSelection();
     37 
     38  private:
     39   // This class shows definition for this view.
     40   RenderWidgetHostViewMac* view_;
     41   // This view is use to bring up the dictionary panel. Generally this is the
     42   // same as |view_|. One can override the view to use via SetTargetView().
     43   RenderWidgetHostViewMac* target_view_;
     44   // The extra offset to use while positioning the dicitonary panel.
     45   gfx::Vector2d offset_;
     46 
     47   DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMacDictionaryHelper);
     48 };
     49 
     50 }  // namespace content
     51 
     52 #endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_DICTIONARY_HELPER_H_
     53