blob: 63cb79d789ce3b03c6677bead62d42c6225b4d86 [file] [log] [blame]
[email protected]71675dc7c2010-05-14 19:47:281// Copyright (c) 2010 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]4d677202009-07-19 07:37:127
[email protected]4d677202009-07-19 07:37:128#include <vector>
9
[email protected]b232fc02009-07-30 22:51:5410#include "base/string16.h"
[email protected]4d677202009-07-19 07:37:1211#include "chrome/browser/cancelable_request.h"
12#include "chrome/browser/history/history.h"
13#include "chrome/browser/tab_contents/navigation_entry.h"
14#include "googleurl/src/gurl.h"
15
16class PrefService;
17class Profile;
18
19// The model that provides the information that should be displayed in the page
20// info dialog.
21class PageInfoModel {
22 public:
23 class PageInfoModelObserver {
[email protected]46ebf0642010-07-24 02:47:4024 public:
25 virtual void ModelChanged() = 0;
26
27 protected:
28 virtual ~PageInfoModelObserver() {}
[email protected]4d677202009-07-19 07:37:1229 };
30
[email protected]4d677202009-07-19 07:37:1231 struct SectionInfo {
32 SectionInfo(bool state,
[email protected]b232fc02009-07-30 22:51:5433 const string16& title,
34 const string16& head_line,
35 const string16& description)
[email protected]4d677202009-07-19 07:37:1236 : state(state),
37 title(title),
38 head_line(head_line),
39 description(description) {
40 }
41
42 bool state; // True if state is OK, false otherwise (ex of bad states:
43 // unverified identity over HTTPS).
44
45 // The title of the section.
[email protected]b232fc02009-07-30 22:51:5446 string16 title;
[email protected]4d677202009-07-19 07:37:1247
48 // A single line describing the section, optional.
[email protected]b232fc02009-07-30 22:51:5449 string16 head_line;
[email protected]4d677202009-07-19 07:37:1250
51 // The full description of what this section is.
[email protected]b232fc02009-07-30 22:51:5452 string16 description;
[email protected]4d677202009-07-19 07:37:1253 };
54
55 PageInfoModel(Profile* profile,
56 const GURL& url,
57 const NavigationEntry::SSLStatus& ssl,
58 bool show_history,
59 PageInfoModelObserver* observer);
60
61 int GetSectionCount();
62 SectionInfo GetSectionInfo(int index);
63
64 // Callback from history service with number of visits to url.
65 void OnGotVisitCountToHost(HistoryService::Handle handle,
66 bool found_visits,
67 int count,
68 base::Time first_visit);
69
70 static void RegisterPrefs(PrefService* prefs);
71
[email protected]71675dc7c2010-05-14 19:47:2872 protected:
73 // Testing constructor. DO NOT USE.
74 PageInfoModel() {}
75
[email protected]4d677202009-07-19 07:37:1276 PageInfoModelObserver* observer_;
77
78 std::vector<SectionInfo> sections_;
79
80 // Used to request number of visits.
81 CancelableRequestConsumer request_consumer_;
82
[email protected]71675dc7c2010-05-14 19:47:2883 private:
[email protected]4d677202009-07-19 07:37:1284 DISALLOW_COPY_AND_ASSIGN(PageInfoModel);
85};
86
[email protected]eeba96c2009-07-23 22:04:2287#endif // CHROME_BROWSER_PAGE_INFO_MODEL_H_