OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui/options/website_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/website_settings_handler.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_service.h" | |
8 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_iterator.h" | 9 #include "chrome/browser/ui/browser_iterator.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
13 #include "components/content_settings/core/browser/content_settings_utils.h" | 12 #include "components/content_settings/core/browser/content_settings_utils.h" |
14 #include "components/content_settings/core/browser/host_content_settings_map.h" | 13 #include "components/content_settings/core/browser/host_content_settings_map.h" |
15 #include "components/power/origin_power_map.h" | 14 #include "components/power/origin_power_map.h" |
16 #include "components/power/origin_power_map_factory.h" | 15 #include "components/power/origin_power_map_factory.h" |
17 #include "content/public/browser/dom_storage_context.h" | 16 #include "content/public/browser/dom_storage_context.h" |
18 #include "content/public/browser/storage_partition.h" | 17 #include "content/public/browser/storage_partition.h" |
19 #include "content/public/browser/user_metrics.h" | 18 #include "content/public/browser/user_metrics.h" |
20 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
21 #include "content/public/browser/web_ui.h" | 20 #include "content/public/browser/web_ui.h" |
22 #include "extensions/browser/app_window/app_window_registry.h" | 21 #include "extensions/browser/app_window/app_window_registry.h" |
23 #include "extensions/browser/extension_registry.h" | 22 #include "extensions/browser/extension_registry.h" |
24 #include "extensions/browser/extension_system.h" | |
25 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
26 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
27 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
28 #include "ui/base/l10n/time_format.h" | 26 #include "ui/base/l10n/time_format.h" |
29 #include "ui/base/text/bytes_formatting.h" | 27 #include "ui/base/text/bytes_formatting.h" |
30 | 28 |
31 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
32 #include "components/user_manager/user_manager.h" | 30 #include "components/user_manager/user_manager.h" |
33 #endif | 31 #endif |
34 | 32 |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 local_storage_ = new BrowsingDataLocalStorageHelper(profile); | 747 local_storage_ = new BrowsingDataLocalStorageHelper(profile); |
750 | 748 |
751 local_storage_->StartFetching( | 749 local_storage_->StartFetching( |
752 base::Bind(&WebsiteSettingsHandler::OnLocalStorageFetched, | 750 base::Bind(&WebsiteSettingsHandler::OnLocalStorageFetched, |
753 weak_ptr_factory_.GetWeakPtr())); | 751 weak_ptr_factory_.GetWeakPtr())); |
754 } | 752 } |
755 | 753 |
756 const std::string& WebsiteSettingsHandler::GetReadableName( | 754 const std::string& WebsiteSettingsHandler::GetReadableName( |
757 const GURL& site_url) { | 755 const GURL& site_url) { |
758 if (site_url.SchemeIs(extensions::kExtensionScheme)) { | 756 if (site_url.SchemeIs(extensions::kExtensionScheme)) { |
759 Profile* profile = GetProfile(); | 757 const extensions::ExtensionRegistry* registry = |
760 ExtensionService* extension_service = | 758 extensions::ExtensionRegistry::Get(GetProfile()); |
761 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
762 | |
763 const extensions::Extension* extension = | 759 const extensions::Extension* extension = |
764 extension_service->extensions()->GetExtensionOrAppByURL(site_url); | 760 registry->enabled_extensions().GetByID(site_url.host()); |
765 // If extension is NULL, it was removed and we cannot look up its name. | 761 // If extension is NULL, it was removed and we cannot look up its name. |
766 if (!extension) | 762 if (!extension) |
767 return site_url.spec(); | 763 return site_url.spec(); |
768 | 764 |
769 return extension->name(); | 765 return extension->name(); |
770 } | 766 } |
771 return site_url.spec(); | 767 return site_url.spec(); |
772 } | 768 } |
773 | 769 |
774 Profile* WebsiteSettingsHandler::GetProfile() { | 770 Profile* WebsiteSettingsHandler::GetProfile() { |
775 Profile* profile = Profile::FromWebUI(web_ui()); | 771 Profile* profile = Profile::FromWebUI(web_ui()); |
776 #if defined(OS_CHROMEOS) | 772 #if defined(OS_CHROMEOS) |
777 // Chrome OS special case: in Guest mode settings are opened in Incognito | 773 // Chrome OS special case: in Guest mode settings are opened in Incognito |
778 // mode, so we need original profile to actually modify settings. | 774 // mode, so we need original profile to actually modify settings. |
779 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 775 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
780 profile = profile->GetOriginalProfile(); | 776 profile = profile->GetOriginalProfile(); |
781 #endif | 777 #endif |
782 return profile; | 778 return profile; |
783 } | 779 } |
784 | 780 |
785 } // namespace options | 781 } // namespace options |
OLD | NEW |