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