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