Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / shell / browser / shell_browser_context.cc
index 9b0003b..8a97911 100644 (file)
 #include "base/path_service.h"
 #include "base/threading/thread.h"
 #include "content/public/browser/browser_thread.h"
-#include "content/public/browser/resource_context.h"
 #include "content/public/browser/storage_partition.h"
 #include "content/public/common/content_switches.h"
 #include "content/shell/browser/shell_download_manager_delegate.h"
-#include "content/shell/browser/shell_url_request_context_getter.h"
 #include "content/shell/common/shell_switches.h"
 
 #if defined(OS_WIN)
 
 namespace content {
 
-class ShellBrowserContext::ShellResourceContext : public ResourceContext {
- public:
-  ShellResourceContext() : getter_(NULL) {}
-  virtual ~ShellResourceContext() {}
-
-  // ResourceContext implementation:
-  virtual net::HostResolver* GetHostResolver() OVERRIDE {
-    CHECK(getter_);
-    return getter_->host_resolver();
-  }
-  virtual net::URLRequestContext* GetRequestContext() OVERRIDE {
-    CHECK(getter_);
-    return getter_->GetURLRequestContext();
-  }
+ShellBrowserContext::ShellResourceContext::ShellResourceContext()
+    : getter_(NULL) {
+}
 
-  void set_url_request_context_getter(ShellURLRequestContextGetter* getter) {
-    getter_ = getter;
-  }
+ShellBrowserContext::ShellResourceContext::~ShellResourceContext() {
+}
 
- private:
-  ShellURLRequestContextGetter* getter_;
+net::HostResolver*
+ShellBrowserContext::ShellResourceContext::GetHostResolver() {
+  CHECK(getter_);
+  return getter_->host_resolver();
+}
 
-  DISALLOW_COPY_AND_ASSIGN(ShellResourceContext);
-};
+net::URLRequestContext*
+ShellBrowserContext::ShellResourceContext::GetRequestContext() {
+  CHECK(getter_);
+  return getter_->GetURLRequestContext();
+}
 
 ShellBrowserContext::ShellBrowserContext(bool off_the_record,
                                          net::NetLog* net_log)
-    : off_the_record_(off_the_record),
-      net_log_(net_log),
+    : resource_context_(new ShellResourceContext),
       ignore_certificate_errors_(false),
-      guest_manager_(NULL),
-      resource_context_(new ShellResourceContext) {
+      off_the_record_(off_the_record),
+      net_log_(net_log),
+      guest_manager_(NULL) {
   InitWhileIOAllowed();
 }
 
@@ -73,10 +65,8 @@ ShellBrowserContext::~ShellBrowserContext() {
 
 void ShellBrowserContext::InitWhileIOAllowed() {
   CommandLine* cmd_line = CommandLine::ForCurrentProcess();
-  if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors) ||
-      cmd_line->HasSwitch(switches::kDumpRenderTree)) {
+  if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors))
     ignore_certificate_errors_ = true;
-  }
   if (cmd_line->HasSwitch(switches::kContentShellDataPath)) {
     path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath);
     return;
@@ -114,16 +104,10 @@ bool ShellBrowserContext::IsOffTheRecord() const {
 }
 
 DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate()  {
-  DownloadManager* manager = BrowserContext::GetDownloadManager(this);
-
   if (!download_manager_delegate_.get()) {
     download_manager_delegate_.reset(new ShellDownloadManagerDelegate());
-    download_manager_delegate_->SetDownloadManager(manager);
-    CommandLine* cmd_line = CommandLine::ForCurrentProcess();
-    if (cmd_line->HasSwitch(switches::kDumpRenderTree)) {
-      download_manager_delegate_->SetDownloadBehaviorForTesting(
-          path_.Append(FILE_PATH_LITERAL("downloads")));
-    }
+    download_manager_delegate_->SetDownloadManager(
+        BrowserContext::GetDownloadManager(this));
   }
 
   return download_manager_delegate_.get();
@@ -133,11 +117,11 @@ net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext()  {
   return GetDefaultStoragePartition(this)->GetURLRequestContext();
 }
 
-net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
+ShellURLRequestContextGetter*
+ShellBrowserContext::CreateURLRequestContextGetter(
     ProtocolHandlerMap* protocol_handlers,
     URLRequestInterceptorScopedVector request_interceptors) {
-  DCHECK(!url_request_getter_.get());
-  url_request_getter_ = new ShellURLRequestContextGetter(
+  return new ShellURLRequestContextGetter(
       ignore_certificate_errors_,
       GetPath(),
       BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
@@ -145,6 +129,14 @@ net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
       protocol_handlers,
       request_interceptors.Pass(),
       net_log_);
+}
+
+net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
+    ProtocolHandlerMap* protocol_handlers,
+    URLRequestInterceptorScopedVector request_interceptors) {
+  DCHECK(!url_request_getter_.get());
+  url_request_getter_ = CreateURLRequestContextGetter(
+      protocol_handlers, request_interceptors.Pass());
   resource_context_->set_url_request_context_getter(url_request_getter_.get());
   return url_request_getter_.get();
 }