diff options
Diffstat (limited to 'ios/web/public')
-rw-r--r-- | ios/web/public/favicon_status.cc | 14 | ||||
-rw-r--r-- | ios/web/public/favicon_status.h | 35 | ||||
-rw-r--r-- | ios/web/public/navigation_item.h | 68 | ||||
-rw-r--r-- | ios/web/public/security_style.h | 39 | ||||
-rw-r--r-- | ios/web/public/ssl_status.cc | 20 | ||||
-rw-r--r-- | ios/web/public/ssl_status.h | 49 |
6 files changed, 222 insertions, 3 deletions
diff --git a/ios/web/public/favicon_status.cc b/ios/web/public/favicon_status.cc new file mode 100644 index 0000000..8c22443 --- /dev/null +++ b/ios/web/public/favicon_status.cc @@ -0,0 +1,14 @@ +// Copyright 2014 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. + +#include "ios/web/public/favicon_status.h" + +namespace web { + +FaviconStatus::FaviconStatus() : valid(false) { + // TODO(rohitrao): Add a GetDefaultFavicon() method to WebClient and call it + // here. +} + +} // namespace web diff --git a/ios/web/public/favicon_status.h b/ios/web/public/favicon_status.h new file mode 100644 index 0000000..e919f83 --- /dev/null +++ b/ios/web/public/favicon_status.h @@ -0,0 +1,35 @@ +// Copyright 2014 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 IOS_WEB_PUBLIC_FAVICON_STATUS_H_ +#define IOS_WEB_PUBLIC_FAVICON_STATUS_H_ + +#include "ui/gfx/image/image.h" +#include "url/gurl.h" + +namespace web { + +// Collects the favicon related information for a NavigationItem. +struct FaviconStatus { + FaviconStatus(); + + // Indicates whether we've gotten an official favicon for the page, or are + // just using the default favicon. + bool valid; + + // The URL of the favicon which was used to load it off the web. + GURL url; + + // The favicon bitmap for the page. If the favicon has not been explicitly + // set or it empty, it will return the default favicon. Note that this is + // loaded asynchronously, so even if the favicon URL is valid we may return + // the default favicon if we haven't gotten the data yet. + gfx::Image image; + + // Copy and assignment is explicitly allowed for this struct. +}; + +} // namespace web + +#endif // IOS_WEB_PUBLIC_FAVICON_STATUS_H_ diff --git a/ios/web/public/navigation_item.h b/ios/web/public/navigation_item.h index 59638f7d..8b2af55 100644 --- a/ios/web/public/navigation_item.h +++ b/ios/web/public/navigation_item.h @@ -6,11 +6,15 @@ #define IOS_WEB_PUBLIC_NAVIGATION_ITEM_H_ #include "base/strings/string16.h" +#include "base/time/time.h" #include "ui/base/page_transition_types.h" class GURL; namespace web { +struct FaviconStatus; +struct Referrer; +struct SSLStatus; // A NavigationItem is a data structure that captures all the information // required to recreate a browsing state. It represents one point in the @@ -19,25 +23,83 @@ class NavigationItem { public: virtual ~NavigationItem() {} + // Page-related stuff -------------------------------------------------------- + + // A unique ID is preserved across commits and redirects, which means that + // sometimes a NavigationEntry's unique ID needs to be set (e.g. when + // creating a committed entry to correspond to a to-be-deleted pending entry, + // the pending entry's ID must be copied). + virtual int GetUniqueID() const = 0; + // The actual URL of the page. For some about pages, this may be a scary // data: URL or something like that. Use GetVirtualURL() below for showing to // the user. + virtual void SetURL(const GURL& url) = 0; virtual const GURL& GetURL() const = 0; - // The URL that should be shown to the user. In most cases this is the same - // as the URL above, but in some case the underlying URL might not be - // suitable for display to the user. + // The referring URL. Can be empty. + virtual void SetReferrer(const Referrer& referrer) = 0; + virtual const Referrer& GetReferrer() const = 0; + + // The virtual URL, when nonempty, will override the actual URL of the page + // when we display it to the user. This allows us to have nice and friendly + // URLs that the user sees for things like about: URLs, but actually feed + // the renderer a data URL that results in the content loading. + // + // GetVirtualURL() will return the URL to display to the user in all cases, so + // if there is no overridden display URL, it will return the actual one. + virtual void SetVirtualURL(const GURL& url) = 0; virtual const GURL& GetVirtualURL() const = 0; // The title as set by the page. This will be empty if there is no title set. // The caller is responsible for detecting when there is no title and // displaying the appropriate "Untitled" label if this is being displayed to // the user. + virtual void SetTitle(const base::string16& title) = 0; virtual const base::string16& GetTitle() const = 0; + // Describes the current page that the tab represents. This is the ID that the + // renderer generated for the page and is how we can tell new versus + // renavigations. + virtual void SetPageID(int page_id) = 0; + virtual int32 GetPageID() const = 0; + + // Page-related helpers ------------------------------------------------------ + + // Returns the title to be displayed on the tab. This could be the title of + // the page if it is available or the URL. |languages| is the list of + // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper + // URL formatting isn't needed (e.g., unit tests). + virtual const base::string16& GetTitleForDisplay( + const std::string& languages) const = 0; + + // Tracking stuff ------------------------------------------------------------ + // The transition type indicates what the user did to move to this page from // the previous page. + virtual void SetTransitionType(ui::PageTransition transition_type) = 0; virtual ui::PageTransition GetTransitionType() const = 0; + + // The favicon data and tracking information. See web::FaviconStatus. + virtual const FaviconStatus& GetFavicon() const = 0; + virtual FaviconStatus& GetFavicon() = 0; + + // All the SSL flags and state. See web::SSLStatus. + virtual const SSLStatus& GetSSL() const = 0; + virtual SSLStatus& GetSSL() = 0; + + // The time at which the last known local navigation has + // completed. (A navigation can be completed more than once if the + // page is reloaded.) + // + // If GetTimestamp() returns a null time, that means that either: + // + // - this navigation hasn't completed yet; + // - this navigation was restored and for some reason the + // timestamp wasn't available; + // - or this navigation was copied from a foreign session. + virtual void SetTimestamp(base::Time timestamp) = 0; + virtual base::Time GetTimestamp() const = 0; }; } // namespace web diff --git a/ios/web/public/security_style.h b/ios/web/public/security_style.h new file mode 100644 index 0000000..a2fbf84 --- /dev/null +++ b/ios/web/public/security_style.h @@ -0,0 +1,39 @@ +// Copyright 2014 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 IOS_WEB_PUBLIC_SECURITY_STYLE_H_ +#define IOS_WEB_PUBLIC_SECURITY_STYLE_H_ + +namespace web { + +// Various aspects of the UI change their appearance according to the security +// context in which they are displayed. For example, the location bar displays +// a lock icon when it is displayed during a valid SSL connection. +// SecuritySyle enumerates these styles, but it is up to the UI elements to +// adjust their display appropriately. +enum SecurityStyle { + // SECURITY_STYLE_UNKNOWN indicates that we do not know the proper security + // style for this object. + SECURITY_STYLE_UNKNOWN, + + // SECURITY_STYLE_UNAUTHENTICATED means the authenticity of this object can + // not be determined, either because it was retrieved using an unauthenticated + // protocol, such as HTTP or FTP, or it was retrieved using a protocol that + // supports authentication, such as HTTPS, but there were errors during + // transmission that render us uncertain to the object's authenticity. + SECURITY_STYLE_UNAUTHENTICATED, + + // SECURITY_STYLE_AUTHENTICATION_BROKEN indicates that we tried to retrieve + // this object in an authenticated manner but were unable to do so. + SECURITY_STYLE_AUTHENTICATION_BROKEN, + + // SECURITY_STYLE_AUTHENTICATED indicates that we successfully retrieved this + // object over an authenticated protocol, such as HTTPS. + SECURITY_STYLE_AUTHENTICATED, + SECURITY_STYLE_LAST = SECURITY_STYLE_AUTHENTICATED +}; + +} // namespace web + +#endif // IOS_WEB_PUBLIC_SECURITY_STYLE_H_ diff --git a/ios/web/public/ssl_status.cc b/ios/web/public/ssl_status.cc new file mode 100644 index 0000000..4957e7e --- /dev/null +++ b/ios/web/public/ssl_status.cc @@ -0,0 +1,20 @@ +// Copyright 2014 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. + +#include "ios/web/public/ssl_status.h" + +namespace web { + +SSLStatus::SSLStatus() + : security_style(SECURITY_STYLE_UNKNOWN), + cert_id(0), + cert_status(0), + security_bits(-1), + connection_status(0), + content_status(NORMAL_CONTENT) { +} + +SSLStatus::~SSLStatus() {} + +} // namespace web diff --git a/ios/web/public/ssl_status.h b/ios/web/public/ssl_status.h new file mode 100644 index 0000000..56f3d11 --- /dev/null +++ b/ios/web/public/ssl_status.h @@ -0,0 +1,49 @@ +// Copyright 2014 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 IOS_WEB_PUBLIC_SSL_STATUS_H_ +#define IOS_WEB_PUBLIC_SSL_STATUS_H_ + +#include "ios/web/public/security_style.h" +#include "net/cert/cert_status_flags.h" + +namespace web { + +// Collects the SSL information for this NavigationItem. +struct SSLStatus { + // Flags used for the page security content status. + enum ContentStatusFlags { + // HTTP page, or HTTPS page with no insecure content. + NORMAL_CONTENT = 0, + + // HTTPS page containing "displayed" HTTP resources (e.g. images, CSS). + DISPLAYED_INSECURE_CONTENT = 1 << 0, + + // The RAN_INSECURE_CONTENT flag is intentionally omitted on iOS because + // there is no way to tell when insecure content is run in a web view. + }; + + SSLStatus(); + ~SSLStatus(); + + bool Equals(const SSLStatus& status) const { + return security_style == status.security_style && + cert_id == status.cert_id && + cert_status == status.cert_status && + security_bits == status.security_bits && + content_status == status.content_status; + } + + web::SecurityStyle security_style; + int cert_id; + net::CertStatus cert_status; + int security_bits; + int connection_status; + // A combination of the ContentStatusFlags above. + int content_status; +}; + +} // namespace web + +#endif // IOS_WEB_PUBLIC_SSL_STATUS_H_ |