blob: eb05dc1f6dbb9cf5d0260372585a22b61d5bc1d6 [file] [log] [blame]
[email protected]eed164b2012-03-02 15:55:391// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]4d677202009-07-19 07:37:122// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]eeba96c2009-07-23 22:04:225#ifndef CHROME_BROWSER_PAGE_INFO_MODEL_H_
6#define CHROME_BROWSER_PAGE_INFO_MODEL_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]4d677202009-07-19 07:37:128
[email protected]4d677202009-07-19 07:37:129#include <vector>
10
[email protected]b232fc02009-07-30 22:51:5411#include "base/string16.h"
[email protected]5581d762011-12-27 14:05:2412#include "chrome/browser/cancelable_request.h"
[email protected]4d677202009-07-19 07:37:1213#include "chrome/browser/history/history.h"
[email protected]4d677202009-07-19 07:37:1214#include "googleurl/src/gurl.h"
[email protected]f08e0512011-06-13 18:10:4415#include "ui/gfx/image/image.h"
[email protected]4d677202009-07-19 07:37:1216
[email protected]33a83db2011-07-27 20:15:0617class PageInfoModelObserver;
[email protected]4d677202009-07-19 07:37:1218class Profile;
19
[email protected]d583e3f22011-12-27 21:38:1720namespace content {
21struct SSLStatus;
22}
23
[email protected]4d677202009-07-19 07:37:1224// The model that provides the information that should be displayed in the page
[email protected]ba96f8a2010-08-26 09:00:0025// info dialog/bubble.
[email protected]4d677202009-07-19 07:37:1226class PageInfoModel {
27 public:
[email protected]ba96f8a2010-08-26 09:00:0028 enum SectionInfoType {
29 SECTION_INFO_IDENTITY = 0,
30 SECTION_INFO_CONNECTION,
31 SECTION_INFO_FIRST_VISIT,
[email protected]0d4e9f282011-06-12 10:33:0432 SECTION_INFO_INTERNAL_PAGE, // Used for chrome:// pages, etc.
[email protected]ba96f8a2010-08-26 09:00:0033 };
34
[email protected]ad02e2f8c2011-02-15 19:52:2435 // NOTE: ICON_STATE_OK ... ICON_STATE_ERROR must be listed in increasing
36 // order of severity. Code may depend on this order.
[email protected]7fef9717a2010-10-02 19:08:4437 enum SectionStateIcon {
38 // No icon.
39 ICON_NONE = -1,
40 // State is OK.
41 ICON_STATE_OK,
[email protected]c45ea2172010-09-10 13:22:0542 // For example, if state is OK but contains mixed content.
[email protected]7fef9717a2010-10-02 19:08:4443 ICON_STATE_WARNING_MINOR,
[email protected]c45ea2172010-09-10 13:22:0544 // For example, if content was served over HTTP.
[email protected]7fef9717a2010-10-02 19:08:4445 ICON_STATE_WARNING_MAJOR,
[email protected]740ea162010-08-27 09:28:2446 // For example, unverified identity over HTTPS.
[email protected]7fef9717a2010-10-02 19:08:4447 ICON_STATE_ERROR,
48 // An information icon.
[email protected]0d4e9f282011-06-12 10:33:0449 ICON_STATE_INFO,
50 // Icon for internal pages.
51 ICON_STATE_INTERNAL_PAGE,
[email protected]740ea162010-08-27 09:28:2452 };
53
[email protected]4d677202009-07-19 07:37:1254 struct SectionInfo {
[email protected]7fef9717a2010-10-02 19:08:4455 SectionInfo(SectionStateIcon icon_id,
[email protected]ba96f8a2010-08-26 09:00:0056 const string16& headline,
57 const string16& description,
58 SectionInfoType type)
[email protected]7fef9717a2010-10-02 19:08:4459 : icon_id(icon_id),
[email protected]ba96f8a2010-08-26 09:00:0060 headline(headline),
61 description(description),
62 type(type) {
[email protected]4d677202009-07-19 07:37:1263 }
64
[email protected]740ea162010-08-27 09:28:2465 // The overall state of the connection (error, warning, ok).
[email protected]7fef9717a2010-10-02 19:08:4466 SectionStateIcon icon_id;
[email protected]4d677202009-07-19 07:37:1267
[email protected]4d677202009-07-19 07:37:1268 // A single line describing the section, optional.
[email protected]ba96f8a2010-08-26 09:00:0069 string16 headline;
[email protected]4d677202009-07-19 07:37:1270
71 // The full description of what this section is.
[email protected]b232fc02009-07-30 22:51:5472 string16 description;
[email protected]ba96f8a2010-08-26 09:00:0073
74 // The type of SectionInfo we are dealing with, for example: Identity,
75 // Connection, First Visit.
76 SectionInfoType type;
[email protected]4d677202009-07-19 07:37:1277 };
78
79 PageInfoModel(Profile* profile,
80 const GURL& url,
[email protected]d583e3f22011-12-27 21:38:1781 const content::SSLStatus& ssl,
[email protected]4d677202009-07-19 07:37:1282 bool show_history,
[email protected]33a83db2011-07-27 20:15:0683 PageInfoModelObserver* observer);
[email protected]0bc83012011-02-22 21:32:0884 ~PageInfoModel();
[email protected]4d677202009-07-19 07:37:1285
86 int GetSectionCount();
87 SectionInfo GetSectionInfo(int index);
88
[email protected]7fef9717a2010-10-02 19:08:4489 // Returns the native image type for an icon with the given id.
[email protected]6f01e952011-02-22 17:59:4790 gfx::Image* GetIconImage(SectionStateIcon icon_id);
[email protected]7fef9717a2010-10-02 19:08:4491
[email protected]4d677202009-07-19 07:37:1292 // Callback from history service with number of visits to url.
93 void OnGotVisitCountToHost(HistoryService::Handle handle,
94 bool found_visits,
95 int count,
96 base::Time first_visit);
97
[email protected]eed164b2012-03-02 15:55:3998 // Returns the label for the "Certificate Information", if needed.
99 string16 GetCertificateLabel() const;
100
[email protected]71675dc7c2010-05-14 19:47:28101 protected:
102 // Testing constructor. DO NOT USE.
[email protected]601858c02010-09-01 17:08:20103 PageInfoModel();
[email protected]71675dc7c2010-05-14 19:47:28104
[email protected]7fef9717a2010-10-02 19:08:44105 // Shared initialization for default and testing constructor.
106 void Init();
107
[email protected]33a83db2011-07-27 20:15:06108 PageInfoModelObserver* observer_;
[email protected]4d677202009-07-19 07:37:12109
110 std::vector<SectionInfo> sections_;
111
[email protected]7fef9717a2010-10-02 19:08:44112 // All possible icons that go next to the text descriptions to indicate state.
[email protected]6f01e952011-02-22 17:59:47113 std::vector<gfx::Image*> icons_;
[email protected]7fef9717a2010-10-02 19:08:44114
[email protected]4d677202009-07-19 07:37:12115 // Used to request number of visits.
116 CancelableRequestConsumer request_consumer_;
117
[email protected]eed164b2012-03-02 15:55:39118 // Label for "Certificate Information", if needed.
119 string16 certificate_label_;
120
[email protected]71675dc7c2010-05-14 19:47:28121 private:
[email protected]4d677202009-07-19 07:37:12122 DISALLOW_COPY_AND_ASSIGN(PageInfoModel);
123};
124
[email protected]eeba96c2009-07-23 22:04:22125#endif // CHROME_BROWSER_PAGE_INFO_MODEL_H_