| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/app_launcher_page_ui.h" | 5 #include "chrome/browser/ui/webui/app_launcher_page_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/webui/app_launcher_login_handler.h" | 12 #include "chrome/browser/ui/webui/app_launcher_login_handler.h" |
| 13 #include "chrome/browser/ui/webui/metrics_handler.h" | 13 #include "chrome/browser/ui/webui/metrics_handler.h" |
| 14 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 14 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| 15 #include "chrome/browser/ui/webui/ntp/app_resource_cache_factory.h" | 15 #include "chrome/browser/ui/webui/ntp/app_resource_cache_factory.h" |
| 16 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | 16 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
| 17 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" | 17 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" |
| 18 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" | 18 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
| 19 #include "chrome/browser/ui/webui/theme_handler.h" |
| 19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 20 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
| 21 #include "chrome/grit/theme_resources.h" | 22 #include "chrome/grit/theme_resources.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/browser/web_ui.h" | 26 #include "content/public/browser/web_ui.h" |
| 26 #include "extensions/browser/extension_system.h" | 27 #include "extensions/browser/extension_system.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 29 | 30 |
| 30 #if defined(ENABLE_THEMES) | |
| 31 #include "chrome/browser/ui/webui/theme_handler.h" | |
| 32 #endif | |
| 33 | |
| 34 class ExtensionService; | 31 class ExtensionService; |
| 35 | 32 |
| 36 using content::BrowserThread; | 33 using content::BrowserThread; |
| 37 | 34 |
| 38 /////////////////////////////////////////////////////////////////////////////// | 35 /////////////////////////////////////////////////////////////////////////////// |
| 39 // AppLauncherPageUI | 36 // AppLauncherPageUI |
| 40 | 37 |
| 41 AppLauncherPageUI::AppLauncherPageUI(content::WebUI* web_ui) | 38 AppLauncherPageUI::AppLauncherPageUI(content::WebUI* web_ui) |
| 42 : content::WebUIController(web_ui) { | 39 : content::WebUIController(web_ui) { |
| 43 web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_APP_LAUNCHER_TAB_TITLE)); | 40 web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_APP_LAUNCHER_TAB_TITLE)); |
| 44 | 41 |
| 45 if (!GetProfile()->IsOffTheRecord()) { | 42 if (!GetProfile()->IsOffTheRecord()) { |
| 46 ExtensionService* service = | 43 ExtensionService* service = |
| 47 extensions::ExtensionSystem::Get(GetProfile())->extension_service(); | 44 extensions::ExtensionSystem::Get(GetProfile())->extension_service(); |
| 48 // We should not be launched without an ExtensionService. | 45 // We should not be launched without an ExtensionService. |
| 49 DCHECK(service); | 46 DCHECK(service); |
| 50 web_ui->AddMessageHandler(new AppLauncherHandler(service)); | 47 web_ui->AddMessageHandler(new AppLauncherHandler(service)); |
| 51 web_ui->AddMessageHandler(new CoreAppLauncherHandler()); | 48 web_ui->AddMessageHandler(new CoreAppLauncherHandler()); |
| 52 web_ui->AddMessageHandler(new FaviconWebUIHandler()); | 49 web_ui->AddMessageHandler(new FaviconWebUIHandler()); |
| 53 web_ui->AddMessageHandler(new MetricsHandler()); | 50 web_ui->AddMessageHandler(new MetricsHandler()); |
| 54 } | 51 } |
| 55 | 52 |
| 56 #if defined(ENABLE_THEMES) | |
| 57 // The theme handler can require some CPU, so do it after hooking up the most | 53 // The theme handler can require some CPU, so do it after hooking up the most |
| 58 // visited handler. This allows the DB query for the new tab thumbs to happen | 54 // visited handler. This allows the DB query for the new tab thumbs to happen |
| 59 // earlier. | 55 // earlier. |
| 60 web_ui->AddMessageHandler(new ThemeHandler()); | 56 web_ui->AddMessageHandler(new ThemeHandler()); |
| 61 #endif | |
| 62 | 57 |
| 63 std::unique_ptr<HTMLSource> html_source( | 58 std::unique_ptr<HTMLSource> html_source( |
| 64 new HTMLSource(GetProfile()->GetOriginalProfile())); | 59 new HTMLSource(GetProfile()->GetOriginalProfile())); |
| 65 content::URLDataSource::Add(GetProfile(), html_source.release()); | 60 content::URLDataSource::Add(GetProfile(), html_source.release()); |
| 66 } | 61 } |
| 67 | 62 |
| 68 AppLauncherPageUI::~AppLauncherPageUI() { | 63 AppLauncherPageUI::~AppLauncherPageUI() { |
| 69 } | 64 } |
| 70 | 65 |
| 71 // static | 66 // static |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return "style-src 'self' chrome://resources chrome://theme 'unsafe-inline';"; | 138 return "style-src 'self' chrome://resources chrome://theme 'unsafe-inline';"; |
| 144 } | 139 } |
| 145 | 140 |
| 146 std::string AppLauncherPageUI::HTMLSource::GetContentSecurityPolicyImgSrc() | 141 std::string AppLauncherPageUI::HTMLSource::GetContentSecurityPolicyImgSrc() |
| 147 const { | 142 const { |
| 148 return "img-src chrome://extension-icon chrome://theme chrome://resources " | 143 return "img-src chrome://extension-icon chrome://theme chrome://resources " |
| 149 "data:;"; | 144 "data:;"; |
| 150 } | 145 } |
| 151 | 146 |
| 152 AppLauncherPageUI::HTMLSource::~HTMLSource() {} | 147 AppLauncherPageUI::HTMLSource::~HTMLSource() {} |
| OLD | NEW |