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 "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 9 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
10 #include "chrome/browser/ui/webui/ntp/app_resource_cache_factory.h" | 10 #include "chrome/browser/ui/webui/ntp/app_resource_cache_factory.h" |
11 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" | 11 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" |
12 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" | 12 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/browser/web_ui.h" | 16 #include "content/public/browser/web_ui.h" |
16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
17 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
20 | 21 |
21 #if defined(ENABLE_THEMES) | 22 #if defined(ENABLE_THEMES) |
22 #include "chrome/browser/ui/webui/theme_handler.h" | 23 #include "chrome/browser/ui/webui/theme_handler.h" |
23 #endif | 24 #endif |
24 | 25 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 AppLauncherPageUI::HTMLSource::HTMLSource(Profile* profile) | 86 AppLauncherPageUI::HTMLSource::HTMLSource(Profile* profile) |
86 : profile_(profile) { | 87 : profile_(profile) { |
87 } | 88 } |
88 | 89 |
89 std::string AppLauncherPageUI::HTMLSource::GetSource() const { | 90 std::string AppLauncherPageUI::HTMLSource::GetSource() const { |
90 return chrome::kChromeUIAppLauncherPageHost; | 91 return chrome::kChromeUIAppLauncherPageHost; |
91 } | 92 } |
92 | 93 |
93 void AppLauncherPageUI::HTMLSource::StartDataRequest( | 94 void AppLauncherPageUI::HTMLSource::StartDataRequest( |
94 const std::string& path, | 95 const std::string& path, |
95 bool is_incognito, | 96 int render_process_id, |
| 97 int render_view_id, |
96 const content::URLDataSource::GotDataCallback& callback) { | 98 const content::URLDataSource::GotDataCallback& callback) { |
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
98 | 100 |
99 NTPResourceCache* resource = AppResourceCacheFactory::GetForProfile(profile_); | 101 NTPResourceCache* resource = AppResourceCacheFactory::GetForProfile(profile_); |
100 resource->set_should_show_most_visited_page(false); | 102 resource->set_should_show_most_visited_page(false); |
101 resource->set_should_show_other_devices_menu(false); | 103 resource->set_should_show_other_devices_menu(false); |
102 resource->set_should_show_recently_closed_menu(false); | 104 resource->set_should_show_recently_closed_menu(false); |
103 | 105 |
| 106 content::RenderProcessHost* render_host = |
| 107 content::RenderProcessHost::FromID(render_process_id); |
| 108 bool is_incognito = render_host->GetBrowserContext()->IsOffTheRecord(); |
104 scoped_refptr<base::RefCountedMemory> html_bytes( | 109 scoped_refptr<base::RefCountedMemory> html_bytes( |
105 resource->GetNewTabHTML(is_incognito)); | 110 resource->GetNewTabHTML(is_incognito)); |
106 | 111 |
107 callback.Run(html_bytes); | 112 callback.Run(html_bytes); |
108 } | 113 } |
109 | 114 |
110 std::string AppLauncherPageUI::HTMLSource::GetMimeType( | 115 std::string AppLauncherPageUI::HTMLSource::GetMimeType( |
111 const std::string& resource) const { | 116 const std::string& resource) const { |
112 return "text/html"; | 117 return "text/html"; |
113 } | 118 } |
114 | 119 |
115 bool AppLauncherPageUI::HTMLSource::ShouldReplaceExistingSource() const { | 120 bool AppLauncherPageUI::HTMLSource::ShouldReplaceExistingSource() const { |
116 return false; | 121 return false; |
117 } | 122 } |
118 | 123 |
119 bool AppLauncherPageUI::HTMLSource::ShouldAddContentSecurityPolicy() const { | 124 bool AppLauncherPageUI::HTMLSource::ShouldAddContentSecurityPolicy() const { |
120 return false; | 125 return false; |
121 } | 126 } |
122 | 127 |
123 AppLauncherPageUI::HTMLSource::~HTMLSource() {} | 128 AppLauncherPageUI::HTMLSource::~HTMLSource() {} |
OLD | NEW |