OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ntp/new_tab_ui.h" | 5 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
6 | 6 |
| 7 #include <memory> |
7 #include <set> | 8 #include <set> |
8 | 9 |
9 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
11 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/webui/metrics_handler.h" | 16 #include "chrome/browser/ui/webui/metrics_handler.h" |
17 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 17 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
18 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | 18 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
19 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" | 19 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.h" |
20 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" | 20 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
21 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" | 21 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // for example). | 76 // for example). |
77 if (service) | 77 if (service) |
78 web_ui->AddMessageHandler(new AppLauncherHandler(service)); | 78 web_ui->AddMessageHandler(new AppLauncherHandler(service)); |
79 } | 79 } |
80 | 80 |
81 #if defined(ENABLE_THEMES) | 81 #if defined(ENABLE_THEMES) |
82 if (!profile->IsGuestSession()) | 82 if (!profile->IsGuestSession()) |
83 web_ui->AddMessageHandler(new ThemeHandler()); | 83 web_ui->AddMessageHandler(new ThemeHandler()); |
84 #endif | 84 #endif |
85 | 85 |
86 scoped_ptr<NewTabHTMLSource> html_source( | 86 std::unique_ptr<NewTabHTMLSource> html_source( |
87 new NewTabHTMLSource(profile->GetOriginalProfile())); | 87 new NewTabHTMLSource(profile->GetOriginalProfile())); |
88 | 88 |
89 // content::URLDataSource assumes the ownership of the html_source. | 89 // content::URLDataSource assumes the ownership of the html_source. |
90 content::URLDataSource::Add(profile, html_source.release()); | 90 content::URLDataSource::Add(profile, html_source.release()); |
91 | 91 |
92 pref_change_registrar_.Init(profile->GetPrefs()); | 92 pref_change_registrar_.Init(profile->GetPrefs()); |
93 pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar, | 93 pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar, |
94 base::Bind(&NewTabUI::OnShowBookmarkBarChanged, | 94 base::Bind(&NewTabUI::OnShowBookmarkBarChanged, |
95 base::Unretained(this))); | 95 base::Unretained(this))); |
96 } | 96 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, | 244 void NewTabUI::NewTabHTMLSource::AddResource(const char* resource, |
245 const char* mime_type, | 245 const char* mime_type, |
246 int resource_id) { | 246 int resource_id) { |
247 DCHECK(resource); | 247 DCHECK(resource); |
248 DCHECK(mime_type); | 248 DCHECK(mime_type); |
249 resource_map_[std::string(resource)] = | 249 resource_map_[std::string(resource)] = |
250 std::make_pair(std::string(mime_type), resource_id); | 250 std::make_pair(std::string(mime_type), resource_id); |
251 } | 251 } |
252 | 252 |
253 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} | 253 NewTabUI::NewTabHTMLSource::~NewTabHTMLSource() {} |
OLD | NEW |