OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_UI_OMNIBOX_PAGE_INFO_MODEL_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_OMNIBOX_PAGE_INFO_MODEL_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/strings/string16.h" |
| 11 #include "ui/gfx/image/image.h" |
| 12 #include "url/gurl.h" |
| 13 |
| 14 class PageInfoModelObserver; |
| 15 |
| 16 namespace ios { |
| 17 class ChromeBrowserState; |
| 18 } |
| 19 |
| 20 namespace web { |
| 21 struct SSLStatus; |
| 22 } |
| 23 |
| 24 // TODO(crbug.com/227827) Merge 178763: PageInfoModel has been removed in |
| 25 // upstream; check if we should use PageInfoModel. |
| 26 // The model that provides the information that should be displayed in the page |
| 27 // info dialog/bubble. |
| 28 class PageInfoModel { |
| 29 public: |
| 30 enum SectionInfoType { |
| 31 SECTION_INFO_IDENTITY = 0, |
| 32 SECTION_INFO_CONNECTION, |
| 33 SECTION_INFO_FIRST_VISIT, |
| 34 SECTION_INFO_INTERNAL_PAGE, // Used for chrome:// pages, etc. |
| 35 }; |
| 36 |
| 37 // NOTE: ICON_STATE_OK ... ICON_STATE_ERROR must be listed in increasing |
| 38 // order of severity. Code may depend on this order. |
| 39 enum SectionStateIcon { |
| 40 // No icon. |
| 41 ICON_NONE = -1, |
| 42 // State is OK. |
| 43 ICON_STATE_OK, |
| 44 // For example, unverified identity over HTTPS. |
| 45 ICON_STATE_ERROR, |
| 46 // An information icon. |
| 47 ICON_STATE_INFO, |
| 48 // Icon for offline pages. |
| 49 ICON_STATE_OFFLINE_PAGE, |
| 50 // Icon for internal pages. |
| 51 ICON_STATE_INTERNAL_PAGE, |
| 52 }; |
| 53 |
| 54 // The button action that can be displayed in the Page Info. Only the button |
| 55 // of the first section that require one will be displayed. |
| 56 enum ButtonAction { |
| 57 // No button. |
| 58 BUTTON_NONE = -1, |
| 59 // Add a button to open help center on security related page. |
| 60 BUTTON_SHOW_SECURITY_HELP, |
| 61 // Add a button to reload the page. |
| 62 BUTTON_RELOAD, |
| 63 }; |
| 64 |
| 65 struct SectionInfo { |
| 66 SectionInfo(SectionStateIcon icon_id, |
| 67 const base::string16& headline, |
| 68 const base::string16& description, |
| 69 SectionInfoType type, |
| 70 ButtonAction button) |
| 71 : icon_id(icon_id), |
| 72 headline(headline), |
| 73 description(description), |
| 74 type(type), |
| 75 button(button) {} |
| 76 |
| 77 // The overall state of the connection (error, warning, ok). |
| 78 SectionStateIcon icon_id; |
| 79 |
| 80 // A single line describing the section, optional. |
| 81 base::string16 headline; |
| 82 |
| 83 // The full description of what this section is. |
| 84 base::string16 description; |
| 85 |
| 86 // The type of SectionInfo we are dealing with, for example: Identity, |
| 87 // Connection, First Visit. |
| 88 SectionInfoType type; |
| 89 |
| 90 // The button at the bottom of the sheet that allows the user to do an extra |
| 91 // action on top of dismissing the sheet. |
| 92 ButtonAction button; |
| 93 }; |
| 94 |
| 95 PageInfoModel(ios::ChromeBrowserState* browser_state, |
| 96 const GURL& url, |
| 97 const web::SSLStatus& ssl, |
| 98 PageInfoModelObserver* observer); |
| 99 ~PageInfoModel(); |
| 100 |
| 101 int GetSectionCount(); |
| 102 SectionInfo GetSectionInfo(int index); |
| 103 |
| 104 // Returns the native image type for an icon with the given id. |
| 105 gfx::Image* GetIconImage(SectionStateIcon icon_id); |
| 106 |
| 107 // Returns the label for the "Certificate Information", if needed. |
| 108 base::string16 GetCertificateLabel() const; |
| 109 |
| 110 protected: |
| 111 // Testing constructor. DO NOT USE. |
| 112 PageInfoModel(); |
| 113 |
| 114 PageInfoModelObserver* observer_; |
| 115 |
| 116 std::vector<SectionInfo> sections_; |
| 117 |
| 118 // Label for "Certificate Information", if needed. |
| 119 base::string16 certificate_label_; |
| 120 |
| 121 private: |
| 122 DISALLOW_COPY_AND_ASSIGN(PageInfoModel); |
| 123 }; |
| 124 |
| 125 #endif // IOS_CHROME_BROWSER_UI_OMNIBOX_PAGE_INFO_MODEL_H_ |
OLD | NEW |