diff options
author | jitendra.ks <jitendra.ks@samsung.com> | 2015-08-14 04:40:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-14 11:40:57 +0000 |
commit | 4f2e9111a6457a4010bb3ca11047dc5a1840f17b (patch) | |
tree | 2622d2a928b8a97740000f9cc3673d8f58afa029 /components/about_handler | |
parent | ed8fd74d0a10ab999ff31799b4918985ab093300 (diff) | |
download | chromium_src-4f2e9111a6457a4010bb3ca11047dc5a1840f17b.zip chromium_src-4f2e9111a6457a4010bb3ca11047dc5a1840f17b.tar.gz chromium_src-4f2e9111a6457a4010bb3ca11047dc5a1840f17b.tar.bz2 |
Create a about handler component.
Create a about handler component.
The following files ::
chrome/browser/net/about_protocol_handler.*
net/url_request/url_request_about_job.*
moved to new component: components/about_handler.
Also added GYP and GN file for same.
BUG=516695
Review URL: https://codereview.chromium.org/1284173003
Cr-Commit-Position: refs/heads/master@{#343366}
Diffstat (limited to 'components/about_handler')
-rw-r--r-- | components/about_handler/BUILD.gn | 17 | ||||
-rw-r--r-- | components/about_handler/DEPS | 3 | ||||
-rw-r--r-- | components/about_handler/about_protocol_handler.cc | 27 | ||||
-rw-r--r-- | components/about_handler/about_protocol_handler.h | 30 | ||||
-rw-r--r-- | components/about_handler/url_request_about_job.cc | 45 | ||||
-rw-r--r-- | components/about_handler/url_request_about_job.h | 35 |
6 files changed, 157 insertions, 0 deletions
diff --git a/components/about_handler/BUILD.gn b/components/about_handler/BUILD.gn new file mode 100644 index 0000000..eeaff47 --- /dev/null +++ b/components/about_handler/BUILD.gn @@ -0,0 +1,17 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("about_handler") { + sources = [ + "about_protocol_handler.cc", + "about_protocol_handler.h", + "url_request_about_job.cc", + "url_request_about_job.h", + ] + + deps = [ + "//base", + "//net", + ] +} diff --git a/components/about_handler/DEPS b/components/about_handler/DEPS new file mode 100644 index 0000000..8fa9d48 --- /dev/null +++ b/components/about_handler/DEPS @@ -0,0 +1,3 @@ +include_rules = [ + "+net", +] diff --git a/components/about_handler/about_protocol_handler.cc b/components/about_handler/about_protocol_handler.cc new file mode 100644 index 0000000..1f55f04 --- /dev/null +++ b/components/about_handler/about_protocol_handler.cc @@ -0,0 +1,27 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/about_handler/about_protocol_handler.h" + +#include "components/about_handler/url_request_about_job.h" + +namespace about_handler { + +AboutProtocolHandler::AboutProtocolHandler() { +} + +AboutProtocolHandler::~AboutProtocolHandler() { +} + +net::URLRequestJob* AboutProtocolHandler::MaybeCreateJob( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const { + return new URLRequestAboutJob(request, network_delegate); +} + +bool AboutProtocolHandler::IsSafeRedirectTarget(const GURL& location) const { + return false; +} + +} // namespace about_handler diff --git a/components/about_handler/about_protocol_handler.h b/components/about_handler/about_protocol_handler.h new file mode 100644 index 0000000..ad8adfb --- /dev/null +++ b/components/about_handler/about_protocol_handler.h @@ -0,0 +1,30 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_ABOUT_HANDLER_ABOUT_PROTOCOL_HANDLER_H_ +#define COMPONENTS_ABOUT_HANDLER_ABOUT_PROTOCOL_HANDLER_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "net/url_request/url_request_job_factory.h" + +namespace about_handler { + +// Implements a ProtocolHandler for About jobs. +class AboutProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { + public: + AboutProtocolHandler(); + ~AboutProtocolHandler() override; + net::URLRequestJob* MaybeCreateJob( + net::URLRequest* request, + net::NetworkDelegate* network_delegate) const override; + bool IsSafeRedirectTarget(const GURL& location) const override; + + private: + DISALLOW_COPY_AND_ASSIGN(AboutProtocolHandler); +}; + +} // namespace about_handler + +#endif // COMPONENTS_ABOUT_HANDLER_ABOUT_PROTOCOL_HANDLER_H_ diff --git a/components/about_handler/url_request_about_job.cc b/components/about_handler/url_request_about_job.cc new file mode 100644 index 0000000..880685a --- /dev/null +++ b/components/about_handler/url_request_about_job.cc @@ -0,0 +1,45 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Simple implementation of about: protocol handler that treats everything as +// about:blank. No other about: features should be available to web content, +// so they're not implemented here. + +#include "components/about_handler/url_request_about_job.h" + +#include "base/bind.h" +#include "base/compiler_specific.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" + +namespace about_handler { + +URLRequestAboutJob::URLRequestAboutJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate) + : URLRequestJob(request, network_delegate), + weak_factory_(this) { +} + +void URLRequestAboutJob::Start() { + // Start reading asynchronously so that all error reporting and data + // callbacks happen as they would for network requests. + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&URLRequestAboutJob::StartAsync, weak_factory_.GetWeakPtr())); +} + +bool URLRequestAboutJob::GetMimeType(std::string* mime_type) const { + *mime_type = "text/html"; + return true; +} + +URLRequestAboutJob::~URLRequestAboutJob() { +} + +void URLRequestAboutJob::StartAsync() { + NotifyHeadersComplete(); +} + +} // namespace about_handler diff --git a/components/about_handler/url_request_about_job.h b/components/about_handler/url_request_about_job.h new file mode 100644 index 0000000..e37c568 --- /dev/null +++ b/components/about_handler/url_request_about_job.h @@ -0,0 +1,35 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_ABOUT_HANDLER_URL_REQUEST_ABOUT_JOB_H_ +#define COMPONENTS_ABOUT_HANDLER_URL_REQUEST_ABOUT_JOB_H_ + +#include <string> + +#include "base/memory/weak_ptr.h" +#include "net/url_request/url_request.h" +#include "net/url_request/url_request_job.h" + +namespace about_handler { + +class URLRequestAboutJob : public net::URLRequestJob { + public: + URLRequestAboutJob(net::URLRequest* request, + net::NetworkDelegate* network_delegate); + + // URLRequestJob: + void Start() override; + bool GetMimeType(std::string* mime_type) const override; + + private: + ~URLRequestAboutJob() override; + + void StartAsync(); + + base::WeakPtrFactory<URLRequestAboutJob> weak_factory_; +}; + +} // namespace about_handler + +#endif // COMPONENTS_ABOUT_HANDLER_URL_REQUEST_ABOUT_JOB_H_ |