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

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

Issue 2079943002: Change RenderFrame to use InterfaceRegistry et al. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a2
Patch Set: . Created 4 years, 6 months 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/contextual_search/renderer/contextual_search_wrapper.h" 5 #include "components/contextual_search/renderer/contextual_search_wrapper.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "content/public/common/service_registry.h"
9 #include "content/public/renderer/chrome_object_extensions_utils.h" 8 #include "content/public/renderer/chrome_object_extensions_utils.h"
10 #include "content/public/renderer/render_frame.h" 9 #include "content/public/renderer/render_frame.h"
11 #include "gin/arguments.h" 10 #include "gin/arguments.h"
12 #include "gin/object_template_builder.h" 11 #include "gin/object_template_builder.h"
12 #include "services/shell/public/cpp/interface_provider.h"
13 #include "third_party/WebKit/public/web/WebFrame.h" 13 #include "third_party/WebKit/public/web/WebFrame.h"
14 #include "third_party/WebKit/public/web/WebKit.h" 14 #include "third_party/WebKit/public/web/WebKit.h"
15 #include "third_party/WebKit/public/web/WebLocalFrame.h" 15 #include "third_party/WebKit/public/web/WebLocalFrame.h"
16 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
17 17
18 namespace { 18 namespace {
19 19
20 static const char kContextualSearchObjectName[] = "contextualSearch"; 20 static const char kContextualSearchObjectName[] = "contextualSearch";
21 static const char kSetCaptionMethodName[] = "setCaption"; 21 static const char kSetCaptionMethodName[] = "setCaption";
22 22
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 gin::ObjectTemplateBuilder ContextualSearchWrapper::GetObjectTemplateBuilder( 65 gin::ObjectTemplateBuilder ContextualSearchWrapper::GetObjectTemplateBuilder(
66 v8::Isolate* isolate) { 66 v8::Isolate* isolate) {
67 return gin::Wrappable<ContextualSearchWrapper>::GetObjectTemplateBuilder( 67 return gin::Wrappable<ContextualSearchWrapper>::GetObjectTemplateBuilder(
68 isolate) 68 isolate)
69 .SetMethod(kSetCaptionMethodName, &ContextualSearchWrapper::SetCaption); 69 .SetMethod(kSetCaptionMethodName, &ContextualSearchWrapper::SetCaption);
70 } 70 }
71 71
72 bool ContextualSearchWrapper::EnsureServiceConnected() { 72 bool ContextualSearchWrapper::EnsureServiceConnected() {
73 if (render_frame() && (!contextual_search_js_api_service_ || 73 if (render_frame() && (!contextual_search_js_api_service_ ||
74 !contextual_search_js_api_service_.is_bound())) { 74 !contextual_search_js_api_service_.is_bound())) {
75 render_frame()->GetServiceRegistry()->ConnectToRemoteService( 75 render_frame()->GetRemoteInterfaces()->GetInterface(
76 mojo::GetProxy(&contextual_search_js_api_service_)); 76 &contextual_search_js_api_service_);
77 return true; 77 return true;
78 } else { 78 } else {
79 return false; 79 return false;
80 } 80 }
81 } 81 }
82 82
83 void ContextualSearchWrapper::OnDestruct() {} 83 void ContextualSearchWrapper::OnDestruct() {}
84 84
85 void ContextualSearchWrapper::SetCaption(const std::string& caption, 85 void ContextualSearchWrapper::SetCaption(const std::string& caption,
86 bool does_answer) { 86 bool does_answer) {
87 if (EnsureServiceConnected()) { 87 if (EnsureServiceConnected()) {
88 contextual_search_js_api_service_->HandleSetCaption(caption, does_answer); 88 contextual_search_js_api_service_->HandleSetCaption(caption, does_answer);
89 } 89 }
90 } 90 }
91 91
92 } // namespace contextual_search 92 } // namespace contextual_search
OLDNEW
« no previous file with comments | « components/contextual_search/DEPS ('k') | components/contextual_search/renderer/overlay_js_render_frame_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698