Skip to content

Commit

Permalink
Small Certificate fix
Browse files Browse the repository at this point in the history
-Use std::move instead .Pass() on scoped_ptr
-Don't use static variable to prevent exit-time destructor warning
  • Loading branch information
janRucka committed Apr 6, 2016
1 parent a3d8ac9 commit 2c81cc4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
22 changes: 18 additions & 4 deletions content/browser/ssl/ssl_cert_error_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace content {

std::set<SSLCertErrorHandler*> instances;
std::set<SSLCertErrorHandler*>* instances = nullptr;

SSLCertErrorHandler::SSLCertErrorHandler(
const base::WeakPtr<Delegate>& delegate,
Expand Down Expand Up @@ -45,15 +45,29 @@ void SSLCertErrorHandler::OnDispatched() {
}

void SSLCertErrorHandler::InsertInstance(SSLCertErrorHandler* instance) {
instances.insert(instance);
if (!instances)
instances = new std::set<SSLCertErrorHandler*>();

instances->insert(instance);
}

void SSLCertErrorHandler::EraseInstance(SSLCertErrorHandler* instance) {
instances.erase(instance);
if (!instances)
return;

instances->erase(instance);

if (instances->size() == 0) {
delete instances;
instances = nullptr;
}
}

std::set<SSLCertErrorHandler*> SSLCertErrorHandler::GetInstances() {
return instances;
if (!instances)
return std::set<SSLCertErrorHandler*>();
else
return *instances;
}

SSLCertErrorHandler::~SSLCertErrorHandler() {
Expand Down
5 changes: 3 additions & 2 deletions content/browser/ssl/ssl_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include <set>
#include <utility>

#include "content/browser/ssl/ssl_policy.h"

Expand Down Expand Up @@ -95,7 +96,7 @@ void SSLPolicy::OnCertificateError(SSLCertErrorHandler* handler)
scoped_ptr<base::ListValue> certificateInfo(new base::ListValue());
certificateInfo->Append(dict);

webContents->OnCertificateError(certificateInfo.Pass());
webContents->OnCertificateError(std::move(certificateInfo));

webContents->SetCertificateErrorCallback(base::Bind(static_cast<void (SSLPolicy::*)
(WebContents*, bool)>(&SSLPolicy::OnAllowCertificate),
Expand Down Expand Up @@ -312,7 +313,7 @@ void SSLPolicy::OnCertErrorInternal(SSLCertErrorHandler* handler,
handler->cert_error(), handler->ssl_info(), handler->request_url(),
handler->resource_type(), overridable, strict_enforcement,
expired_previous_decision,
base::Bind(static_cast<void (SSLPolicy::*)(scoped_refptr<SSLCertErrorHandler>,
base::Bind(static_cast<void (SSLPolicy::*)(scoped_refptr<SSLCertErrorHandler>,
bool)>(&SSLPolicy::OnAllowCertificate),
base::Unretained(this),
make_scoped_refptr(handler)),
Expand Down
2 changes: 1 addition & 1 deletion extensions/browser/guest_view/web_view/web_view_guest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ void WebViewGuest::OnCertificateError(base::ListValue* certificate)
scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->Set(webview::kCertificate, certificate);
DispatchEventToView(
new GuestViewEvent(webview::kEventCertificateError, args.Pass()));
new GuestViewEvent(webview::kEventCertificateError, std::move(args)));
}

double WebViewGuest::GetZoom() const {
Expand Down

0 comments on commit 2c81cc4

Please sign in to comment.