Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_HEADER_OBSERVER_H_ | |
| 6 #define CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_HEADER_OBSERVER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/gtest_prod_util.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/values.h" | |
| 14 #include "content/public/browser/resource_request_info.h" | |
| 15 #include "content/public/browser/web_contents_observer.h" | |
| 16 #include "content/public/common/console_message_level.h" | |
| 17 #include "url/gurl.h" | |
| 18 | |
| 19 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.
| |
| 20 | |
| 21 namespace content { | |
| 22 | |
| 23 class NavigationHandle; | |
| 24 | |
| 25 // This observer asynchronously executes the clearing of browsing data. | |
| 26 // TODO(msramek): It is currently not clear whether we should defer | |
| 27 // the navigation until clearing is complete. If we decide that it should, | |
| 28 // this class should be instead implemented as a NavigationThrottle. | |
| 29 class CONTENT_EXPORT ClearSiteDataHeaderObserver : public WebContentsObserver { | |
| 30 public: | |
| 31 struct ConsoleMessage { | |
| 32 GURL url; | |
| 33 std::string text; | |
| 34 ConsoleMessageLevel level; | |
| 35 }; | |
| 36 | |
| 37 static std::unique_ptr<ClearSiteDataHeaderObserver> | |
| 38 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
| |
| 39 | |
| 40 ~ClearSiteDataHeaderObserver() override; | |
| 41 | |
| 42 // WebContentsObserver implementation: | |
| 43 void DidStartNavigation(NavigationHandle* handle) override; | |
| 44 void DidRedirectNavigation(NavigationHandle* handle) override; | |
| 45 void DidFinishNavigation(NavigationHandle* handle) override; | |
| 46 | |
| 47 private: | |
| 48 explicit ClearSiteDataHeaderObserver(WebContents* web_contents); | |
| 49 | |
| 50 // Scans for 'Clear-Site-Data' headers, calls ParseHeader() to parse them, | |
| 51 // and requests the actual data clearing. This is the common logic | |
| 52 // 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.
| |
| 53 void HandleHeader(NavigationHandle* navigation_handle); | |
| 54 | |
| 55 // 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)
| |
| 56 // the header requests to |clear_cookies|, |clear_storage|, and |clear_cache|. | |
| 57 // The |messages| vector will be filled with messages to be output in the | |
| 58 // console. Returns true if parsing was successful. | |
| 59 bool ParseHeader(const std::string& header, | |
| 60 bool* clear_cookies, bool* clear_storage, bool* clear_cache, | |
| 61 std::vector<ConsoleMessage>* messages); | |
| 62 | |
| 63 // Cached console messages to be output when the RenderFrameHost is ready. | |
| 64 std::vector<ConsoleMessage> messages_; | |
| 65 GURL current_url_; | |
| 66 | |
| 67 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.
| |
| 68 FRIEND_TEST_ALL_PREFIXES(ClearSiteDataHeaderObserverTest, ParseHeader); | |
| 69 FRIEND_TEST_ALL_PREFIXES(ClearSiteDataHeaderObserverTest, InvalidHeader); | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(ClearSiteDataHeaderObserver); | |
| 72 }; | |
| 73 | |
| 74 } // namespace content | |
| 75 | |
| 76 #endif // CONTENT_BROWSER_BROWSING_DATA_CLEAR_SITE_DATA_HEADER_OBSERVER_H_ | |
| OLD | NEW |