summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 13:54:36 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 13:54:36 +0000
commit9a86b04e0f0df56fcc55eee8b1d380cdc83bc54b (patch)
tree07c3a65254271723783f73407330269e0a713e85
parent5e9857bef42afc8daf476a3bbfc6e8686c71c892 (diff)
downloadchromium_src-9a86b04e0f0df56fcc55eee8b1d380cdc83bc54b.zip
chromium_src-9a86b04e0f0df56fcc55eee8b1d380cdc83bc54b.tar.gz
chromium_src-9a86b04e0f0df56fcc55eee8b1d380cdc83bc54b.tar.bz2
Address a TODO in SSLPolicyBackend class.
Fix the conversions from wide to string16 in this class and get rid of the base/utf_string_conversions.h. (Note: this was a TODO for evanm). BUG=None TEST=compiles locally and trybots Review URL: http://codereview.chromium.org/3284003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57987 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ssl/ssl_policy_backend.cc70
-rw-r--r--chrome/browser/ssl/ssl_policy_backend.h31
2 files changed, 45 insertions, 56 deletions
diff --git a/chrome/browser/ssl/ssl_policy_backend.cc b/chrome/browser/ssl/ssl_policy_backend.cc
index 16d12dc..6d7b6ab 100644
--- a/chrome/browser/ssl/ssl_policy_backend.cc
+++ b/chrome/browser/ssl/ssl_policy_backend.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/ssl/ssl_policy_backend.h"
#include "app/resource_bundle.h"
-#include "base/utf_string_conversions.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/ssl/ssl_host_state.h"
#include "chrome/browser/tab_contents/infobar_delegate.h"
@@ -70,45 +69,7 @@ SSLPolicyBackend::SSLPolicyBackend(NavigationController* controller)
DCHECK(controller_);
}
-void SSLPolicyBackend::ShowMessage(const std::wstring& msg) {
- ShowMessageWithLink(msg, std::wstring(), NULL);
-}
-
-void SSLPolicyBackend::ShowMessageWithLink(const std::wstring& msg,
- const std::wstring& link_text,
- Task* task) {
- if (controller_->pending_entry()) {
- // The main frame is currently loading, wait until the load is committed so
- // to show the error on the right page (once the location bar shows the
- // correct url).
- if (std::find(pending_messages_.begin(), pending_messages_.end(), msg) ==
- pending_messages_.end())
- pending_messages_.push_back(SSLMessageInfo(msg, link_text, task));
-
- return;
- }
-
- NavigationEntry* entry = controller_->GetActiveEntry();
- if (!entry)
- return;
-
- // Don't show the message if the user doesn't expect an authenticated session.
- if (entry->ssl().security_style() <= SECURITY_STYLE_UNAUTHENTICATED)
- return;
-
- if (controller_->tab_contents()) {
- // TODO(evanm): remove base/utf_string_conversions.h include after fixing
- // below conversions.
- controller_->tab_contents()->AddInfoBar(
- new SSLInfoBarDelegate(controller_->tab_contents(),
- WideToUTF16Hack(msg),
- WideToUTF16Hack(link_text),
- task));
- }
-}
-
-void SSLPolicyBackend::HostRanInsecureContent(const std::string& host,
- int id) {
+void SSLPolicyBackend::HostRanInsecureContent(const std::string& host, int id) {
ssl_host_state_->HostRanInsecureContent(host, id);
SSLManager::NotifySSLInternalStateChanged();
}
@@ -145,3 +106,32 @@ void SSLPolicyBackend::ShowPendingMessages() {
void SSLPolicyBackend::ClearPendingMessages() {
pending_messages_.clear();
}
+
+void SSLPolicyBackend::ShowMessageWithLink(const string16& msg,
+ const string16& link_text,
+ Task* task) {
+ if (controller_->pending_entry()) {
+ // The main frame is currently loading, wait until the load is committed so
+ // to show the error on the right page (once the location bar shows the
+ // correct url).
+ if (std::find(pending_messages_.begin(), pending_messages_.end(), msg) ==
+ pending_messages_.end())
+ pending_messages_.push_back(SSLMessageInfo(msg, link_text, task));
+
+ return;
+ }
+
+ NavigationEntry* entry = controller_->GetActiveEntry();
+ if (!entry)
+ return;
+
+ // Don't show the message if the user doesn't expect an authenticated session.
+ if (entry->ssl().security_style() <= SECURITY_STYLE_UNAUTHENTICATED)
+ return;
+
+ if (controller_->tab_contents()) {
+ controller_->tab_contents()->AddInfoBar(
+ new SSLInfoBarDelegate(controller_->tab_contents(),
+ msg, link_text, task));
+ }
+}
diff --git a/chrome/browser/ssl/ssl_policy_backend.h b/chrome/browser/ssl/ssl_policy_backend.h
index 2793b57..06bc8fe 100644
--- a/chrome/browser/ssl/ssl_policy_backend.h
+++ b/chrome/browser/ssl/ssl_policy_backend.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/string16.h"
#include "net/base/x509_certificate.h"
class NavigationController;
@@ -20,16 +21,6 @@ class SSLPolicyBackend {
public:
explicit SSLPolicyBackend(NavigationController* controller);
- // Ensure that the specified message is displayed to the user. This will
- // display an InfoBar at the top of the associated tab.
- void ShowMessage(const std::wstring& msg);
-
- // Same as ShowMessage but also contains a link that when clicked run the
- // specified task. The SSL Manager becomes the owner of the task.
- void ShowMessageWithLink(const std::wstring& msg,
- const std::wstring& link_text,
- Task* task);
-
// Records that a host has run insecure content.
void HostRanInsecureContent(const std::string& host, int pid);
@@ -57,26 +48,34 @@ class SSLPolicyBackend {
// in an info-bar.
struct SSLMessageInfo {
public:
- explicit SSLMessageInfo(const std::wstring& text)
+ explicit SSLMessageInfo(const string16& text)
: message(text),
action(NULL) { }
- SSLMessageInfo(const std::wstring& message,
- const std::wstring& link_text,
+ SSLMessageInfo(const string16& message,
+ const string16& link_text,
Task* action)
: message(message), link_text(link_text), action(action) { }
// Overridden so that std::find works.
- bool operator==(const std::wstring& other_message) const {
+ bool operator==(const string16& other_message) const {
// We are uniquing SSLMessageInfo by their message only.
return message == other_message;
}
- std::wstring message;
- std::wstring link_text;
+ string16 message;
+ string16 link_text;
Task* action;
};
+ // Ensure that the specified message is displayed to the user. This will
+ // display an InfoBar at the top of the associated tab. It also contains a
+ // link that when clicked run the specified task. The SSL Manager becomes the
+ // owner of the task.
+ void ShowMessageWithLink(const string16& msg,
+ const string16& link_text,
+ Task* task);
+
// The NavigationController that owns this SSLManager. We are responsible
// for the security UI of this tab.
NavigationController* controller_;