Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 // Sets the Gin Handle being used to wrap this object. | |
| 37 void SetGinHandle(gin::Handle<ContextualSearchWrapper> wrapper); | |
|
jochen (gone - plz use gerrit)
2015/12/04 13:21:36
delete this
Donn Denman
2015/12/09 00:57:33
Done.
| |
| 38 | |
| 39 // Required by gin::Wrappable. | |
| 40 static gin::WrapperInfo kWrapperInfo; | |
| 41 | |
| 42 private: | |
| 43 // Instantiate by calling Install. | |
| 44 explicit ContextualSearchWrapper(content::RenderFrame* render_frame); | |
| 45 ~ContextualSearchWrapper() override; | |
| 46 | |
| 47 // gin::Wrappable. | |
| 48 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | |
| 49 v8::Isolate* isolate) final; | |
| 50 | |
| 51 // Called by JavaScript to set the caption , and indicate whether | |
| 52 // the caption provides an answer (e.g. an actual definition), rather than | |
| 53 // just general notification of what kind of answer may be available. | |
| 54 void SetCaption(const std::string& caption, bool does_answer); | |
| 55 | |
| 56 // Helper function to ensure that this class has connected to the API service. | |
| 57 void EnsureServiceConnected(); | |
| 58 | |
| 59 // The gin handle being used to wrap this object. | |
| 60 gin::Handle<ContextualSearchWrapper> gin_handle_; | |
|
jochen (gone - plz use gerrit)
2015/12/04 13:21:36
delete this
Donn Denman
2015/12/09 00:57:33
Done.
| |
| 61 | |
| 62 // The service to notify when API calls are made. | |
| 63 ContextualSearchJsApiServicePtr contextual_search_js_api_service_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(ContextualSearchWrapper); | |
| 66 }; | |
| 67 | |
| 68 } // namespace contextual_search | |
| 69 | |
| 70 #endif // COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_CONTEXTUAL_SEARCH_WRAPPER_H_ | |
| OLD | NEW |