| 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/extensions/extension_dom_ui.h" | 5 #include "chrome/browser/extensions/extension_dom_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // static | 156 // static |
| 157 void ExtensionDOMUI::RegisterUserPrefs(PrefService* prefs) { | 157 void ExtensionDOMUI::RegisterUserPrefs(PrefService* prefs) { |
| 158 prefs->RegisterDictionaryPref(kExtensionURLOverrides); | 158 prefs->RegisterDictionaryPref(kExtensionURLOverrides); |
| 159 } | 159 } |
| 160 | 160 |
| 161 // static | 161 // static |
| 162 bool ExtensionDOMUI::HandleChromeURLOverride(GURL* url, Profile* profile) { | 162 bool ExtensionDOMUI::HandleChromeURLOverride(GURL* url, Profile* profile) { |
| 163 if (!url->SchemeIs(chrome::kChromeUIScheme)) | 163 if (!url->SchemeIs(chrome::kChromeUIScheme)) |
| 164 return false; | 164 return false; |
| 165 | 165 |
| 166 // Even when the extensions service is enabled by default, it's still | 166 // We can't handle chrome-extension URLs in incognito mode. |
| 167 // disabled in incognito mode. | 167 if (profile->IsOffTheRecord()) |
| 168 ExtensionsService* service = profile->GetExtensionsService(); | |
| 169 if (!service) | |
| 170 return false; | 168 return false; |
| 171 | 169 |
| 172 const DictionaryValue* overrides = | 170 const DictionaryValue* overrides = |
| 173 profile->GetPrefs()->GetDictionary(kExtensionURLOverrides); | 171 profile->GetPrefs()->GetDictionary(kExtensionURLOverrides); |
| 174 std::string page = url->host(); | 172 std::string page = url->host(); |
| 175 ListValue* url_list; | 173 ListValue* url_list; |
| 176 if (!overrides || !overrides->GetList(UTF8ToWide(page), &url_list)) | 174 if (!overrides || !overrides->GetList(UTF8ToWide(page), &url_list)) |
| 177 return false; | 175 return false; |
| 178 | 176 |
| 177 ExtensionsService* service = profile->GetExtensionsService(); |
| 179 if (!service->is_ready()) { | 178 if (!service->is_ready()) { |
| 180 // TODO(erikkay) So far, it looks like extensions load before the new tab | 179 // TODO(erikkay) So far, it looks like extensions load before the new tab |
| 181 // page. I don't know if we have anything that enforces this, so add this | 180 // page. I don't know if we have anything that enforces this, so add this |
| 182 // check for safety. | 181 // check for safety. |
| 183 NOTREACHED() << "Chrome URL override requested before extensions loaded"; | 182 NOTREACHED() << "Chrome URL override requested before extensions loaded"; |
| 184 return false; | 183 return false; |
| 185 } | 184 } |
| 186 | 185 |
| 187 while (url_list->GetSize()) { | 186 while (url_list->GetSize()) { |
| 188 Value* val; | 187 Value* val; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 341 |
| 343 Extension* extension = service->GetExtensionByURL(page_url); | 342 Extension* extension = service->GetExtensionByURL(page_url); |
| 344 if (!extension) | 343 if (!extension) |
| 345 return NULL; | 344 return NULL; |
| 346 | 345 |
| 347 // TODO(arv): Move this off of the UI thread and onto the File thread. If | 346 // TODO(arv): Move this off of the UI thread and onto the File thread. If |
| 348 // possible to do this asynchronously, use ImageLoadingTracker. | 347 // possible to do this asynchronously, use ImageLoadingTracker. |
| 349 return ReadFileData(extension->GetIconPath( | 348 return ReadFileData(extension->GetIconPath( |
| 350 Extension::EXTENSION_ICON_BITTY).GetFilePathOnAnyThreadHack()); | 349 Extension::EXTENSION_ICON_BITTY).GetFilePathOnAnyThreadHack()); |
| 351 } | 350 } |
| OLD | NEW |