summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-15 22:14:25 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-15 22:14:25 +0000
commitb0f146ff51b2b37a2e3549c875fb42365ded7a21 (patch)
treefc4ee794e7feacbc3d73dfb763b5a90bb11f1041 /content/shell
parent190efec7b7523f42c0f7e9a5ad80c79c3f68a7d1 (diff)
downloadchromium_src-b0f146ff51b2b37a2e3549c875fb42365ded7a21.zip
chromium_src-b0f146ff51b2b37a2e3549c875fb42365ded7a21.tar.gz
chromium_src-b0f146ff51b2b37a2e3549c875fb42365ded7a21.tar.bz2
Create a very simple TabContentsView (and not fully implemented yet) and add more supporting code to be able to load a page. Right now it's not rendering, but I suspect it's something small, and the patch has gotten large so I figure it's time to send it for review.
BUG=90445 Review URL: http://codereview.chromium.org/7906008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101395 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/shell_browser_context.cc380
-rw-r--r--content/shell/shell_browser_context.h78
-rw-r--r--content/shell/shell_browser_main.cc86
-rw-r--r--content/shell/shell_browser_main.h49
-rw-r--r--content/shell/shell_content_browser_client.cc23
-rw-r--r--content/shell/shell_content_browser_client.h11
6 files changed, 621 insertions, 6 deletions
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc
new file mode 100644
index 0000000..34d8df4
--- /dev/null
+++ b/content/shell/shell_browser_context.cc
@@ -0,0 +1,380 @@
+// 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.
+
+#include "content/shell/shell_browser_context.h"
+
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/string_split.h"
+#include "content/browser/appcache/chrome_appcache_service.h"
+#include "content/browser/browser_thread.h"
+#include "content/browser/chrome_blob_storage_context.h"
+#include "content/browser/download/download_manager.h"
+#include "content/browser/download/download_status_updater.h"
+#include "content/browser/download/mock_download_manager_delegate.h"
+#include "content/browser/file_system/browser_file_system_helper.h"
+#include "content/browser/geolocation/geolocation_permission_context.h"
+#include "content/browser/host_zoom_map.h"
+#include "content/browser/in_process_webkit/webkit_context.h"
+#include "content/browser/resource_context.h"
+#include "content/browser/ssl/ssl_host_state.h"
+#include "content/shell/shell_browser_main.h"
+#include "net/base/cert_verifier.h"
+#include "net/base/default_origin_bound_cert_store.h"
+#include "net/base/dnsrr_resolver.h"
+#include "net/base/host_resolver.h"
+#include "net/http/http_auth_handler_factory.h"
+#include "net/http/http_cache.h"
+#include "net/base/origin_bound_cert_service.h"
+#include "net/base/ssl_config_service_defaults.h"
+#include "net/proxy/proxy_service.h"
+#include "net/url_request/url_request_context.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "net/url_request/url_request_job_factory.h"
+#include "webkit/database/database_tracker.h"
+#include "webkit/quota/quota_manager.h"
+
+#if defined(OS_WIN)
+#include "base/base_paths_win.h"
+#endif
+
+namespace {
+
+class ShellURLRequestContextGetter : public net::URLRequestContextGetter {
+ public:
+ ShellURLRequestContextGetter(
+ const FilePath& base_path_,
+ MessageLoop* io_loop,
+ MessageLoop* file_loop)
+ : io_loop_(io_loop),
+ file_loop_(file_loop) {
+ }
+
+ // net::URLRequestContextGetter implementation.
+ virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ if (!url_request_context_) {
+ FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
+ net::HttpCache::DefaultBackend* main_backend =
+ new net::HttpCache::DefaultBackend(
+ net::DISK_CACHE,
+ cache_path,
+ 0,
+ BrowserThread::GetMessageLoopProxyForThread(
+ BrowserThread::CACHE));
+
+ net::NetLog* net_log = NULL;
+ host_resolver_.reset(net::CreateSystemHostResolver(
+ net::HostResolver::kDefaultParallelism,
+ net::HostResolver::kDefaultRetryAttempts,
+ net_log));
+
+ cert_verifier_.reset(new net::CertVerifier());
+
+ origin_bound_cert_service_.reset(new net::OriginBoundCertService(
+ new net::DefaultOriginBoundCertStore(NULL)));
+
+ dnsrr_resolver_.reset(new net::DnsRRResolver());
+
+ proxy_config_service_.reset(
+ net::ProxyService::CreateSystemProxyConfigService(
+ io_loop_,
+ file_loop_));
+
+ // TODO(jam): use v8 if possible, look at chrome code.
+ proxy_service_.reset(
+ net::ProxyService::CreateUsingSystemProxyResolver(
+ proxy_config_service_.get(),
+ 0,
+ net_log));
+
+ url_security_manager_.reset(net::URLSecurityManager::Create(NULL, NULL));
+
+ std::vector<std::string> supported_schemes;
+ base::SplitString("basic,digest,ntlm,negotiate", ',', &supported_schemes);
+ http_auth_handler_factory_.reset(
+ net::HttpAuthHandlerRegistryFactory::Create(
+ supported_schemes,
+ url_security_manager_.get(),
+ host_resolver_.get(),
+ std::string(), // gssapi_library_name
+ false, // negotiate_disable_cname_lookup
+ false)); // negotiate_enable_port
+
+ net::HttpCache* main_cache = new net::HttpCache(
+ host_resolver_.get(),
+ cert_verifier_.get(),
+ origin_bound_cert_service_.get(),
+ dnsrr_resolver_.get(),
+ NULL, //dns_cert_checker
+ proxy_service_.get(),
+ new net::SSLConfigServiceDefaults(),
+ http_auth_handler_factory_.get(),
+ NULL, // network_delegate
+ net_log,
+ main_backend);
+ main_http_factory_.reset(main_cache);
+
+ url_request_context_ = new net::URLRequestContext();
+ job_factory_.reset(new net::URLRequestJobFactory);
+ url_request_context_->set_job_factory(job_factory_.get());
+ url_request_context_->set_http_transaction_factory(main_cache);
+ url_request_context_->set_origin_bound_cert_service(
+ origin_bound_cert_service_.get());
+ url_request_context_->set_dnsrr_resolver(dnsrr_resolver_.get());
+ url_request_context_->set_proxy_service(proxy_service_.get());
+ }
+
+ return url_request_context_;
+ }
+
+ virtual net::CookieStore* DONTUSEME_GetCookieStore() OVERRIDE {
+ if (BrowserThread::CurrentlyOn(BrowserThread::IO))
+ return GetURLRequestContext()->cookie_store();
+ NOTIMPLEMENTED();
+ return NULL;
+ }
+
+ virtual scoped_refptr<base::MessageLoopProxy>
+ GetIOMessageLoopProxy() const OVERRIDE {
+ return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
+ }
+
+ net::HostResolver* host_resolver() { return host_resolver_.get(); }
+
+ private:
+ FilePath base_path_;
+ MessageLoop* io_loop_;
+ MessageLoop* file_loop_;
+
+ scoped_ptr<net::URLRequestJobFactory> job_factory_;
+ scoped_refptr<net::URLRequestContext> url_request_context_;
+
+ scoped_ptr<net::HttpTransactionFactory> main_http_factory_;
+ scoped_ptr<net::HostResolver> host_resolver_;
+ scoped_ptr<net::CertVerifier> cert_verifier_;
+ scoped_ptr<net::OriginBoundCertService> origin_bound_cert_service_;
+ scoped_ptr<net::DnsRRResolver> dnsrr_resolver_;
+ scoped_ptr<net::ProxyConfigService> proxy_config_service_;
+ scoped_ptr<net::ProxyService> proxy_service_;
+ scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_;
+ scoped_ptr<net::URLSecurityManager> url_security_manager_;
+};
+
+class ShellResourceContext : public content::ResourceContext {
+ public:
+ ShellResourceContext(ShellURLRequestContextGetter* getter)
+ : getter_(getter) {
+ }
+
+ private:
+ virtual void EnsureInitialized() const OVERRIDE {
+ const_cast<ShellResourceContext*>(this)->InitializeInternal();
+ }
+
+ void InitializeInternal() {
+ set_request_context(getter_->GetURLRequestContext());
+ set_host_resolver(getter_->host_resolver());
+ }
+
+ scoped_refptr<ShellURLRequestContextGetter> getter_;
+};
+
+class ShellGeolocationPermissionContext : public GeolocationPermissionContext {
+ public:
+ ShellGeolocationPermissionContext() {
+ }
+
+ // GeolocationPermissionContext implementation).
+ virtual void RequestGeolocationPermission(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame) OVERRIDE {
+ NOTIMPLEMENTED();
+ }
+
+ virtual void CancelGeolocationPermissionRequest(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame) OVERRIDE {
+ NOTIMPLEMENTED();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ShellGeolocationPermissionContext);
+};
+
+} // namespace
+
+namespace content {
+
+ShellBrowserContext::ShellBrowserContext(
+ ShellBrowserMainParts* shell_main_parts)
+ : shell_main_parts_(shell_main_parts) {
+}
+
+ShellBrowserContext::~ShellBrowserContext() {
+}
+
+FilePath ShellBrowserContext::GetPath() {
+ FilePath result;
+
+#if defined(OS_WIN)
+ CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &result));
+ result.Append(std::wstring(L"content_shell"));
+#else
+ NOTIMPLEMENTED();
+#endif
+
+ if (!file_util::PathExists(result))
+ file_util::CreateDirectory(result);
+
+ return result;
+}
+
+bool ShellBrowserContext::IsOffTheRecord() {
+ return false;
+}
+
+SSLHostState* ShellBrowserContext::GetSSLHostState() {
+ if (!ssl_host_state_.get())
+ ssl_host_state_.reset(new SSLHostState());
+ return ssl_host_state_.get();
+}
+
+DownloadManager* ShellBrowserContext::GetDownloadManager() {
+ if (!download_manager_.get()) {
+ download_status_updater_.reset(new DownloadStatusUpdater());
+
+ download_manager_delegate_.reset(new MockDownloadManagerDelegate());
+ download_manager_ = new DownloadManager(download_manager_delegate_.get(),
+ download_status_updater_.get());
+ download_manager_->Init(this);
+ }
+ return download_manager_.get();
+}
+
+bool ShellBrowserContext::HasCreatedDownloadManager() const {
+ return download_manager_.get() != NULL;
+}
+
+net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() {
+ if (!url_request_getter_) {
+ url_request_getter_ = new ShellURLRequestContextGetter(
+ GetPath(),
+ shell_main_parts_->io_thread()->message_loop(),
+ shell_main_parts_->file_thread()->message_loop());
+ }
+ return url_request_getter_;
+}
+
+net::URLRequestContextGetter*
+ ShellBrowserContext::GetRequestContextForRenderProcess(
+ int renderer_child_id) {
+ return GetRequestContext();
+}
+
+net::URLRequestContextGetter*
+ ShellBrowserContext::GetRequestContextForMedia() {
+ return GetRequestContext();
+}
+
+const ResourceContext& ShellBrowserContext::GetResourceContext() {
+ if (!resource_context_.get()) {
+ resource_context_.reset(new ShellResourceContext(
+ static_cast<ShellURLRequestContextGetter*>(GetRequestContext())));
+ }
+ return *resource_context_.get();
+}
+
+HostZoomMap* ShellBrowserContext::GetHostZoomMap() {
+ if (!host_zoom_map_)
+ host_zoom_map_ = new HostZoomMap();
+ return host_zoom_map_.get();
+}
+
+GeolocationPermissionContext*
+ ShellBrowserContext::GetGeolocationPermissionContext() {
+ if (!geolocation_permission_context_) {
+ geolocation_permission_context_ =
+ new ShellGeolocationPermissionContext();
+ }
+ return geolocation_permission_context_;
+}
+
+bool ShellBrowserContext::DidLastSessionExitCleanly() {
+ return true;
+}
+
+quota::QuotaManager* ShellBrowserContext::GetQuotaManager() {
+ CreateQuotaManagerAndClients();
+ return quota_manager_.get();
+}
+
+WebKitContext* ShellBrowserContext::GetWebKitContext() {
+ CreateQuotaManagerAndClients();
+ return webkit_context_.get();
+}
+
+webkit_database::DatabaseTracker* ShellBrowserContext::GetDatabaseTracker() {
+ CreateQuotaManagerAndClients();
+ return db_tracker_;
+}
+
+ChromeBlobStorageContext* ShellBrowserContext::GetBlobStorageContext() {
+ if (!blob_storage_context_) {
+ blob_storage_context_ = new ChromeBlobStorageContext();
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ blob_storage_context_.get(),
+ &ChromeBlobStorageContext::InitializeOnIOThread));
+ }
+ return blob_storage_context_;
+}
+
+ChromeAppCacheService* ShellBrowserContext::GetAppCacheService() {
+ CreateQuotaManagerAndClients();
+ return appcache_service_;
+}
+
+fileapi::FileSystemContext* ShellBrowserContext::GetFileSystemContext() {
+ CreateQuotaManagerAndClients();
+ return file_system_context_.get();
+}
+
+void ShellBrowserContext::CreateQuotaManagerAndClients() {
+ quota_manager_ = new quota::QuotaManager(
+ IsOffTheRecord(),
+ GetPath(),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
+ NULL);
+
+ file_system_context_ = CreateFileSystemContext(
+ GetPath(), IsOffTheRecord(), NULL, quota_manager_->proxy());
+ db_tracker_ = new webkit_database::DatabaseTracker(
+ GetPath(), IsOffTheRecord(), false, NULL, quota_manager_->proxy(),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
+ webkit_context_ = new WebKitContext(
+ IsOffTheRecord(), GetPath(), NULL, false, quota_manager_->proxy(),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT));
+ appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy());
+ scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy;
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ appcache_service_.get(),
+ &ChromeAppCacheService::InitializeOnIOThread,
+ IsOffTheRecord()
+ ? FilePath() : GetPath().Append(FILE_PATH_LITERAL("AppCache")),
+ &GetResourceContext(),
+ special_storage_policy));
+}
+
+} // namespace content
diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h
new file mode 100644
index 0000000..feed65d
--- /dev/null
+++ b/content/shell/shell_browser_context.h
@@ -0,0 +1,78 @@
+// 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 CONTENT_SHELL_SHELL_BROWSER_CONTEXT_H_
+#define CONTENT_SHELL_SHELL_BROWSER_CONTEXT_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/browser/browser_context.h"
+
+class DownloadManager;
+class DownloadManagerDelegate;
+class DownloadStatusUpdater;
+class GeolocationPermissionContext;
+class HostZoomMap;
+class SSLHostState;
+
+namespace content {
+
+class ResourceContext;
+class ShellBrowserMainParts;
+
+class ShellBrowserContext : public BrowserContext {
+ public:
+ explicit ShellBrowserContext(ShellBrowserMainParts* shell_main_parts);
+ virtual ~ShellBrowserContext();
+
+ // BrowserContext implementation.
+ virtual FilePath GetPath() OVERRIDE;
+ virtual bool IsOffTheRecord() OVERRIDE;
+ virtual SSLHostState* GetSSLHostState() OVERRIDE;
+ virtual DownloadManager* GetDownloadManager() OVERRIDE;
+ virtual bool HasCreatedDownloadManager() const OVERRIDE;
+ virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
+ virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
+ int renderer_child_id) OVERRIDE;
+ virtual net::URLRequestContextGetter* GetRequestContextForMedia() OVERRIDE;
+ virtual const ResourceContext& GetResourceContext() OVERRIDE;
+ virtual HostZoomMap* GetHostZoomMap() OVERRIDE;
+ virtual GeolocationPermissionContext*
+ GetGeolocationPermissionContext() OVERRIDE;
+ virtual bool DidLastSessionExitCleanly() OVERRIDE;
+ virtual quota::QuotaManager* GetQuotaManager() OVERRIDE;
+ virtual WebKitContext* GetWebKitContext() OVERRIDE;
+ virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
+ virtual ChromeBlobStorageContext* GetBlobStorageContext() OVERRIDE;
+ virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE;
+ virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE;
+
+ private:
+ void CreateQuotaManagerAndClients();
+
+ scoped_ptr<ResourceContext> resource_context_;
+ scoped_ptr<SSLHostState> ssl_host_state_;
+ scoped_ptr<DownloadStatusUpdater> download_status_updater_;
+ scoped_ptr<DownloadManagerDelegate> download_manager_delegate_;
+ scoped_refptr<DownloadManager> download_manager_;
+ scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
+ scoped_refptr<HostZoomMap> host_zoom_map_;
+ scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_;
+ scoped_refptr<WebKitContext> webkit_context_;
+ scoped_refptr<ChromeAppCacheService> appcache_service_;
+ scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;
+ scoped_refptr<fileapi::FileSystemContext> file_system_context_;
+ scoped_refptr<quota::QuotaManager> quota_manager_;
+ scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
+
+ ShellBrowserMainParts* shell_main_parts_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext);
+};
+
+} // namespace content
+
+#endif // CONTENT_SHELL_SHELL_BROWSER_CONTEXT_H_
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc
index a6a06c7..ed86f3b 100644
--- a/content/shell/shell_browser_main.cc
+++ b/content/shell/shell_browser_main.cc
@@ -4,3 +4,89 @@
#include "content/shell/shell_browser_main.h"
+#include "base/message_loop.h"
+#include "base/threading/thread.h"
+#include "base/threading/thread_restrictions.h"
+#include "content/browser/browser_process_sub_thread.h"
+#include "content/browser/renderer_host/resource_dispatcher_host.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/tab_contents/navigation_controller.h"
+#include "content/common/page_transition_types.h"
+#include "content/shell/shell_browser_context.h"
+#include "content/shell/shell_content_browser_client.h"
+#include "ui/base/clipboard/clipboard.h"
+
+namespace content {
+
+ShellBrowserMainParts::ShellBrowserMainParts(
+ const MainFunctionParams& parameters)
+ : BrowserMainParts(parameters) {
+ ShellContentBrowserClient* shell_browser_client =
+ static_cast<ShellContentBrowserClient*>(
+ content::GetContentClient()->browser());
+ shell_browser_client->set_shell_browser_main_parts(this);
+}
+
+ShellBrowserMainParts::~ShellBrowserMainParts() {
+ base::ThreadRestrictions::SetIOAllowed(true);
+ io_thread()->message_loop()->PostTask(
+ FROM_HERE,
+ NewRunnableFunction(&base::ThreadRestrictions::SetIOAllowed, true));
+
+ resource_dispatcher_host_->Shutdown();
+ io_thread_.reset();
+ cache_thread_.reset();
+ process_launcher_thread_.reset();
+ file_thread_.reset();
+ resource_dispatcher_host_.reset(); // Kills WebKit thread.
+ db_thread_.reset();
+}
+
+void ShellBrowserMainParts::PreMainMessageLoopRun() {
+ db_thread_.reset(new BrowserProcessSubThread(BrowserThread::DB));
+ db_thread_->Start();
+ file_thread_.reset(new BrowserProcessSubThread(BrowserThread::FILE));
+ file_thread_->Start();
+ process_launcher_thread_.reset(
+ new BrowserProcessSubThread(BrowserThread::PROCESS_LAUNCHER));
+ process_launcher_thread_->Start();
+
+ base::Thread::Options options;
+ options.message_loop_type = MessageLoop::TYPE_IO;
+
+ cache_thread_.reset(new BrowserProcessSubThread(BrowserThread::CACHE));
+ cache_thread_->StartWithOptions(options);
+ io_thread_.reset(new BrowserProcessSubThread(BrowserThread::IO));
+ io_thread_->StartWithOptions(options);
+
+ browser_context_.reset(new ShellBrowserContext(this));
+
+ tab_contents_.reset(new TabContents(
+ browser_context_.get(),
+ NULL,
+ MSG_ROUTING_NONE,
+ NULL,
+ NULL));
+ tab_contents_->controller().LoadURL(
+ GURL("http://www.google.com"),
+ GURL(),
+ PageTransition::TYPED,
+ std::string());
+}
+
+ResourceDispatcherHost* ShellBrowserMainParts::GetResourceDispatcherHost() {
+ if (!resource_dispatcher_host_.get()) {
+ ResourceQueue::DelegateSet resource_queue_delegates;
+ resource_dispatcher_host_.reset(
+ new ResourceDispatcherHost(resource_queue_delegates));
+ }
+ return resource_dispatcher_host_.get();
+}
+
+ui::Clipboard* ShellBrowserMainParts::GetClipboard() {
+ if (!clipboard_.get())
+ clipboard_.reset(new ui::Clipboard());
+ return clipboard_.get();
+}
+
+} // namespace
diff --git a/content/shell/shell_browser_main.h b/content/shell/shell_browser_main.h
index baa67fd..fc1bb21 100644
--- a/content/shell/shell_browser_main.h
+++ b/content/shell/shell_browser_main.h
@@ -6,4 +6,53 @@
#define CONTENT_SHELL_SHELL_BROWSER_MAIN_H_
#pragma once
+#include "base/memory/scoped_ptr.h"
+#include "content/browser/browser_main.h"
+
+class ResourceDispatcherHost;
+class TabContents;
+
+namespace base {
+class Thread;
+}
+
+namespace ui {
+class Clipboard;
+}
+
+namespace content {
+
+class ShellBrowserContext;
+
+class ShellBrowserMainParts : public BrowserMainParts {
+ public:
+ explicit ShellBrowserMainParts(const MainFunctionParams& parameters);
+ virtual ~ShellBrowserMainParts();
+
+ virtual void PreMainMessageLoopRun();
+
+ ResourceDispatcherHost* GetResourceDispatcherHost();
+ ui::Clipboard* GetClipboard();
+
+ base::Thread* io_thread() { return io_thread_.get(); }
+ base::Thread* file_thread() { return file_thread_.get(); }
+
+ private:
+ scoped_ptr<ShellBrowserContext> browser_context_;
+ scoped_ptr<TabContents> tab_contents_;
+
+ scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_;
+ scoped_ptr<ui::Clipboard> clipboard_;
+
+ scoped_ptr<base::Thread> io_thread_;
+ scoped_ptr<base::Thread> file_thread_;
+ scoped_ptr<base::Thread> db_thread_;
+ scoped_ptr<base::Thread> process_launcher_thread_;
+ scoped_ptr<base::Thread> cache_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShellBrowserMainParts);
+};
+
+} // namespace content
+
#endif // CONTENT_SHELL_SHELL_BROWSER_MAIN_H_
diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc
index 15ce376..5c6aa48 100644
--- a/content/shell/shell_content_browser_client.cc
+++ b/content/shell/shell_content_browser_client.cc
@@ -6,24 +6,36 @@
#include "base/file_path.h"
#include "content/browser/webui/empty_web_ui_factory.h"
+#include "content/shell/shell_browser_main.h"
#include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/clipboard/clipboard.h"
#include "webkit/glue/webpreferences.h"
+#if defined(OS_WIN)
+#include "content/browser/tab_contents/tab_contents_view_win.h"
+#endif
+
namespace content {
+ShellContentBrowserClient::ShellContentBrowserClient()
+ : shell_browser_main_parts_(NULL) {
+}
+
ShellContentBrowserClient::~ShellContentBrowserClient() {
}
BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(
const MainFunctionParams& parameters) {
- return NULL;
+ return new ShellBrowserMainParts(parameters);
}
TabContentsView* ShellContentBrowserClient::CreateTabContentsView(
TabContents* tab_contents) {
+#if defined(TOOLKIT_VIEWS)
+ return new TabContentsViewWin(tab_contents);
+#else
return NULL;
+#endif
}
void ShellContentBrowserClient::RenderViewHostCreated(
@@ -44,7 +56,7 @@ void ShellContentBrowserClient::WorkerProcessHostCreated(
WebUIFactory* ShellContentBrowserClient::GetWebUIFactory() {
// Return an empty factory so callsites don't have to check for NULL.
- return EmptyWebUIFactory::Get();
+ return EmptyWebUIFactory::GetInstance();
}
GURL ShellContentBrowserClient::GetEffectiveURL(
@@ -191,12 +203,11 @@ std::string ShellContentBrowserClient::GetWorkerProcessTitle(
}
ResourceDispatcherHost* ShellContentBrowserClient::GetResourceDispatcherHost() {
- return NULL;
+ return shell_browser_main_parts_->GetResourceDispatcherHost();
}
ui::Clipboard* ShellContentBrowserClient::GetClipboard() {
- static ui::Clipboard clipboard;
- return &clipboard;
+ return shell_browser_main_parts_->GetClipboard();
}
MHTMLGenerationManager* ShellContentBrowserClient::GetMHTMLGenerationManager() {
diff --git a/content/shell/shell_content_browser_client.h b/content/shell/shell_content_browser_client.h
index a611197..e61e54c 100644
--- a/content/shell/shell_content_browser_client.h
+++ b/content/shell/shell_content_browser_client.h
@@ -9,14 +9,22 @@
#include <string>
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "content/browser/content_browser_client.h"
namespace content {
+class ShellBrowserMainParts;
+
class ShellContentBrowserClient : public ContentBrowserClient {
public:
+ ShellContentBrowserClient();
virtual ~ShellContentBrowserClient();
+ void set_shell_browser_main_parts(ShellBrowserMainParts* parts) {
+ shell_browser_main_parts_ = parts;
+ }
+
virtual BrowserMainParts* CreateBrowserMainParts(
const MainFunctionParams& parameters) OVERRIDE;
virtual TabContentsView* CreateTabContentsView(
@@ -136,6 +144,9 @@ class ShellContentBrowserClient : public ContentBrowserClient {
crypto::CryptoModuleBlockingPasswordDelegate* GetCryptoPasswordDelegate(
const GURL& url) OVERRIDE;
#endif
+
+ private:
+ ShellBrowserMainParts* shell_browser_main_parts_;
};
} // namespace content