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 @@
#include "base/memory/ptr_util.h"
#include "base/scoped_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
......
......@@ -11,8 +11,9 @@
#include "base/strings/string_piece.h"
#include "base/threading/thread_task_runner_handle.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/storage_partition.h"
#include "crypto/ec_private_key.h"
#include "extensions/common/api/runtime.h"
#include "net/base/completion_callback.h"
......@@ -27,16 +28,20 @@ namespace extensions {
MessagePropertyProvider::MessagePropertyProvider() {}
void MessagePropertyProvider::GetChannelID(Profile* profile,
const GURL& source_url, const ChannelIDCallback& reply) {
void MessagePropertyProvider::GetChannelID(
content::BrowserContext* browser_context,
const GURL& source_url,
const ChannelIDCallback& reply) {
if (!source_url.is_valid()) {
// 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.
reply.Run(std::string());
return;
}
scoped_refptr<net::URLRequestContextGetter> request_context_getter(
profile->GetRequestContext());
content::BrowserContext::GetDefaultStoragePartition(browser_context)
->GetURLRequestContext());
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&MessagePropertyProvider::GetChannelIDOnIOThread,
......
......@@ -11,12 +11,15 @@
#include "base/macros.h"
class GURL;
class Profile;
namespace base {
class TaskRunner;
}
namespace content {
class BrowserContext;
}
namespace net {
class URLRequestContextGetter;
}
......@@ -33,7 +36,7 @@ class MessagePropertyProvider {
// Gets the DER-encoded public key of the domain-bound cert,
// aka TLS channel ID, for the given URL.
// Runs |reply| on the current message loop.
void GetChannelID(Profile* profile,
void GetChannelID(content::BrowserContext* browser_context,
const GURL& source_url,
const ChannelIDCallback& reply);
......
......@@ -26,6 +26,7 @@
#include "chrome/browser/tab_contents/tab_util.h"
#include "components/guest_view/common/guest_view_constants.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/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
......@@ -469,14 +470,14 @@ void MessageService::OpenChannelToTab(int source_process_id,
content::RenderFrameHost::FromID(source_process_id, source_routing_id);
if (!source)
return;
Profile* profile =
Profile::FromBrowserContext(source->GetProcess()->GetBrowserContext());
content::BrowserContext* browser_context =
source->GetProcess()->GetBrowserContext();
WebContents* contents = NULL;
std::unique_ptr<MessagePort> receiver;
PortId receiver_port_id(source_port_id.context_id, source_port_id.port_number,
false);
if (!ExtensionTabUtil::GetTabById(tab_id, profile, true, NULL, NULL,
if (!ExtensionTabUtil::GetTabById(tab_id, browser_context, true, NULL, NULL,
&contents, NULL) ||
contents->GetController().NeedsReload()) {
// The tab isn't loaded yet. Don't attempt to connect.
......@@ -505,8 +506,9 @@ void MessageService::OpenChannelToTab(int source_process_id,
if (!extension_id.empty()) {
// Source extension == target extension so the extension must exist, or
// where did the IPC come from?
extension = ExtensionRegistry::Get(profile)->enabled_extensions().GetByID(
extension_id);
extension = ExtensionRegistry::Get(browser_context)
->enabled_extensions()
.GetByID(extension_id);
DCHECK(extension);
}
......@@ -882,7 +884,7 @@ void MessageService::OnOpenChannelAllowed(
// Capture this reference before params is invalidated by base::Passed().
const GURL& source_url = params->source_url;
property_provider_.GetChannelID(
Profile::FromBrowserContext(context), source_url,
context, source_url,
base::Bind(&MessageService::GotChannelID, weak_factory_.GetWeakPtr(),
base::Passed(&params)));
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