| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 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 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 m_callback.clear(); | 119 m_callback.clear(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void PolicyChecker::stopCheck() | 122 void PolicyChecker::stopCheck() |
| 123 { | 123 { |
| 124 PolicyCallback callback = m_callback; | 124 PolicyCallback callback = m_callback; |
| 125 m_callback.clear(); | 125 m_callback.clear(); |
| 126 callback.cancel(); | 126 callback.cancel(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void PolicyChecker::cannotShowMIMEType(const ResourceResponse& response) | |
| 130 { | |
| 131 handleUnimplementablePolicy(m_frame->loader()->client()->cannotShowMIMETypeE
rror(response)); | |
| 132 } | |
| 133 | |
| 134 void PolicyChecker::continueAfterNavigationPolicy(PolicyAction policy) | 129 void PolicyChecker::continueAfterNavigationPolicy(PolicyAction policy) |
| 135 { | 130 { |
| 136 PolicyCallback callback = m_callback; | 131 PolicyCallback callback = m_callback; |
| 137 m_callback.clear(); | 132 m_callback.clear(); |
| 138 | 133 |
| 139 bool shouldContinue = policy == PolicyUse; | 134 bool shouldContinue = policy == PolicyUse; |
| 140 | 135 |
| 141 switch (policy) { | 136 switch (policy) { |
| 142 case PolicyIgnore: | 137 case PolicyIgnore: |
| 143 callback.clearRequest(); | 138 callback.clearRequest(); |
| 144 break; | 139 break; |
| 145 case PolicyDownload: { | 140 case PolicyDownload: { |
| 146 ResourceRequest request = callback.request(); | 141 ResourceRequest request = callback.request(); |
| 147 m_frame->loader()->setOriginalURLForDownloadRequest(request); | 142 m_frame->loader()->setOriginalURLForDownloadRequest(request); |
| 148 m_frame->loader()->client()->startDownload(request); | 143 m_frame->loader()->client()->startDownload(request); |
| 149 callback.clearRequest(); | 144 callback.clearRequest(); |
| 150 break; | 145 break; |
| 151 } | 146 } |
| 152 case PolicyUse: { | 147 case PolicyUse: |
| 153 ResourceRequest request(callback.request()); | |
| 154 | |
| 155 if (!m_frame->loader()->client()->canHandleRequest(request)) { | |
| 156 handleUnimplementablePolicy(m_frame->loader()->client()->cannotS
howURLError(callback.request())); | |
| 157 callback.clearRequest(); | |
| 158 shouldContinue = false; | |
| 159 } | |
| 160 break; | 148 break; |
| 161 } | |
| 162 } | 149 } |
| 163 | 150 |
| 164 callback.call(shouldContinue); | 151 callback.call(shouldContinue); |
| 165 } | 152 } |
| 166 | 153 |
| 167 void PolicyChecker::continueAfterNewWindowPolicy(PolicyAction policy) | 154 void PolicyChecker::continueAfterNewWindowPolicy(PolicyAction policy) |
| 168 { | 155 { |
| 169 PolicyCallback callback = m_callback; | 156 PolicyCallback callback = m_callback; |
| 170 m_callback.clear(); | 157 m_callback.clear(); |
| 171 | 158 |
| 172 switch (policy) { | 159 switch (policy) { |
| 173 case PolicyIgnore: | 160 case PolicyIgnore: |
| 174 callback.clearRequest(); | 161 callback.clearRequest(); |
| 175 break; | 162 break; |
| 176 case PolicyDownload: | 163 case PolicyDownload: |
| 177 m_frame->loader()->client()->startDownload(callback.request()); | 164 m_frame->loader()->client()->startDownload(callback.request()); |
| 178 callback.clearRequest(); | 165 callback.clearRequest(); |
| 179 break; | 166 break; |
| 180 case PolicyUse: | 167 case PolicyUse: |
| 181 break; | 168 break; |
| 182 } | 169 } |
| 183 | 170 |
| 184 callback.call(policy == PolicyUse); | 171 callback.call(policy == PolicyUse); |
| 185 } | 172 } |
| 186 | 173 |
| 187 void PolicyChecker::handleUnimplementablePolicy(const ResourceError& error) | |
| 188 { | |
| 189 m_delegateIsHandlingUnimplementablePolicy = true; | |
| 190 m_frame->loader()->client()->dispatchUnableToImplementPolicy(error); | |
| 191 m_delegateIsHandlingUnimplementablePolicy = false; | |
| 192 } | |
| 193 | |
| 194 } // namespace WebCore | 174 } // namespace WebCore |
| OLD | NEW |