| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
| 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
| 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
| 8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 9 * | 9 * |
| 10 * Redistribution and use in source and binary forms, with or without | 10 * Redistribution and use in source and binary forms, with or without |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 if (i == iconCount) | 115 if (i == iconCount) |
| 116 iconURLs.append(*iter); | 116 iconURLs.append(*iter); |
| 117 } | 117 } |
| 118 | 118 |
| 119 return iconURLs; | 119 return iconURLs; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void IconController::commitToDatabase(const KURL& icon) | 122 void IconController::commitToDatabase(const KURL& icon) |
| 123 { | 123 { |
| 124 LOG(IconDatabase, "Committing iconURL %s to database for pageURLs %s and %s"
, icon.string().ascii().data(), m_frame->document()->url().string().ascii().data
(), m_frame->loader()->initialRequest().url().string().ascii().data()); | 124 LOG_INFO(IconDatabase, "Committing iconURL %s to database for pageURLs %s an
d %s", icon.string().ascii().data(), m_frame->document()->url().string().ascii()
.data(), m_frame->loader()->initialRequest().url().string().ascii().data()); |
| 125 iconDatabase().setIconURLForPageURL(icon.string(), m_frame->document()->url(
).string()); | 125 iconDatabase().setIconURLForPageURL(icon.string(), m_frame->document()->url(
).string()); |
| 126 iconDatabase().setIconURLForPageURL(icon.string(), m_frame->loader()->initia
lRequest().url().string()); | 126 iconDatabase().setIconURLForPageURL(icon.string(), m_frame->loader()->initia
lRequest().url().string()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void IconController::startLoader() | 129 void IconController::startLoader() |
| 130 { | 130 { |
| 131 // FIXME: We kick off the icon loader when the frame is done receiving its m
ain resource. | 131 // FIXME: We kick off the icon loader when the frame is done receiving its m
ain resource. |
| 132 // But we should instead do it when we're done parsing the head element. | 132 // But we should instead do it when we're done parsing the head element. |
| 133 if (!m_frame->loader()->isLoadingMainFrame()) | 133 if (!m_frame->loader()->isLoadingMainFrame()) |
| 134 return; | 134 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 165 return; | 165 return; |
| 166 } | 166 } |
| 167 | 167 |
| 168 IconLoadDecision decision = iconDatabase().synchronousLoadDecisionForIconURL
(urlString, m_frame->loader()->documentLoader()); | 168 IconLoadDecision decision = iconDatabase().synchronousLoadDecisionForIconURL
(urlString, m_frame->loader()->documentLoader()); |
| 169 | 169 |
| 170 if (decision == IconLoadUnknown) { | 170 if (decision == IconLoadUnknown) { |
| 171 // In this case, we may end up loading the icon later, but we still want
to commit the icon url mapping to the database | 171 // In this case, we may end up loading the icon later, but we still want
to commit the icon url mapping to the database |
| 172 // just in case we don't end up loading later - if we commit the mapping
a second time after the load, that's no big deal | 172 // just in case we don't end up loading later - if we commit the mapping
a second time after the load, that's no big deal |
| 173 // We also tell the client to register for the notification that the ico
n is received now so it isn't missed in case the | 173 // We also tell the client to register for the notification that the ico
n is received now so it isn't missed in case the |
| 174 // icon is later read in from disk | 174 // icon is later read in from disk |
| 175 LOG(IconDatabase, "IconController %p might load icon %s later", this, ur
lString.ascii().data()); | 175 LOG_INFO(IconDatabase, "IconController %p might load icon %s later", thi
s, urlString.ascii().data()); |
| 176 m_waitingForLoadDecision = true; | 176 m_waitingForLoadDecision = true; |
| 177 m_frame->loader()->client()->registerForIconNotification(); | 177 m_frame->loader()->client()->registerForIconNotification(); |
| 178 commitToDatabase(iconURL); | 178 commitToDatabase(iconURL); |
| 179 return; | 179 return; |
| 180 } | 180 } |
| 181 | 181 |
| 182 continueLoadWithDecision(decision); | 182 continueLoadWithDecision(decision); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void IconController::stopLoader() | 185 void IconController::stopLoader() |
| 186 { | 186 { |
| 187 if (m_iconLoader) | 187 if (m_iconLoader) |
| 188 m_iconLoader->stopLoading(); | 188 m_iconLoader->stopLoading(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 // Callback for the old-style synchronous IconDatabase interface. | 191 // Callback for the old-style synchronous IconDatabase interface. |
| 192 void IconController::loadDecisionReceived(IconLoadDecision iconLoadDecision) | 192 void IconController::loadDecisionReceived(IconLoadDecision iconLoadDecision) |
| 193 { | 193 { |
| 194 if (!m_waitingForLoadDecision) | 194 if (!m_waitingForLoadDecision) |
| 195 return; | 195 return; |
| 196 LOG(IconDatabase, "IconController %p was told a load decision is available f
or its icon", this); | 196 LOG_INFO(IconDatabase, "IconController %p was told a load decision is availa
ble for its icon", this); |
| 197 continueLoadWithDecision(iconLoadDecision); | 197 continueLoadWithDecision(iconLoadDecision); |
| 198 m_waitingForLoadDecision = false; | 198 m_waitingForLoadDecision = false; |
| 199 } | 199 } |
| 200 | 200 |
| 201 void IconController::continueLoadWithDecision(IconLoadDecision iconLoadDecision) | 201 void IconController::continueLoadWithDecision(IconLoadDecision iconLoadDecision) |
| 202 { | 202 { |
| 203 ASSERT(iconLoadDecision != IconLoadUnknown); | 203 ASSERT(iconLoadDecision != IconLoadUnknown); |
| 204 | 204 |
| 205 // FIXME (<rdar://problem/9168605>) - We should support in-memory-only priv
ate browsing icons in asynchronous icon database mode. | 205 // FIXME (<rdar://problem/9168605>) - We should support in-memory-only priv
ate browsing icons in asynchronous icon database mode. |
| 206 if (iconDatabase().supportsAsynchronousMode() && m_frame->page()->settings()
->privateBrowsingEnabled()) | 206 if (iconDatabase().supportsAsynchronousMode() && m_frame->page()->settings()
->privateBrowsingEnabled()) |
| 207 return; | 207 return; |
| 208 | 208 |
| 209 if (iconLoadDecision == IconLoadNo) { | 209 if (iconLoadDecision == IconLoadNo) { |
| 210 KURL iconURL(url()); | 210 KURL iconURL(url()); |
| 211 String urlString(iconURL.string()); | 211 String urlString(iconURL.string()); |
| 212 if (urlString.isEmpty()) | 212 if (urlString.isEmpty()) |
| 213 return; | 213 return; |
| 214 | 214 |
| 215 LOG(IconDatabase, "IconController::startLoader() - Told not to load this
icon, committing iconURL %s to database for pageURL mapping", urlString.ascii()
.data()); | 215 LOG_INFO(IconDatabase, "IconController::startLoader() - Told not to load
this icon, committing iconURL %s to database for pageURL mapping", urlString.as
cii().data()); |
| 216 commitToDatabase(iconURL); | 216 commitToDatabase(iconURL); |
| 217 | 217 |
| 218 if (iconDatabase().supportsAsynchronousMode()) { | 218 if (iconDatabase().supportsAsynchronousMode()) { |
| 219 m_frame->loader()->documentLoader()->getIconDataForIconURL(urlString
); | 219 m_frame->loader()->documentLoader()->getIconDataForIconURL(urlString
); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 | 222 |
| 223 // We were told not to load this icon - that means this icon is already
known by the database | 223 // We were told not to load this icon - that means this icon is already
known by the database |
| 224 // If the icon data hasn't been read in from disk yet, kick off the read
of the icon from the database to make sure someone | 224 // If the icon data hasn't been read in from disk yet, kick off the read
of the icon from the database to make sure someone |
| 225 // has done it. This is after registering for the notification so the We
bView can call the appropriate delegate method. | 225 // has done it. This is after registering for the notification so the We
bView can call the appropriate delegate method. |
| 226 // Otherwise if the icon data *is* available, notify the delegate | 226 // Otherwise if the icon data *is* available, notify the delegate |
| 227 if (!iconDatabase().synchronousIconDataKnownForIconURL(urlString)) { | 227 if (!iconDatabase().synchronousIconDataKnownForIconURL(urlString)) { |
| 228 LOG(IconDatabase, "Told not to load icon %s but icon data is not yet
available - registering for notification and requesting load from disk", urlStr
ing.ascii().data()); | 228 LOG_INFO(IconDatabase, "Told not to load icon %s but icon data is no
t yet available - registering for notification and requesting load from disk", u
rlString.ascii().data()); |
| 229 m_frame->loader()->client()->registerForIconNotification(); | 229 m_frame->loader()->client()->registerForIconNotification(); |
| 230 iconDatabase().synchronousIconForPageURL(m_frame->document()->url().
string(), IntSize(0, 0)); | 230 iconDatabase().synchronousIconForPageURL(m_frame->document()->url().
string(), IntSize(0, 0)); |
| 231 iconDatabase().synchronousIconForPageURL(m_frame->loader()->initialR
equest().url().string(), IntSize(0, 0)); | 231 iconDatabase().synchronousIconForPageURL(m_frame->loader()->initialR
equest().url().string(), IntSize(0, 0)); |
| 232 } else | 232 } else |
| 233 m_frame->loader()->client()->dispatchDidReceiveIcon(); | 233 m_frame->loader()->client()->dispatchDidReceiveIcon(); |
| 234 | 234 |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| 238 if (!m_iconLoader) | 238 if (!m_iconLoader) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 } | 276 } |
| 277 if (iconType == TouchIcon) { | 277 if (iconType == TouchIcon) { |
| 278 url.setPath("/apple-touch-icon.png"); | 278 url.setPath("/apple-touch-icon.png"); |
| 279 return IconURL::defaultIconURL(url, TouchIcon); | 279 return IconURL::defaultIconURL(url, TouchIcon); |
| 280 } | 280 } |
| 281 #endif | 281 #endif |
| 282 return IconURL(); | 282 return IconURL(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } | 285 } |
| OLD | NEW |