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

Unified Diff: content/browser/browsing_data/clear_site_data_header_observer.h

Issue 2025683003: First experimental implementation of the Clear-Site-Data header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix URL in comments, remove accidental change. Created 4 years, 5 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: content/browser/browsing_data/clear_site_data_header_observer.h
diff --git a/content/browser/browsing_data/clear_site_data_header_observer.h b/content/browser/browsing_data/clear_site_data_header_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..27b7ba61df06b96685d145c367e25540da0bcf45
--- /dev/null
+++ b/content/browser/browsing_data/clear_site_data_header_observer.h
@@ -0,0 +1,76 @@
+// 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 CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_HEADER_OBSERVER_H_
+#define CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_HEADER_OBSERVER_H_
+
+#include <memory>
+#include <vector>
+
+#include "base/gtest_prod_util.h"
+#include "base/macros.h"
+#include "base/values.h"
+#include "content/public/browser/resource_request_info.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/common/console_message_level.h"
+#include "url/gurl.h"
+
+class Profile;
nasko 2016/07/28 17:30:30 This is unused. What is it for?
msramek 2016/08/01 16:03:19 Removed, thanks for catching.
+
+namespace content {
+
+class NavigationHandle;
+
+// This observer asynchronously executes the clearing of browsing data.
+// TODO(msramek): It is currently not clear whether we should defer
+// the navigation until clearing is complete. If we decide that it should,
+// this class should be instead implemented as a NavigationThrottle.
+class CONTENT_EXPORT ClearSiteDataHeaderObserver : public WebContentsObserver {
+ public:
+ struct ConsoleMessage {
+ GURL url;
+ std::string text;
+ ConsoleMessageLevel level;
+ };
+
+ static std::unique_ptr<ClearSiteDataHeaderObserver>
+ CreateFor(NavigationHandle* handle);
nasko 2016/07/28 17:30:30 Can you document what this method does? Since this
msramek 2016/08/01 16:03:19 See the other comment - let's discuss whether this
+
+ ~ClearSiteDataHeaderObserver() override;
+
+ // WebContentsObserver implementation:
+ void DidStartNavigation(NavigationHandle* handle) override;
+ void DidRedirectNavigation(NavigationHandle* handle) override;
+ void DidFinishNavigation(NavigationHandle* handle) override;
+
+ private:
+ explicit ClearSiteDataHeaderObserver(WebContents* web_contents);
+
+ // Scans for 'Clear-Site-Data' headers, calls ParseHeader() to parse them,
+ // and requests the actual data clearing. This is the common logic
+ // of WillProcessResponse() and WillRedirectRequest().
nasko 2016/07/28 17:30:31 Those two methods no longer exist here.
msramek 2016/08/01 16:03:19 Renamed to WebContentObserver ~equivalents.
+ void HandleHeader(NavigationHandle* navigation_handle);
+
+ // Parses the value of the 'Clear-Site-Data' header and outputs whether
nasko 2016/07/28 17:30:31 Can you point to the spec for this header? It migh
msramek 2016/08/01 16:03:19 Done. (Referenced it in the class comment)
+ // the header requests to |clear_cookies|, |clear_storage|, and |clear_cache|.
+ // The |messages| vector will be filled with messages to be output in the
+ // console. Returns true if parsing was successful.
+ bool ParseHeader(const std::string& header,
+ bool* clear_cookies, bool* clear_storage, bool* clear_cache,
+ std::vector<ConsoleMessage>* messages);
+
+ // Cached console messages to be output when the RenderFrameHost is ready.
+ std::vector<ConsoleMessage> messages_;
+ GURL current_url_;
+
+ friend class ClearSiteDataHeaderObserverTest;
nasko 2016/07/28 17:30:30 friend declarations go right after the private: la
msramek 2016/08/01 16:03:19 Done.
+ FRIEND_TEST_ALL_PREFIXES(ClearSiteDataHeaderObserverTest, ParseHeader);
+ FRIEND_TEST_ALL_PREFIXES(ClearSiteDataHeaderObserverTest, InvalidHeader);
+
+ DISALLOW_COPY_AND_ASSIGN(ClearSiteDataHeaderObserver);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_HEADER_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698