Commit 6b237bcf authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Deduplicate some chrome/browser/android constants and helpers

In jumbo builds many cc files compile in the same translation
unit and then they share the same anonymous namespace. Having
the same constants and helper functions in several files will
then result in compilation failures.

In preparation for jumbo in chrome/browser, this patch
deduplicates the GetWebContents() helper function and the constants
kOMADrmMessageMimeType, kOMADrmContentMimeType,
kOMADrmRightsMimeType1, kOMADrmRightsMimeType2.

Bug: 746957
Change-Id: Ie268f77c7a099a8de01ae08c70870306f38fc05a
Reviewed-on: https://chromium-review.googlesource.com/897612Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#534182}
parent 6637caa0
......@@ -59,16 +59,6 @@ base::LazyInstance<base::Lock>::DestructorAtExit g_download_controller_lock_;
int kDefaultAutoResumptionSizeLimit = 10 * 1024 * 1024; // 10 MB
const char kAutoResumptionSizeLimitParamName[] = "AutoResumptionSizeLimit";
WebContents* GetWebContents(int render_process_id, int render_view_id) {
content::RenderViewHost* render_view_host =
content::RenderViewHost::FromID(render_process_id, render_view_id);
if (!render_view_host)
return nullptr;
return WebContents::FromRenderViewHost(render_view_host);
}
void CreateContextMenuDownload(
const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
const content::ContextMenuParams& params,
......
......@@ -4,9 +4,27 @@
#include "chrome/browser/android/download/download_controller_base.h"
#include "chrome/common/chrome_content_client.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/browser/web_contents.h"
#include "net/url_request/url_request.h"
const char kOMADrmMessageMimeType[] = "application/vnd.oma.drm.message";
const char kOMADrmContentMimeType[] = "application/vnd.oma.drm.content";
const char kOMADrmRightsMimeType1[] = "application/vnd.oma.drm.rights+xml";
const char kOMADrmRightsMimeType2[] = "application/vnd.oma.drm.rights+wbxml";
content::WebContents* GetWebContents(int render_process_id,
int render_view_id) {
content::RenderViewHost* render_view_host =
content::RenderViewHost::FromID(render_process_id, render_view_id);
if (!render_view_host)
return nullptr;
return content::WebContents::FromRenderViewHost(render_view_host);
}
// static
DownloadControllerBase* DownloadControllerBase::download_controller_ = nullptr;
......
......@@ -24,6 +24,13 @@ namespace content {
class WebContents;
}
extern const char kOMADrmMessageMimeType[];
extern const char kOMADrmContentMimeType[];
extern const char kOMADrmRightsMimeType1[];
extern const char kOMADrmRightsMimeType2[];
content::WebContents* GetWebContents(int render_process_id, int render_view_id);
// Used to store all the information about an Android download.
struct DownloadInfo {
explicit DownloadInfo(const net::URLRequest* request);
......
......@@ -5,21 +5,13 @@
#include "chrome/browser/android/download/intercept_download_resource_throttle.h"
#include "base/strings/string_util.h"
#include "chrome/browser/android/download/download_controller_base.h"
#include "net/cookies/canonical_cookie.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
namespace {
static const char kOMADrmMessageMimeType[] = "application/vnd.oma.drm.message";
static const char kOMADrmContentMimeType[] = "application/vnd.oma.drm.content";
static const char kOMADrmRightsMimeType1[] =
"application/vnd.oma.drm.rights+xml";
static const char kOMADrmRightsMimeType2[] =
"application/vnd.oma.drm.rights+wbxml";
}
InterceptDownloadResourceThrottle::InterceptDownloadResourceThrottle(
net::URLRequest* request,
const content::ResourceRequestInfo::WebContentsGetter& wc_getter)
......
......@@ -15,25 +15,6 @@
using content::BrowserThread;
namespace {
static const char kOMADrmMessageMimeType[] = "application/vnd.oma.drm.message";
static const char kOMADrmContentMimeType[] = "application/vnd.oma.drm.content";
static const char kOMADrmRightsMimeType1[] =
"application/vnd.oma.drm.rights+xml";
static const char kOMADrmRightsMimeType2[] =
"application/vnd.oma.drm.rights+wbxml";
content::WebContents* GetWebContents(int render_process_id,
int render_view_id) {
content::RenderViewHost* render_view_host =
content::RenderViewHost::FromID(render_process_id, render_view_id);
return content::WebContents::FromRenderViewHost(render_view_host);
}
} // namespace
// static
std::unique_ptr<content::NavigationThrottle>
InterceptOMADownloadNavigationThrottle::Create(
......
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