summaryrefslogtreecommitdiffstats
path: root/chrome/browser/page_info_model.h
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-18 00:34:06 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-18 00:34:06 +0000
commitd4c755d3917ec20b811d4b868c18cb40cae6713b (patch)
treeab2fa1b64c4a0cacd379ef0950f381be12eeb810 /chrome/browser/page_info_model.h
parentcf07e5608a8712bea53666d2ee3adbf3d182899c (diff)
downloadchromium_src-d4c755d3917ec20b811d4b868c18cb40cae6713b.zip
chromium_src-d4c755d3917ec20b811d4b868c18cb40cae6713b.tar.gz
chromium_src-d4c755d3917ec20b811d4b868c18cb40cae6713b.tar.bz2
Refactoring the page info to have a model.BUG=NoneTEST=Make sure clicking the lock/warning icon when visiting a HTTPS page brings the page info and that it reports the correct info. Also check that the "Page/Frame info" right click menu works as well.
Review URL: http://codereview.chromium.org/155336 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/page_info_model.h')
-rw-r--r--chrome/browser/page_info_model.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/chrome/browser/page_info_model.h b/chrome/browser/page_info_model.h
new file mode 100644
index 0000000..5d32979
--- /dev/null
+++ b/chrome/browser/page_info_model.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PAGE_INFO_MODEL_H
+#define CHROME_BROWSER_PAGE_INFO_MODEL_H
+
+#include <string>
+#include <vector>
+
+#include "chrome/browser/cancelable_request.h"
+#include "chrome/browser/history/history.h"
+#include "chrome/browser/tab_contents/navigation_entry.h"
+#include "googleurl/src/gurl.h"
+
+class PrefService;
+class Profile;
+
+// The model that provides the information that should be displayed in the page
+// info dialog.
+class PageInfoModel {
+ public:
+ class PageInfoModelObserver {
+ public:
+ virtual void ModelChanged() = 0;
+ };
+
+ // Because the UI on the Mac is statically laid-out, this enum provides the
+ // section type for the associated index. It is only used on Mac.
+ // Ideally the view wouldn't have to know anything regarding the semantics of
+ // the model and would only use GetSectionCount()/GetSectionInfo().
+ enum SectionType {
+ IDENTITY = 0,
+ CONNECTION,
+ HISTORY
+ };
+
+ struct SectionInfo {
+ SectionInfo(bool state,
+ std::wstring title,
+ std::wstring head_line,
+ std::wstring description)
+ : state(state),
+ title(title),
+ head_line(head_line),
+ description(description) {
+ }
+
+ bool state; // True if state is OK, false otherwise (ex of bad states:
+ // unverified identity over HTTPS).
+
+ // The title of the section.
+ std::wstring title;
+
+ // A single line describing the section, optional.
+ std::wstring head_line;
+
+ // The full description of what this section is.
+ std::wstring description;
+ };
+
+ PageInfoModel(Profile* profile,
+ const GURL& url,
+ const NavigationEntry::SSLStatus& ssl,
+ bool show_history,
+ PageInfoModelObserver* observer);
+
+ int GetSectionCount();
+ SectionInfo GetSectionInfo(int index);
+
+ // Callback from history service with number of visits to url.
+ void OnGotVisitCountToHost(HistoryService::Handle handle,
+ bool found_visits,
+ int count,
+ base::Time first_visit);
+
+ static void RegisterPrefs(PrefService* prefs);
+
+ private:
+ PageInfoModelObserver* observer_;
+
+ std::vector<SectionInfo> sections_;
+
+ // Used to request number of visits.
+ CancelableRequestConsumer request_consumer_;
+
+ DISALLOW_COPY_AND_ASSIGN(PageInfoModel);
+};
+
+#endif // CHROME_BROWSER_PAGE_INFO_MODEL_H