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
11namespace content {
12
13class RenderWidgetHostView;
14class RenderWidgetHostViewMac;
15
16// A helper class to bring up definition of word for a RWHV.
17//
18// This is triggered by "Lookup in Dictionary" context menu item.
19// Either uses Dictionary.app or a light-weight dictionary panel, based on
20// system settings.
21class RenderWidgetHostViewMacDictionaryHelper {
22 public:
23  explicit RenderWidgetHostViewMacDictionaryHelper(RenderWidgetHostView* view);
24
25  // Overrides the view to use to bring up dictionary panel.
26  // This |target_view| can be different from |view_|, |view_| is used to get
27  // the current selection value where |target_view| is used to bring up the
28  // cocoa dictionary panel.
29  void SetTargetView(RenderWidgetHostView* target_view);
30  void set_offset(const gfx::Vector2d& offset) { offset_ = offset; }
31
32  // Brings up either Dictionary.app or a light-weight dictionary panel,
33  // depending on system settings.
34  void ShowDefinitionForSelection();
35
36 private:
37  // This class shows definition for this view.
38  RenderWidgetHostViewMac* view_;
39  // This view is use to bring up the dictionary panel. Generally this is the
40  // same as |view_|. One can override the view to use via SetTargetView().
41  RenderWidgetHostViewMac* target_view_;
42  // The extra offset to use while positioning the dicitonary panel.
43  gfx::Vector2d offset_;
44
45  DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMacDictionaryHelper);
46};
47
48}  // namespace content
49
50#endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_DICTIONARY_HELPER_H_
51