Chromium Code Reviews| Index: content/browser/browsing_data/clear_site_data_throttle.h |
| diff --git a/content/browser/browsing_data/clear_site_data_throttle.h b/content/browser/browsing_data/clear_site_data_throttle.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e4750cc3d1d8b3613ac15235b6bd6845b35ac4d0 |
| --- /dev/null |
| +++ b/content/browser/browsing_data/clear_site_data_throttle.h |
| @@ -0,0 +1,67 @@ |
| +// 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_THROTTLE_H_ |
| +#define CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_ |
| + |
| +#include <memory> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/values.h" |
| +#include "content/public/browser/navigation_throttle.h" |
| +#include "content/public/browser/resource_request_info.h" |
| +#include "content/public/browser/web_contents_observer.h" |
| + |
| +class Profile; |
| + |
| +namespace content { |
| + |
| +class NavigationHandle; |
| + |
| +// This throttle asynchronously executes the clearing of browsing data. |
| +// It does not block navigation. |
|
Mike West
2016/06/02 07:00:08
Aside: I think we might need to reconsider this on
msramek
2016/06/14 20:12:08
Agreed. I have no idea right now which one is the
|
| +class CONTENT_EXPORT ClearSiteDataThrottle : public NavigationThrottle, |
| + public WebContentsObserver { |
| + public: |
| + static std::unique_ptr<NavigationThrottle> |
| + CreateThrottleFor(NavigationHandle* handle); |
| + |
| + ~ClearSiteDataThrottle() override; |
| + |
| + // WebContentsObserver implementation: |
| + void DidFinishNavigation(NavigationHandle* handle) override; |
| + |
| + // NavigationThrottle implementation: |
| + ThrottleCheckResult WillProcessResponse() override; |
| + |
| + private: |
| + friend class ClearSiteDataThrottleTest; |
| + |
| + struct ConsoleMessage { |
| + std::string text; |
| + bool error; |
| + }; |
| + |
| + explicit ClearSiteDataThrottle(NavigationHandle* handle); |
| + |
| + // Parses the value of the 'Clear-Site-Data' header and outputs whether |
| + // the header requests to |clear_cookies|, |clear_storage|, and |clear_cache|. |
| + // Returns true if parsing was successful. |
| + bool ParseHeader(const std::string& header, |
| + bool* clear_cookies, bool* clear_storage, bool* clear_cache); |
| + |
| + // Console logging. |
| + void ConsoleLog(const std::string& text, bool error); |
| + |
| + // Cached console messages to be output when the navigation is ready |
| + // to commit. |
| + std::vector<ConsoleMessage> messages_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ClearSiteDataThrottle); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_THROTTLE_H_ |