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/navigation_details.h" | 11 #include "content/browser/tab_contents/navigation_details.h" |
12 #include "content/browser/tab_contents/navigation_entry.h" | 12 #include "content/browser/tab_contents/navigation_entry.h" |
13 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
14 #include "content/browser/tab_contents/tab_contents_delegate.h" | 14 #include "content/browser/tab_contents/tab_contents_delegate.h" |
15 #include "content/browser/tab_contents/title_updated_details.h" | 15 #include "content/browser/tab_contents/title_updated_details.h" |
16 #include "content/common/notification_service.h" | 16 #include "content/common/notification_service.h" |
17 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
18 | 18 |
19 HistoryTabHelper::HistoryTabHelper(TabContents* tab_contents) | 19 HistoryTabHelper::HistoryTabHelper(TabContents* tab_contents) |
20 : TabContentsObserver(tab_contents), | 20 : TabContentsObserver(tab_contents), |
21 received_page_title_(false) { | 21 received_page_title_(false) { |
22 registrar_.Add(this, NotificationType::TAB_CONTENTS_TITLE_UPDATED, | 22 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED, |
23 Source<TabContents>(tab_contents)); | 23 Source<TabContents>(tab_contents)); |
24 } | 24 } |
25 | 25 |
26 HistoryTabHelper::~HistoryTabHelper() { | 26 HistoryTabHelper::~HistoryTabHelper() { |
27 } | 27 } |
28 | 28 |
29 void HistoryTabHelper::UpdateHistoryForNavigation( | 29 void HistoryTabHelper::UpdateHistoryForNavigation( |
30 scoped_refptr<history::HistoryAddPageArgs> add_page_args) { | 30 scoped_refptr<history::HistoryAddPageArgs> add_page_args) { |
31 HistoryService* hs = GetHistoryService(); | 31 HistoryService* hs = GetHistoryService(); |
32 if (hs) | 32 if (hs) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 scoped_refptr<history::HistoryAddPageArgs> add_page_args( | 97 scoped_refptr<history::HistoryAddPageArgs> add_page_args( |
98 CreateHistoryAddPageArgs(tab_contents()->GetURL(), details, params)); | 98 CreateHistoryAddPageArgs(tab_contents()->GetURL(), details, params)); |
99 if (!tab_contents()->delegate() || | 99 if (!tab_contents()->delegate() || |
100 !tab_contents()->delegate()->ShouldAddNavigationToHistory( | 100 !tab_contents()->delegate()->ShouldAddNavigationToHistory( |
101 *add_page_args, details.type)) | 101 *add_page_args, details.type)) |
102 return; | 102 return; |
103 | 103 |
104 UpdateHistoryForNavigation(add_page_args); | 104 UpdateHistoryForNavigation(add_page_args); |
105 } | 105 } |
106 | 106 |
107 void HistoryTabHelper::Observe(NotificationType type, | 107 void HistoryTabHelper::Observe(int type, |
108 const NotificationSource& source, | 108 const NotificationSource& source, |
109 const NotificationDetails& details) { | 109 const NotificationDetails& details) { |
110 DCHECK(type.value == NotificationType::TAB_CONTENTS_TITLE_UPDATED); | 110 DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED); |
111 TitleUpdatedDetails* title = Details<TitleUpdatedDetails>(details).ptr(); | 111 TitleUpdatedDetails* title = Details<TitleUpdatedDetails>(details).ptr(); |
112 | 112 |
113 if (received_page_title_) | 113 if (received_page_title_) |
114 return; | 114 return; |
115 | 115 |
116 // |title->entry()| may be null. | 116 // |title->entry()| may be null. |
117 if (title->entry()) { | 117 if (title->entry()) { |
118 UpdateHistoryPageTitle(*title->entry()); | 118 UpdateHistoryPageTitle(*title->entry()); |
119 received_page_title_ = title->explicit_set(); | 119 received_page_title_ = title->explicit_set(); |
120 } | 120 } |
(...skipping 30 matching lines...) Expand all Loading... |
151 if (ts) | 151 if (ts) |
152 ts->SetPageThumbnail(url, bitmap, score); | 152 ts->SetPageThumbnail(url, bitmap, score); |
153 } | 153 } |
154 | 154 |
155 HistoryService* HistoryTabHelper::GetHistoryService() { | 155 HistoryService* HistoryTabHelper::GetHistoryService() { |
156 if (tab_contents()->profile()->IsOffTheRecord()) | 156 if (tab_contents()->profile()->IsOffTheRecord()) |
157 return NULL; | 157 return NULL; |
158 | 158 |
159 return tab_contents()->profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); | 159 return tab_contents()->profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); |
160 } | 160 } |
OLD | NEW |