| 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_CONTEXTUAL_SEARCH_WRAPPER_H_ |
| 6 #define COMPONENTS_CONTEXTUAL_SEARCH_CONTEXTUAL_SEARCH_WRAPPER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "components/contextual_search/contextual_search_api_service.mojom.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> { |
| 26 public: |
| 27 // Installs Contextual Search JavaScript. |
| 28 static void Install(content::RenderFrame* render_frame); |
| 29 |
| 30 // Required by gin::Wrappable. |
| 31 static gin::WrapperInfo kWrapperInfo; |
| 32 |
| 33 private: |
| 34 // Intantiate by calling Install. |
| 35 ContextualSearchWrapper(content::RenderFrame* render_frame); |
| 36 ~ContextualSearchWrapper() override; |
| 37 |
| 38 // gin::Wrappable. |
| 39 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 40 v8::Isolate* isolate) final; |
| 41 |
| 42 // Called by JavaScript to set the caption. |
| 43 void SetCaption(const std::string& caption); |
| 44 |
| 45 // Helper function to ensure that this class has connected to the API service. |
| 46 void EnsureServiceConnected(); |
| 47 |
| 48 // The render frame that this wrapper is bound to. |
| 49 content::RenderFrame* render_frame_; |
| 50 |
| 51 // The service to notify when API calls are made. |
| 52 ContextualSearchApiServicePtr contextual_search_api_service_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(ContextualSearchWrapper); |
| 55 }; |
| 56 |
| 57 } // namespace contextual_search |
| 58 |
| 59 #endif // COMPONENTS_CONTEXTUAL_SEARCH_CONTEXTUAL_SEARCH_WRAPPER_H_ |
| OLD | NEW |