[email protected] | 71675dc7c | 2010-05-14 19:47:28 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | eeba96c | 2009-07-23 22:04:22 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_PAGE_INFO_MODEL_H_ |
| 6 | #define CHROME_BROWSER_PAGE_INFO_MODEL_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame^] | 7 | #pragma once |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 8 | |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
[email protected] | b232fc0 | 2009-07-30 22:51:54 | [diff] [blame] | 11 | #include "base/string16.h" |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 12 | #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 | |
| 17 | class PrefService; |
| 18 | class Profile; |
| 19 | |
| 20 | // The model that provides the information that should be displayed in the page |
| 21 | // info dialog. |
| 22 | class PageInfoModel { |
| 23 | public: |
| 24 | class PageInfoModelObserver { |
[email protected] | 46ebf064 | 2010-07-24 02:47:40 | [diff] [blame] | 25 | public: |
| 26 | virtual void ModelChanged() = 0; |
| 27 | |
| 28 | protected: |
| 29 | virtual ~PageInfoModelObserver() {} |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 30 | }; |
| 31 | |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 32 | struct SectionInfo { |
| 33 | SectionInfo(bool state, |
[email protected] | b232fc0 | 2009-07-30 22:51:54 | [diff] [blame] | 34 | const string16& title, |
| 35 | const string16& head_line, |
| 36 | const string16& description) |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 37 | : 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] | b232fc0 | 2009-07-30 22:51:54 | [diff] [blame] | 47 | string16 title; |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 48 | |
| 49 | // A single line describing the section, optional. |
[email protected] | b232fc0 | 2009-07-30 22:51:54 | [diff] [blame] | 50 | string16 head_line; |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 51 | |
| 52 | // The full description of what this section is. |
[email protected] | b232fc0 | 2009-07-30 22:51:54 | [diff] [blame] | 53 | string16 description; |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 54 | }; |
| 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] | 71675dc7c | 2010-05-14 19:47:28 | [diff] [blame] | 73 | protected: |
| 74 | // Testing constructor. DO NOT USE. |
| 75 | PageInfoModel() {} |
| 76 | |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 77 | PageInfoModelObserver* observer_; |
| 78 | |
| 79 | std::vector<SectionInfo> sections_; |
| 80 | |
| 81 | // Used to request number of visits. |
| 82 | CancelableRequestConsumer request_consumer_; |
| 83 | |
[email protected] | 71675dc7c | 2010-05-14 19:47:28 | [diff] [blame] | 84 | private: |
[email protected] | 4d67720 | 2009-07-19 07:37:12 | [diff] [blame] | 85 | DISALLOW_COPY_AND_ASSIGN(PageInfoModel); |
| 86 | }; |
| 87 | |
[email protected] | eeba96c | 2009-07-23 22:04:22 | [diff] [blame] | 88 | #endif // CHROME_BROWSER_PAGE_INFO_MODEL_H_ |