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

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: Reset the Wrapper when the Frame goes away. 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 "gin/wrappable.h"
12
13 namespace blink {
14 class WebFrame;
15 }
16
17 namespace gin {
18 class Arguments;
19 }
20
21 namespace contextual_search {
22
23 // Wrapper for injecting Contextual Search JavaScript
24 // into a WebFrame.
25 class ContextualSearchWrapper : public gin::Wrappable<ContextualSearchWrapper> {
jochen (gone - plz use gerrit) 2015/12/02 12:59:15 this class should derive from RenderFrameObserver,
Donn Denman 2015/12/03 01:21:09 Done.
26 public:
27 // Installs Contextual Search JavaScript.
28 static scoped_ptr<ContextualSearchWrapper> Install(
jochen (gone - plz use gerrit) 2015/12/02 12:59:15 should return bool or boid
Donn Denman 2015/12/03 01:21:09 Done.
29 content::RenderFrame* render_frame);
30
31 // Required by gin::Wrappable.
32 static gin::WrapperInfo kWrapperInfo;
33
34 ~ContextualSearchWrapper() override;
jochen (gone - plz use gerrit) 2015/12/02 12:59:15 should be private
Donn Denman 2015/12/03 01:21:09 Done.
35
36 private:
37 // Instantiate by calling Install.
38 explicit ContextualSearchWrapper(content::RenderFrame* render_frame);
39
40 // gin::Wrappable.
41 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
42 v8::Isolate* isolate) final;
43
44 // Called by JavaScript to set the caption , and indicate whether
45 // the caption provides an answer (e.g. an actual definition), rather than
46 // just general notification of what kind of answer may be available.
47 void SetCaption(const std::string& caption, bool does_answer);
48
49 // Helper function to ensure that this class has connected to the API service.
50 void EnsureServiceConnected();
51
52 // The render frame that this wrapper is bound to.
53 content::RenderFrame* render_frame_;
54
55 // The service to notify when API calls are made.
56 ContextualSearchJsApiServicePtr contextual_search_js_api_service_;
57
58 DISALLOW_COPY_AND_ASSIGN(ContextualSearchWrapper);
59 };
60
61 } // namespace contextual_search
62
63 #endif // COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_CONTEXTUAL_SEARCH_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698