summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authordavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 19:34:49 +0000
committerdavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 19:34:49 +0000
commit1f18184a07252103a8cd9652d64de749f41ef09f (patch)
tree7e0c5eb9dea2890d8231eb7ad69dec318ac6e610 /chrome/browser/tab_contents
parent348b9bc12d4e2ccd03a7fbcb327a3975207a5fec (diff)
downloadchromium_src-1f18184a07252103a8cd9652d64de749f41ef09f.zip
chromium_src-1f18184a07252103a8cd9652d64de749f41ef09f.tar.gz
chromium_src-1f18184a07252103a8cd9652d64de749f41ef09f.tar.bz2
Refactor SSLClientAuthHandler and certificate selection
This cleans up much of the code involved in displaying a certificate selection dialog to the user. - Adds a new inner class to RenderViewHostDelegate (later to be populated with more SSL things). - Adds a helper class for TabContents' implementation. - Moves the certificate dialogs themselves to have a common entry point. - Makes SSLClientAuthHandler call the RVHDelegate to query the user, with the TabContents implementation displaying the dialogs. - Picks the correct parent window for the dialog on all platforms, instead of relying on BrowserList::GetLastActive - Makes the OS X implementation use an asynchronous sheet, now that we know the parent. - Fixes an index-mismatch problem in the OS X implementation, should we fail to create an identity. R=agl,brettw,mark BUG=148 TEST=selecting client certificates still works Review URL: http://codereview.chromium.org/2823038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53231 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc11
-rw-r--r--chrome/browser/tab_contents/tab_contents.h8
-rw-r--r--chrome/browser/tab_contents/tab_contents_ssl_helper.cc24
-rw-r--r--chrome/browser/tab_contents/tab_contents_ssl_helper.h28
4 files changed, 71 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 73b1b9f..e25fc44 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -71,6 +71,7 @@
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/provisional_load_details.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
+#include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/browser/tab_contents/thumbnail_generator.h"
#include "chrome/browser/translate/page_translated_details.h"
@@ -501,6 +502,12 @@ PluginInstaller* TabContents::GetPluginInstaller() {
return plugin_installer_.get();
}
+TabContentsSSLHelper* TabContents::GetSSLHelper() {
+ if (ssl_helper_.get() == NULL)
+ ssl_helper_.reset(new TabContentsSSLHelper(this));
+ return ssl_helper_.get();
+}
+
RenderProcessHost* TabContents::GetRenderProcessHost() const {
return render_manager_.current_host()->process();
}
@@ -2177,6 +2184,10 @@ RenderViewHostDelegate::AutoFill* TabContents::GetAutoFillDelegate() {
return GetAutoFillManager();
}
+RenderViewHostDelegate::SSL* TabContents::GetSSLDelegate() {
+ return GetSSLHelper();
+}
+
AutomationResourceRoutingDelegate*
TabContents::GetAutomationResourceRoutingDelegate() {
return delegate();
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 49016ae..8d14246 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -88,6 +88,7 @@ class SkBitmap;
class TabContents;
class TabContentsDelegate;
class TabContentsFactory;
+class TabContentsSSLHelper;
class TabContentsView;
class URLPattern;
class URLRequestContextGetter;
@@ -168,6 +169,9 @@ class TabContents : public PageNavigator,
// Returns the PluginInstaller, creating it if necessary.
PluginInstaller* GetPluginInstaller();
+ // Returns the TabContentsSSLHelper, creating if it necessary.
+ TabContentsSSLHelper* GetSSLHelper();
+
// Returns the SavePackage which manages the page saving job. May be NULL.
SavePackage* save_package() const { return save_package_.get(); }
@@ -893,6 +897,7 @@ class TabContents : public PageNavigator,
virtual RenderViewHostDelegate::FavIcon* GetFavIconDelegate();
virtual RenderViewHostDelegate::Autocomplete* GetAutocompleteDelegate();
virtual RenderViewHostDelegate::AutoFill* GetAutoFillDelegate();
+ virtual RenderViewHostDelegate::SSL* GetSSLDelegate();
virtual AutomationResourceRoutingDelegate*
GetAutomationResourceRoutingDelegate();
virtual TabContents* GetAsTabContents();
@@ -1067,6 +1072,9 @@ class TabContents : public PageNavigator,
// PluginInstaller, lazily created.
scoped_ptr<PluginInstaller> plugin_installer_;
+ // TabContentsSSLHelper, lazily created.
+ scoped_ptr<TabContentsSSLHelper> ssl_helper_;
+
// Handles drag and drop event forwarding to extensions.
BookmarkDrag* bookmark_drag_;
diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc
new file mode 100644
index 0000000..0f00d1e
--- /dev/null
+++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc
@@ -0,0 +1,24 @@
+// Copyright (c) 2010 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 "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
+
+#include "chrome/browser/ssl/ssl_client_auth_handler.h"
+#include "chrome/browser/ssl_client_certificate_selector.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+
+TabContentsSSLHelper::TabContentsSSLHelper(TabContents* tab_contents)
+ : tab_contents_(tab_contents) {
+}
+
+TabContentsSSLHelper::~TabContentsSSLHelper() {
+}
+
+void TabContentsSSLHelper::ShowClientCertificateRequestDialog(
+ scoped_refptr<SSLClientAuthHandler> handler) {
+ // Display the native certificate request dialog for each platform.
+ browser::ShowSSLClientCertificateSelector(
+ tab_contents_->GetMessageBoxRootWindow(),
+ handler->cert_request_info(), handler);
+}
diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.h b/chrome/browser/tab_contents/tab_contents_ssl_helper.h
new file mode 100644
index 0000000..bddb379
--- /dev/null
+++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2010 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 CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_SSL_HELPER_H_
+#define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_SSL_HELPER_H_
+
+#include "chrome/browser/renderer_host/render_view_host_delegate.h"
+
+class SSLClientAuthHandler;
+class TabContents;
+
+class TabContentsSSLHelper : public RenderViewHostDelegate::SSL {
+ public:
+ explicit TabContentsSSLHelper(TabContents* tab_contents);
+ virtual ~TabContentsSSLHelper();
+
+ // RenderViewHostDelegate::SSL implementation:
+ virtual void ShowClientCertificateRequestDialog(
+ scoped_refptr<SSLClientAuthHandler> handler);
+
+ private:
+ TabContents* tab_contents_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabContentsSSLHelper);
+};
+
+#endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_SSL_HELPER_H_