OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/favicon/content/content_favicon_driver.h" | 5 #include "components/favicon/content/content_favicon_driver.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "components/favicon/content/favicon_url_util.h" | 8 #include "components/favicon/content/favicon_url_util.h" |
9 #include "components/favicon/core/favicon_url.h" | 9 #include "components/favicon/core/favicon_url.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 url, true, max_image_size, bypass_cache, | 75 url, true, max_image_size, bypass_cache, |
76 base::Bind(&FaviconDriverImpl::DidDownloadFavicon, | 76 base::Bind(&FaviconDriverImpl::DidDownloadFavicon, |
77 base::Unretained(this))); | 77 base::Unretained(this))); |
78 } | 78 } |
79 | 79 |
80 bool ContentFaviconDriver::IsOffTheRecord() { | 80 bool ContentFaviconDriver::IsOffTheRecord() { |
81 DCHECK(web_contents()); | 81 DCHECK(web_contents()); |
82 return web_contents()->GetBrowserContext()->IsOffTheRecord(); | 82 return web_contents()->GetBrowserContext()->IsOffTheRecord(); |
83 } | 83 } |
84 | 84 |
85 GURL ContentFaviconDriver::GetActiveURL() { | 85 GURL ContentFaviconDriver::GetActiveURL() { |
tfarina
2015/06/30 21:22:55
Nasko, I guess you want me to rename this and GetA
tfarina
2015/06/30 21:22:55
Should I rename it to GetLastCommittedURL()?
nasko
2015/07/01 05:56:30
Ideally, this should be renamed, but there are man
| |
86 content::NavigationEntry* entry = | 86 content::NavigationEntry* entry = |
87 web_contents()->GetController().GetActiveEntry(); | 87 web_contents()->GetController().GetLastCommittedEntry(); |
nasko
2015/07/01 05:56:30
Let's watch for failures/bugs from this CL once it
sdefresne
2015/08/13 09:12:26
drive-by: on iOS we are using GetVisibleItem() eve
| |
88 return entry ? entry->GetURL() : GURL(); | 88 return entry ? entry->GetURL() : GURL(); |
89 } | 89 } |
90 | 90 |
91 base::string16 ContentFaviconDriver::GetActiveTitle() { | 91 base::string16 ContentFaviconDriver::GetActiveTitle() { |
92 content::NavigationEntry* entry = | 92 content::NavigationEntry* entry = |
93 web_contents()->GetController().GetActiveEntry(); | 93 web_contents()->GetController().GetLastCommittedEntry(); |
94 return entry ? entry->GetTitle() : base::string16(); | 94 return entry ? entry->GetTitle() : base::string16(); |
95 } | 95 } |
96 | 96 |
97 bool ContentFaviconDriver::GetActiveFaviconValidity() { | 97 bool ContentFaviconDriver::GetActiveFaviconValidity() { |
98 return GetFaviconStatus().valid; | 98 return GetFaviconStatus().valid; |
99 } | 99 } |
100 | 100 |
101 void ContentFaviconDriver::SetActiveFaviconValidity(bool valid) { | 101 void ContentFaviconDriver::SetActiveFaviconValidity(bool valid) { |
102 GetFaviconStatus().valid = valid; | 102 GetFaviconStatus().valid = valid; |
103 } | 103 } |
104 | 104 |
105 GURL ContentFaviconDriver::GetActiveFaviconURL() { | 105 GURL ContentFaviconDriver::GetActiveFaviconURL() { |
106 return GetFaviconStatus().url; | 106 return GetFaviconStatus().url; |
107 } | 107 } |
108 | 108 |
109 void ContentFaviconDriver::SetActiveFaviconURL(const GURL& url) { | 109 void ContentFaviconDriver::SetActiveFaviconURL(const GURL& url) { |
110 GetFaviconStatus().url = url; | 110 GetFaviconStatus().url = url; |
111 } | 111 } |
112 | 112 |
113 gfx::Image ContentFaviconDriver::GetActiveFaviconImage() { | 113 gfx::Image ContentFaviconDriver::GetActiveFaviconImage() { |
114 return GetFaviconStatus().image; | 114 return GetFaviconStatus().image; |
115 } | 115 } |
116 | 116 |
117 void ContentFaviconDriver::SetActiveFaviconImage(const gfx::Image& image) { | 117 void ContentFaviconDriver::SetActiveFaviconImage(const gfx::Image& image) { |
118 GetFaviconStatus().image = image; | 118 GetFaviconStatus().image = image; |
119 } | 119 } |
120 | 120 |
121 content::FaviconStatus& ContentFaviconDriver::GetFaviconStatus() { | 121 content::FaviconStatus& ContentFaviconDriver::GetFaviconStatus() { |
122 DCHECK(web_contents()->GetController().GetActiveEntry()); | 122 DCHECK(web_contents()->GetController().GetLastCommittedEntry()); |
123 return web_contents()->GetController().GetActiveEntry()->GetFavicon(); | 123 return web_contents()->GetController().GetLastCommittedEntry()->GetFavicon(); |
124 } | 124 } |
125 | 125 |
126 ContentFaviconDriver::ContentFaviconDriver( | 126 ContentFaviconDriver::ContentFaviconDriver( |
127 content::WebContents* web_contents, | 127 content::WebContents* web_contents, |
128 FaviconService* favicon_service, | 128 FaviconService* favicon_service, |
129 history::HistoryService* history_service, | 129 history::HistoryService* history_service, |
130 bookmarks::BookmarkModel* bookmark_model) | 130 bookmarks::BookmarkModel* bookmark_model) |
131 : content::WebContentsObserver(web_contents), | 131 : content::WebContentsObserver(web_contents), |
132 FaviconDriverImpl(favicon_service, history_service, bookmark_model) { | 132 FaviconDriverImpl(favicon_service, history_service, bookmark_model) { |
133 } | 133 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 // redownloaded. | 173 // redownloaded. |
174 GURL url = details.entry->GetURL(); | 174 GURL url = details.entry->GetURL(); |
175 if (url != bypass_cache_page_url_) | 175 if (url != bypass_cache_page_url_) |
176 bypass_cache_page_url_ = GURL(); | 176 bypass_cache_page_url_ = GURL(); |
177 | 177 |
178 // Get the favicon, either from history or request it from the net. | 178 // Get the favicon, either from history or request it from the net. |
179 FetchFavicon(url); | 179 FetchFavicon(url); |
180 } | 180 } |
181 | 181 |
182 } // namespace favicon | 182 } // namespace favicon |
OLD | NEW |