| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/history/history_tab_helper.h" | 5 #include "chrome/browser/history/history_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/history/history.h" | 7 #include "chrome/browser/history/history.h" |
| 8 #include "chrome/browser/history/top_sites.h" | 8 #include "chrome/browser/history/top_sites.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| 11 #include "content/browser/tab_contents/tab_contents.h" | 11 #include "content/browser/tab_contents/tab_contents.h" |
| 12 #include "content/browser/tab_contents/title_updated_details.h" | 12 #include "content/browser/tab_contents/title_updated_details.h" |
| 13 #include "content/public/browser/navigation_details.h" | 13 #include "content/public/browser/navigation_details.h" |
| 14 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" |
| 15 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
| 16 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
| 18 #include "content/public/browser/web_contents_delegate.h" | 18 #include "content/public/browser/web_contents_delegate.h" |
| 19 #include "content/public/common/frame_navigate_params.h" | 19 #include "content/public/common/frame_navigate_params.h" |
| 20 | 20 |
| 21 using content::NavigationEntry; |
| 22 |
| 21 HistoryTabHelper::HistoryTabHelper(TabContents* tab_contents) | 23 HistoryTabHelper::HistoryTabHelper(TabContents* tab_contents) |
| 22 : content::WebContentsObserver(tab_contents), | 24 : content::WebContentsObserver(tab_contents), |
| 23 received_page_title_(false) { | 25 received_page_title_(false) { |
| 24 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED, | 26 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED, |
| 25 content::Source<TabContents>(tab_contents)); | 27 content::Source<TabContents>(tab_contents)); |
| 26 } | 28 } |
| 27 | 29 |
| 28 HistoryTabHelper::~HistoryTabHelper() { | 30 HistoryTabHelper::~HistoryTabHelper() { |
| 29 } | 31 } |
| 30 | 32 |
| 31 void HistoryTabHelper::UpdateHistoryForNavigation( | 33 void HistoryTabHelper::UpdateHistoryForNavigation( |
| 32 scoped_refptr<history::HistoryAddPageArgs> add_page_args) { | 34 scoped_refptr<history::HistoryAddPageArgs> add_page_args) { |
| 33 HistoryService* hs = GetHistoryService(); | 35 HistoryService* hs = GetHistoryService(); |
| 34 if (hs) | 36 if (hs) |
| 35 GetHistoryService()->AddPage(*add_page_args); | 37 GetHistoryService()->AddPage(*add_page_args); |
| 36 } | 38 } |
| 37 | 39 |
| 38 void HistoryTabHelper::UpdateHistoryPageTitle( | 40 void HistoryTabHelper::UpdateHistoryPageTitle(const NavigationEntry& entry) { |
| 39 const content::NavigationEntry& entry) { | |
| 40 HistoryService* hs = GetHistoryService(); | 41 HistoryService* hs = GetHistoryService(); |
| 41 if (hs) | 42 if (hs) |
| 42 hs->SetPageTitle(entry.GetVirtualURL(), entry.GetTitleForDisplay("")); | 43 hs->SetPageTitle(entry.GetVirtualURL(), entry.GetTitleForDisplay("")); |
| 43 } | 44 } |
| 44 | 45 |
| 45 scoped_refptr<history::HistoryAddPageArgs> | 46 scoped_refptr<history::HistoryAddPageArgs> |
| 46 HistoryTabHelper::CreateHistoryAddPageArgs( | 47 HistoryTabHelper::CreateHistoryAddPageArgs( |
| 47 const GURL& virtual_url, | 48 const GURL& virtual_url, |
| 48 const content::LoadCommittedDetails& details, | 49 const content::LoadCommittedDetails& details, |
| 49 const content::FrameNavigateParams& params) { | 50 const content::FrameNavigateParams& params) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 162 } |
| 162 | 163 |
| 163 HistoryService* HistoryTabHelper::GetHistoryService() { | 164 HistoryService* HistoryTabHelper::GetHistoryService() { |
| 164 Profile* profile = | 165 Profile* profile = |
| 165 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 166 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 166 if (profile->IsOffTheRecord()) | 167 if (profile->IsOffTheRecord()) |
| 167 return NULL; | 168 return NULL; |
| 168 | 169 |
| 169 return profile->GetHistoryService(Profile::IMPLICIT_ACCESS); | 170 return profile->GetHistoryService(Profile::IMPLICIT_ACCESS); |
| 170 } | 171 } |
| OLD | NEW |