Commit 00087417 authored by Michael Giuffrida's avatar Michael Giuffrida Committed by Commit Bot

Remove some Profile use from messaging API

Bug: 742641
Change-Id: Id786af8e12352e6a01f63fd52235f48c167571e5
Reviewed-on: https://chromium-review.googlesource.com/578323Reviewed-by: default avatarToni Barzic <tbarzic@chromium.org>
Commit-Queue: Michael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488043}
parent 9cf4246e
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/interstitial_page.h" #include "content/public/browser/interstitial_page.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/profiles/profile.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "crypto/ec_private_key.h" #include "crypto/ec_private_key.h"
#include "extensions/common/api/runtime.h" #include "extensions/common/api/runtime.h"
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
...@@ -27,16 +28,20 @@ namespace extensions { ...@@ -27,16 +28,20 @@ namespace extensions {
MessagePropertyProvider::MessagePropertyProvider() {} MessagePropertyProvider::MessagePropertyProvider() {}
void MessagePropertyProvider::GetChannelID(Profile* profile, void MessagePropertyProvider::GetChannelID(
const GURL& source_url, const ChannelIDCallback& reply) { content::BrowserContext* browser_context,
const GURL& source_url,
const ChannelIDCallback& reply) {
if (!source_url.is_valid()) { if (!source_url.is_valid()) {
// This isn't a real URL, so there's no sense in looking for a channel ID // This isn't a real URL, so there's no sense in looking for a channel ID
// for it. Dispatch with an empty tls channel ID. // for it. Dispatch with an empty tls channel ID.
reply.Run(std::string()); reply.Run(std::string());
return; return;
} }
scoped_refptr<net::URLRequestContextGetter> request_context_getter( scoped_refptr<net::URLRequestContextGetter> request_context_getter(
profile->GetRequestContext()); content::BrowserContext::GetDefaultStoragePartition(browser_context)
->GetURLRequestContext());
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE, content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&MessagePropertyProvider::GetChannelIDOnIOThread, base::BindOnce(&MessagePropertyProvider::GetChannelIDOnIOThread,
......
...@@ -11,12 +11,15 @@ ...@@ -11,12 +11,15 @@
#include "base/macros.h" #include "base/macros.h"
class GURL; class GURL;
class Profile;
namespace base { namespace base {
class TaskRunner; class TaskRunner;
} }
namespace content {
class BrowserContext;
}
namespace net { namespace net {
class URLRequestContextGetter; class URLRequestContextGetter;
} }
...@@ -33,7 +36,7 @@ class MessagePropertyProvider { ...@@ -33,7 +36,7 @@ class MessagePropertyProvider {
// Gets the DER-encoded public key of the domain-bound cert, // Gets the DER-encoded public key of the domain-bound cert,
// aka TLS channel ID, for the given URL. // aka TLS channel ID, for the given URL.
// Runs |reply| on the current message loop. // Runs |reply| on the current message loop.
void GetChannelID(Profile* profile, void GetChannelID(content::BrowserContext* browser_context,
const GURL& source_url, const GURL& source_url,
const ChannelIDCallback& reply); const ChannelIDCallback& reply);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/tab_contents/tab_util.h"
#include "components/guest_view/common/guest_view_constants.h" #include "components/guest_view/common/guest_view_constants.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
...@@ -469,14 +470,14 @@ void MessageService::OpenChannelToTab(int source_process_id, ...@@ -469,14 +470,14 @@ void MessageService::OpenChannelToTab(int source_process_id,
content::RenderFrameHost::FromID(source_process_id, source_routing_id); content::RenderFrameHost::FromID(source_process_id, source_routing_id);
if (!source) if (!source)
return; return;
Profile* profile = content::BrowserContext* browser_context =
Profile::FromBrowserContext(source->GetProcess()->GetBrowserContext()); source->GetProcess()->GetBrowserContext();
WebContents* contents = NULL; WebContents* contents = NULL;
std::unique_ptr<MessagePort> receiver; std::unique_ptr<MessagePort> receiver;
PortId receiver_port_id(source_port_id.context_id, source_port_id.port_number, PortId receiver_port_id(source_port_id.context_id, source_port_id.port_number,
false); false);
if (!ExtensionTabUtil::GetTabById(tab_id, profile, true, NULL, NULL, if (!ExtensionTabUtil::GetTabById(tab_id, browser_context, true, NULL, NULL,
&contents, NULL) || &contents, NULL) ||
contents->GetController().NeedsReload()) { contents->GetController().NeedsReload()) {
// The tab isn't loaded yet. Don't attempt to connect. // The tab isn't loaded yet. Don't attempt to connect.
...@@ -505,8 +506,9 @@ void MessageService::OpenChannelToTab(int source_process_id, ...@@ -505,8 +506,9 @@ void MessageService::OpenChannelToTab(int source_process_id,
if (!extension_id.empty()) { if (!extension_id.empty()) {
// Source extension == target extension so the extension must exist, or // Source extension == target extension so the extension must exist, or
// where did the IPC come from? // where did the IPC come from?
extension = ExtensionRegistry::Get(profile)->enabled_extensions().GetByID( extension = ExtensionRegistry::Get(browser_context)
extension_id); ->enabled_extensions()
.GetByID(extension_id);
DCHECK(extension); DCHECK(extension);
} }
...@@ -882,7 +884,7 @@ void MessageService::OnOpenChannelAllowed( ...@@ -882,7 +884,7 @@ void MessageService::OnOpenChannelAllowed(
// Capture this reference before params is invalidated by base::Passed(). // Capture this reference before params is invalidated by base::Passed().
const GURL& source_url = params->source_url; const GURL& source_url = params->source_url;
property_provider_.GetChannelID( property_provider_.GetChannelID(
Profile::FromBrowserContext(context), source_url, context, source_url,
base::Bind(&MessageService::GotChannelID, weak_factory_.GetWeakPtr(), base::Bind(&MessageService::GotChannelID, weak_factory_.GetWeakPtr(),
base::Passed(&params))); base::Passed(&params)));
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment