| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/appcache/chrome_appcache_service.h" | 5 #include "chrome/browser/appcache/chrome_appcache_service.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" | 10 #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 // static | 75 // static |
| 76 void ChromeAppCacheService::ClearLocalState(const FilePath& profile_path) { | 76 void ChromeAppCacheService::ClearLocalState(const FilePath& profile_path) { |
| 77 file_util::Delete(profile_path.Append(chrome::kAppCacheDirname), true); | 77 file_util::Delete(profile_path.Append(chrome::kAppCacheDirname), true); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url) { | 80 bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url) { |
| 81 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 81 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 82 ContentSetting setting = host_contents_settings_map_->GetContentSetting( | 82 ContentSetting setting = host_contents_settings_map_->GetContentSetting( |
| 83 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES); | 83 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); |
| 84 DCHECK(setting != CONTENT_SETTING_DEFAULT); | 84 DCHECK(setting != CONTENT_SETTING_DEFAULT); |
| 85 // We don't prompt for read access. | 85 // We don't prompt for read access. |
| 86 return setting != CONTENT_SETTING_BLOCK; | 86 return setting != CONTENT_SETTING_BLOCK; |
| 87 } | 87 } |
| 88 | 88 |
| 89 int ChromeAppCacheService::CanCreateAppCache( | 89 int ChromeAppCacheService::CanCreateAppCache( |
| 90 const GURL& manifest_url, net::CompletionCallback* callback) { | 90 const GURL& manifest_url, net::CompletionCallback* callback) { |
| 91 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 91 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 92 ContentSetting setting = host_contents_settings_map_->GetContentSetting( | 92 ContentSetting setting = host_contents_settings_map_->GetContentSetting( |
| 93 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES); | 93 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); |
| 94 DCHECK(setting != CONTENT_SETTING_DEFAULT); | 94 DCHECK(setting != CONTENT_SETTING_DEFAULT); |
| 95 if (setting == CONTENT_SETTING_ASK) { | 95 if (setting == CONTENT_SETTING_ASK) { |
| 96 ChromeThread::PostTask( | 96 ChromeThread::PostTask( |
| 97 ChromeThread::UI, FROM_HERE, | 97 ChromeThread::UI, FROM_HERE, |
| 98 NewRunnableMethod(this, &ChromeAppCacheService::DoPrompt, | 98 NewRunnableMethod(this, &ChromeAppCacheService::DoPrompt, |
| 99 manifest_url, callback)); | 99 manifest_url, callback)); |
| 100 return net::ERR_IO_PENDING; | 100 return net::ERR_IO_PENDING; |
| 101 } | 101 } |
| 102 return (setting != CONTENT_SETTING_BLOCK) ? net::OK : | 102 return (setting != CONTENT_SETTING_BLOCK) ? net::OK : |
| 103 net::ERR_ACCESS_DENIED; | 103 net::ERR_ACCESS_DENIED; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void ChromeAppCacheService::DoPrompt( | 106 void ChromeAppCacheService::DoPrompt( |
| 107 const GURL& manifest_url, net::CompletionCallback* callback) { | 107 const GURL& manifest_url, net::CompletionCallback* callback) { |
| 108 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 108 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 109 | 109 |
| 110 // The setting may have changed (due to the "remember" option) | 110 // The setting may have changed (due to the "remember" option) |
| 111 ContentSetting setting = host_contents_settings_map_->GetContentSetting( | 111 ContentSetting setting = host_contents_settings_map_->GetContentSetting( |
| 112 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES); | 112 manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); |
| 113 if (setting != CONTENT_SETTING_ASK) { | 113 if (setting != CONTENT_SETTING_ASK) { |
| 114 int rv = (setting != CONTENT_SETTING_BLOCK) ? net::OK : | 114 int rv = (setting != CONTENT_SETTING_BLOCK) ? net::OK : |
| 115 net::ERR_ACCESS_DENIED; | 115 net::ERR_ACCESS_DENIED; |
| 116 DidPrompt(rv, manifest_url, callback); | 116 DidPrompt(rv, manifest_url, callback); |
| 117 return; | 117 return; |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Show the prompt on top of the current tab. | 120 // Show the prompt on top of the current tab. |
| 121 Browser* browser = BrowserList::GetLastActive(); | 121 Browser* browser = BrowserList::GetLastActive(); |
| 122 if (!browser || !browser->GetSelectedTabContents()) { | 122 if (!browser || !browser->GetSelectedTabContents()) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 const tracked_objects::Location& from_here, | 169 const tracked_objects::Location& from_here, |
| 170 Task* task) { | 170 Task* task) { |
| 171 return ChromeThread::PostTask(ToChromeThreadID(id), from_here, task); | 171 return ChromeThread::PostTask(ToChromeThreadID(id), from_here, task); |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool AppCacheThread::CurrentlyOn(int id) { | 174 bool AppCacheThread::CurrentlyOn(int id) { |
| 175 return ChromeThread::CurrentlyOn(ToChromeThreadID(id)); | 175 return ChromeThread::CurrentlyOn(ToChromeThreadID(id)); |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace appcache | 178 } // namespace appcache |
| OLD | NEW |