Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1035)

Side by Side Diff: components/contextual_search/renderer/contextual_search_wrapper.h

Issue 1385663002: [Contextual Search] Add Mojo-enabled API component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a few more missing dependencies to the new component's BUILD.gn rules for our renderer sectio… Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_CONTEXTUAL_SEARCH_WRAPPER_H_
6 #define COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_CONTEXTUAL_SEARCH_WRAPPER_H_
7
8 #include "base/basictypes.h"
9 #include "components/contextual_search/common/contextual_search_js_api_service.m ojom.h"
10 #include "content/public/renderer/render_frame.h"
11 #include "content/public/renderer/render_frame_observer.h"
12 #include "gin/handle.h"
13 #include "gin/wrappable.h"
14
15 namespace blink {
16 class WebFrame;
17 }
18
19 namespace gin {
20 class Arguments;
21 }
22
23 namespace contextual_search {
24
25 // Wrapper for injecting Contextual Search JavaScript
26 // into a WebFrame.
27 class ContextualSearchWrapper : public gin::Wrappable<ContextualSearchWrapper>,
28 public content::RenderFrameObserver {
29 public:
30 // Installs Contextual Search JavaScript.
31 static void Install(content::RenderFrame* render_frame);
32
33 // RenderFrameObserver implementation.
34 void OnDestruct() override;
35
36 // Required by gin::Wrappable.
37 static gin::WrapperInfo kWrapperInfo;
38
39 private:
40 // Instantiate by calling Install.
41 explicit ContextualSearchWrapper(content::RenderFrame* render_frame);
42 ~ContextualSearchWrapper() override;
43
44 // gin::Wrappable.
45 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
46 v8::Isolate* isolate) final;
47
48 // Called by JavaScript to set the caption , and indicate whether
49 // the caption provides an answer (e.g. an actual definition), rather than
50 // just general notification of what kind of answer may be available.
51 void SetCaption(const std::string& caption, bool does_answer);
52
53 // Helper function to ensure that this class has connected to the API service.
54 // Returns false if cannot connect.
55 bool EnsureServiceConnected();
56
57 // The service to notify when API calls are made.
58 ContextualSearchJsApiServicePtr contextual_search_js_api_service_;
59
60 DISALLOW_COPY_AND_ASSIGN(ContextualSearchWrapper);
61 };
62
63 } // namespace contextual_search
64
65 #endif // COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_CONTEXTUAL_SEARCH_WRAPPER_H_
OLDNEW
« no previous file with comments | « components/contextual_search/renderer/DEPS ('k') | components/contextual_search/renderer/contextual_search_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698