Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: components/offline_pages/loaded_offline_page_info.h

Issue 2362033002: Showing previews UI for Offline Previews (Closed)
Patch Set: typo Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/loaded_offline_page_info.h
diff --git a/components/offline_pages/loaded_offline_page_info.h b/components/offline_pages/loaded_offline_page_info.h
new file mode 100644
index 0000000000000000000000000000000000000000..1eb8df40779127f65360b5a70d64d15eea9ae595
--- /dev/null
+++ b/components/offline_pages/loaded_offline_page_info.h
@@ -0,0 +1,62 @@
+// Copyright 2016 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 COMPONENTS_OFFLINE_PAGES_LOADED_OFFLINE_PAGE_INFO_H_
+#define COMPONENTS_OFFLINE_PAGES_LOADED_OFFLINE_PAGE_INFO_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/supports_user_data.h"
+
+namespace net {
+class URLRequest;
+}
+
+namespace offline_pages {
+
+struct OfflinePageItem;
+struct OfflinePageHeader;
+
+// Contains the info about the offline page being loaded.
+class LoadedOfflinePageInfo : public base::SupportsUserData::Data {
+ public:
+ LoadedOfflinePageInfo();
+ ~LoadedOfflinePageInfo() override;
+
+ std::unique_ptr<LoadedOfflinePageInfo> DeepCopy();
+
+ // static
+ static void CreateInfoForRequest(
+ net::URLRequest* request,
+ std::unique_ptr<OfflinePageItem> offline_page,
+ std::unique_ptr<OfflinePageHeader> offline_header,
+ bool is_offline_preview);
+
+ // static
+ static LoadedOfflinePageInfo* GetInfo(const net::URLRequest& request);
+
+ OfflinePageItem* offline_page() { return offline_page_.get(); }
+
+ OfflinePageHeader* offline_header() { return offline_header_.get(); }
+
+ bool is_offline_preview() { return is_offline_preview_; }
+
+ private:
+ // The cached copy of OfflinePageItem.
+ std::unique_ptr<OfflinePageItem> offline_page_;
+
+ // The offline header that is provided when offline page is loaded.
+ std::unique_ptr<OfflinePageHeader> offline_header_;
+
+ // Whether the offline page was navigated to as a preview. Previews are shown
+ // when the user is on a prohibitively slow network.
+ bool is_offline_preview_;
+
+ DISALLOW_COPY_AND_ASSIGN(LoadedOfflinePageInfo);
+};
+
+} // namespace offline_pages
+
+#endif // COMPONENTS_OFFLINE_PAGES_LOADED_OFFLINE_PAGE_INFO_H_

Powered by Google App Engine
This is Rietveld 408576698