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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_process_host.cc

Issue 22532011: Pass handle of the native view window to the native messaging host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/messaging/native_message_process_host.h" 5 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h" 12 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h"
13 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h" 13 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h"
14 #include "chrome/common/chrome_version_info.h" 14 #include "chrome/common/chrome_version_info.h"
15 #include "chrome/common/extensions/features/feature.h" 15 #include "chrome/common/extensions/features/feature.h"
16 #include "content/public/browser/render_widget_host.h"
17 #include "content/public/browser/render_widget_host_view.h"
16 #include "extensions/common/constants.h" 18 #include "extensions/common/constants.h"
17 #include "net/base/file_stream.h" 19 #include "net/base/file_stream.h"
18 #include "net/base/io_buffer.h" 20 #include "net/base/io_buffer.h"
19 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
20 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
21 #include "url/gurl.h" 23 #include "url/gurl.h"
22 24
23 namespace { 25 namespace {
24 26
25 // Maximum message size in bytes for messages received from Native Messaging 27 // Maximum message size in bytes for messages received from Native Messaging
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 base::Unretained(this))); 72 base::Unretained(this)));
71 } 73 }
72 74
73 NativeMessageProcessHost::~NativeMessageProcessHost() { 75 NativeMessageProcessHost::~NativeMessageProcessHost() {
74 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 76 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
75 Close(std::string()); 77 Close(std::string());
76 } 78 }
77 79
78 // static 80 // static
79 scoped_ptr<NativeMessageProcessHost> NativeMessageProcessHost::Create( 81 scoped_ptr<NativeMessageProcessHost> NativeMessageProcessHost::Create(
82 int source_process_id,
Sergey Ulanov 2013/08/07 22:51:20 instead of passing process_id and routing_id pair,
alexeypa (please no reviews) 2013/08/08 16:57:32 Done.
83 int source_routing_id,
80 base::WeakPtr<Client> weak_client_ui, 84 base::WeakPtr<Client> weak_client_ui,
81 const std::string& source_extension_id, 85 const std::string& source_extension_id,
82 const std::string& native_host_name, 86 const std::string& native_host_name,
83 int destination_port) { 87 int destination_port) {
88 // Get handle of the native view and pass it to the launcher. The launcher
89 // will later pass the handle to the native messaging host process.
90 gfx::NativeWindow native_view =
91 content::RenderWidgetHost::FromID(source_process_id, source_routing_id)->
92 GetView()->GetNativeView();
84 return CreateWithLauncher(weak_client_ui, source_extension_id, 93 return CreateWithLauncher(weak_client_ui, source_extension_id,
85 native_host_name, destination_port, 94 native_host_name, destination_port,
86 NativeProcessLauncher::CreateDefault()); 95 NativeProcessLauncher::CreateDefault(native_view));
87 } 96 }
88 97
89 // static 98 // static
90 scoped_ptr<NativeMessageProcessHost> 99 scoped_ptr<NativeMessageProcessHost>
91 NativeMessageProcessHost::CreateWithLauncher( 100 NativeMessageProcessHost::CreateWithLauncher(
92 base::WeakPtr<Client> weak_client_ui, 101 base::WeakPtr<Client> weak_client_ui,
93 const std::string& source_extension_id, 102 const std::string& source_extension_id,
94 const std::string& native_host_name, 103 const std::string& native_host_name,
95 int destination_port, 104 int destination_port,
96 scoped_ptr<NativeProcessLauncher> launcher) { 105 scoped_ptr<NativeProcessLauncher> launcher) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 closed_ = true; 340 closed_ = true;
332 read_stream_.reset(); 341 read_stream_.reset();
333 write_stream_.reset(); 342 write_stream_.reset();
334 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 343 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
335 base::Bind(&Client::CloseChannel, weak_client_ui_, 344 base::Bind(&Client::CloseChannel, weak_client_ui_,
336 destination_port_, error_message)); 345 destination_port_, error_message));
337 } 346 }
338 } 347 }
339 348
340 } // namespace extensions 349 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698