Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Unified Diff: components/security_state/content/web_contents_security_state_model.h

Issue 2448943002: Refactor SecurityStateModel/Clients for simplicity and reusability. (Closed)
Patch Set: Refactor -> WebContentsSecurityStateModel. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/security_state/content/web_contents_security_state_model.h
diff --git a/components/security_state/content/web_contents_security_state_model.h b/components/security_state/content/web_contents_security_state_model.h
new file mode 100644
index 0000000000000000000000000000000000000000..b4b6d436a45b9fdb817135f675eb984ddb91d426
--- /dev/null
+++ b/components/security_state/content/web_contents_security_state_model.h
@@ -0,0 +1,75 @@
+// Copyright 2015 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 COMPONENTS_SECURITY_STATE_CONTENT_WEB_CONTENTS_SECURITY_STATE_MODEL_H_
+#define COMPONENTS_SECURITY_STATE_CONTENT_WEB_CONTENTS_SECURITY_STATE_MODEL_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "components/security_state/core/security_state_model.h"
+#include "components/security_state/core/security_state_model_client.h"
+#include "third_party/WebKit/public/platform/WebSecurityStyle.h"
+
+namespace content {
+class NavigationEntry;
+struct SecurityStyleExplanations;
+class WebContents;
+}
+
+namespace security_state {
+
+// Provides embedder-specific information to a WebContentsSecurityStateModel.
+class WebContentsSecurityStateModelClient {
+ public:
+ // Returns true if the page or request is known to be loaded with a
+ // certificate installed by the system administrator.
+ virtual bool UsedPolicyInstalledCertificate() = 0;
+
+ // Returns true if the given NavigationEntry fails the malware check.
+ virtual bool GetMalwareStatus(content::NavigationEntry* entry,
+ content::WebContents* web_contents) = 0;
+};
+
+// Uses a WebContents and a WebContentsSecurityStateModelClient to provide a
+// SecurityStateModel with the information that it needs to determine the page's
+// security status.
+class WebContentsSecurityStateModel {
+ public:
+ explicit WebContentsSecurityStateModel(
+ content::WebContents* web_contents);
+ virtual ~WebContentsSecurityStateModel();
+
+ void SetClient(WebContentsSecurityStateModelClient* client);
+
+ // Populates |result| to describe the current page.
+ void GetSecurityInfo(SecurityStateModel::SecurityInfo* result) const;
+
+ // Retrieves the visible security state that is relevant to the
+ // SecurityStateModel.
+ void GetVisibleSecurityState(SecurityStateModel::VisibleSecurityState* state);
+
+ // Returns the SecurityStyle that should be applied to a WebContents
+ // with the given |security_info|. Populates
+ // |security_style_explanations| to explain why the returned
+ // SecurityStyle was chosen.
+ static blink::WebSecurityStyle GetSecurityStyle(
+ const SecurityStateModel::SecurityInfo& security_info,
+ content::SecurityStyleExplanations* security_style_explanations);
+
+ private:
+ content::WebContents* web_contents_;
+ std::unique_ptr<SecurityStateModel> security_state_model_;
+
+ WebContentsSecurityStateModelClient* client_;
+
+ class Client;
+ std::unique_ptr<Client> internal_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebContentsSecurityStateModel);
+};
+
+} // namespace security_state
+
+#endif // COMPONENTS_SECURITY_STATE_CONTENT_WEB_CONTENTS_SECURITY_STATE_MODEL_H_

Powered by Google App Engine
This is Rietveld 408576698