| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_HISTORY_HISTORY_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "content/public/browser/web_contents_user_data.h" | 11 #include "content/public/browser/web_contents_user_data.h" |
| 12 | 12 |
| 13 class HistoryService; | 13 class HistoryService; |
| 14 | 14 |
| 15 namespace history { | 15 namespace history { |
| 16 struct HistoryAddPageArgs; | 16 struct HistoryAddPageArgs; |
| 17 } | 17 } |
| 18 | 18 |
| 19 class HistoryTabHelper : public content::WebContentsObserver, | 19 class HistoryTabHelper : public content::WebContentsObserver, |
| 20 public content::WebContentsUserData<HistoryTabHelper> { | 20 public content::WebContentsUserData<HistoryTabHelper> { |
| 21 public: | 21 public: |
| 22 virtual ~HistoryTabHelper(); | 22 ~HistoryTabHelper() override; |
| 23 | 23 |
| 24 // Updates history with the specified navigation. This is called by | 24 // Updates history with the specified navigation. This is called by |
| 25 // OnMsgNavigate to update history state. | 25 // OnMsgNavigate to update history state. |
| 26 void UpdateHistoryForNavigation( | 26 void UpdateHistoryForNavigation( |
| 27 const history::HistoryAddPageArgs& add_page_args); | 27 const history::HistoryAddPageArgs& add_page_args); |
| 28 | 28 |
| 29 // Sends the page title to the history service. This is called when we receive | 29 // Sends the page title to the history service. This is called when we receive |
| 30 // the page title and we know we want to update history. | 30 // the page title and we know we want to update history. |
| 31 void UpdateHistoryPageTitle(const content::NavigationEntry& entry); | 31 void UpdateHistoryPageTitle(const content::NavigationEntry& entry); |
| 32 | 32 |
| 33 // Returns the history::HistoryAddPageArgs to use for adding a page to | 33 // Returns the history::HistoryAddPageArgs to use for adding a page to |
| 34 // history. | 34 // history. |
| 35 history::HistoryAddPageArgs CreateHistoryAddPageArgs( | 35 history::HistoryAddPageArgs CreateHistoryAddPageArgs( |
| 36 const GURL& virtual_url, | 36 const GURL& virtual_url, |
| 37 base::Time timestamp, | 37 base::Time timestamp, |
| 38 bool did_replace_entry, | 38 bool did_replace_entry, |
| 39 const content::FrameNavigateParams& params); | 39 const content::FrameNavigateParams& params); |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 explicit HistoryTabHelper(content::WebContents* web_contents); | 42 explicit HistoryTabHelper(content::WebContents* web_contents); |
| 43 friend class content::WebContentsUserData<HistoryTabHelper>; | 43 friend class content::WebContentsUserData<HistoryTabHelper>; |
| 44 | 44 |
| 45 // content::WebContentsObserver implementation. | 45 // content::WebContentsObserver implementation. |
| 46 virtual void DidNavigateMainFrame( | 46 void DidNavigateMainFrame( |
| 47 const content::LoadCommittedDetails& details, | 47 const content::LoadCommittedDetails& details, |
| 48 const content::FrameNavigateParams& params) override; | 48 const content::FrameNavigateParams& params) override; |
| 49 virtual void DidNavigateAnyFrame( | 49 void DidNavigateAnyFrame(content::RenderFrameHost* render_frame_host, |
| 50 content::RenderFrameHost* render_frame_host, | 50 const content::LoadCommittedDetails& details, |
| 51 const content::LoadCommittedDetails& details, | 51 const content::FrameNavigateParams& params) override; |
| 52 const content::FrameNavigateParams& params) override; | 52 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override; |
| 53 virtual void TitleWasSet(content::NavigationEntry* entry, | 53 void WebContentsDestroyed() override; |
| 54 bool explicit_set) override; | |
| 55 virtual void WebContentsDestroyed() override; | |
| 56 | 54 |
| 57 // Helper function to return the history service. May return NULL. | 55 // Helper function to return the history service. May return NULL. |
| 58 HistoryService* GetHistoryService(); | 56 HistoryService* GetHistoryService(); |
| 59 | 57 |
| 60 // Whether we have a (non-empty) title for the current page. | 58 // Whether we have a (non-empty) title for the current page. |
| 61 // Used to prevent subsequent title updates from affecting history. This | 59 // Used to prevent subsequent title updates from affecting history. This |
| 62 // prevents some weirdness because some AJAXy apps use titles for status | 60 // prevents some weirdness because some AJAXy apps use titles for status |
| 63 // messages. | 61 // messages. |
| 64 bool received_page_title_; | 62 bool received_page_title_; |
| 65 | 63 |
| 66 DISALLOW_COPY_AND_ASSIGN(HistoryTabHelper); | 64 DISALLOW_COPY_AND_ASSIGN(HistoryTabHelper); |
| 67 }; | 65 }; |
| 68 | 66 |
| 69 #endif // CHROME_BROWSER_HISTORY_HISTORY_TAB_HELPER_H_ | 67 #endif // CHROME_BROWSER_HISTORY_HISTORY_TAB_HELPER_H_ |
| OLD | NEW |