blob: 6bf0389e3f080b60746f7fa2d512320ab416dccb [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]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]4d677202009-07-19 07:37:1212#include "chrome/browser/cancelable_request.h"
13#include "chrome/browser/history/history.h"
14#include "chrome/browser/tab_contents/navigation_entry.h"
15#include "googleurl/src/gurl.h"
16
17class PrefService;
18class Profile;
19
20// The model that provides the information that should be displayed in the page
21// info dialog.
22class PageInfoModel {
23 public:
24 class PageInfoModelObserver {
[email protected]46ebf0642010-07-24 02:47:4025 public:
26 virtual void ModelChanged() = 0;
27
28 protected:
29 virtual ~PageInfoModelObserver() {}
[email protected]4d677202009-07-19 07:37:1230 };
31
[email protected]4d677202009-07-19 07:37:1232 struct SectionInfo {
33 SectionInfo(bool state,
[email protected]b232fc02009-07-30 22:51:5434 const string16& title,
35 const string16& head_line,
36 const string16& description)
[email protected]4d677202009-07-19 07:37:1237 : state(state),
38 title(title),
39 head_line(head_line),
40 description(description) {
41 }
42
43 bool state; // True if state is OK, false otherwise (ex of bad states:
44 // unverified identity over HTTPS).
45
46 // The title of the section.
[email protected]b232fc02009-07-30 22:51:5447 string16 title;
[email protected]4d677202009-07-19 07:37:1248
49 // A single line describing the section, optional.
[email protected]b232fc02009-07-30 22:51:5450 string16 head_line;
[email protected]4d677202009-07-19 07:37:1251
52 // The full description of what this section is.
[email protected]b232fc02009-07-30 22:51:5453 string16 description;
[email protected]4d677202009-07-19 07:37:1254 };
55
56 PageInfoModel(Profile* profile,
57 const GURL& url,
58 const NavigationEntry::SSLStatus& ssl,
59 bool show_history,
60 PageInfoModelObserver* observer);
61
62 int GetSectionCount();
63 SectionInfo GetSectionInfo(int index);
64
65 // Callback from history service with number of visits to url.
66 void OnGotVisitCountToHost(HistoryService::Handle handle,
67 bool found_visits,
68 int count,
69 base::Time first_visit);
70
71 static void RegisterPrefs(PrefService* prefs);
72
[email protected]71675dc7c2010-05-14 19:47:2873 protected:
74 // Testing constructor. DO NOT USE.
75 PageInfoModel() {}
76
[email protected]4d677202009-07-19 07:37:1277 PageInfoModelObserver* observer_;
78
79 std::vector<SectionInfo> sections_;
80
81 // Used to request number of visits.
82 CancelableRequestConsumer request_consumer_;
83
[email protected]71675dc7c2010-05-14 19:47:2884 private:
[email protected]4d677202009-07-19 07:37:1285 DISALLOW_COPY_AND_ASSIGN(PageInfoModel);
86};
87
[email protected]eeba96c2009-07-23 22:04:2288#endif // CHROME_BROWSER_PAGE_INFO_MODEL_H_