| 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/history_ui.h" | 5 #include "chrome/browser/ui/webui/history_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 return source; | 170 return source; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace | 173 } // namespace |
| 174 | 174 |
| 175 HistoryUI::HistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 175 HistoryUI::HistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 176 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); | 176 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); |
| 177 web_ui->AddMessageHandler(new MetricsHandler()); | 177 web_ui->AddMessageHandler(new MetricsHandler()); |
| 178 | 178 |
| 179 Profile* profile = Profile::FromWebUI(web_ui); |
| 180 content::WebUIDataSource* data_source = CreateHistoryUIHTMLSource(profile); |
| 181 |
| 179 // On mobile we deal with foreign sessions differently. | 182 // On mobile we deal with foreign sessions differently. |
| 180 #if !defined(OS_ANDROID) | 183 #if !defined(OS_ANDROID) |
| 181 if (search::IsInstantExtendedAPIEnabled()) { | 184 if (search::IsInstantExtendedAPIEnabled()) { |
| 182 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); | 185 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); |
| 183 web_ui->AddMessageHandler(new HistoryLoginHandler()); | 186 web_ui->AddMessageHandler(new HistoryLoginHandler(data_source)); |
| 184 } | 187 } |
| 185 #endif | 188 #endif |
| 186 | 189 |
| 187 // TODO(crbug.com/595332): Since the API to query other forms of browsing | 190 // TODO(crbug.com/595332): Since the API to query other forms of browsing |
| 188 // history is not ready yet, make it possible to test the history UI as if | 191 // history is not ready yet, make it possible to test the history UI as if |
| 189 // it were. If the user opens chrome://history/?reset_ofbh, we will assume | 192 // it were. If the user opens chrome://history/?reset_ofbh, we will assume |
| 190 // that other forms of browsing history exist (for all accounts), and we will | 193 // that other forms of browsing history exist (for all accounts), and we will |
| 191 // also reset the one-time notice shown in the Clear Browsing Data dialog. | 194 // also reset the one-time notice shown in the Clear Browsing Data dialog. |
| 192 // This code should be removed as soon as the API is ready. | 195 // This code should be removed as soon as the API is ready. |
| 193 GURL url = web_ui->GetWebContents()->GetVisibleURL(); | 196 GURL url = web_ui->GetWebContents()->GetVisibleURL(); |
| 194 if (url.has_query() && url.query() == "reset_ofbh") { | 197 if (url.has_query() && url.query() == "reset_ofbh") { |
| 195 Profile::FromWebUI(web_ui)->GetPrefs()->SetInteger( | 198 Profile::FromWebUI(web_ui)->GetPrefs()->SetInteger( |
| 196 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes, 0); | 199 browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes, 0); |
| 197 browsing_data::testing:: | 200 browsing_data::testing:: |
| 198 g_override_other_forms_of_browsing_history_query = true; | 201 g_override_other_forms_of_browsing_history_query = true; |
| 199 } | 202 } |
| 200 | 203 |
| 201 // Set up the chrome://history-frame/ source. | 204 // Set up the chrome://history-frame/ source. |
| 202 Profile* profile = Profile::FromWebUI(web_ui); | 205 content::WebUIDataSource::Add(profile, data_source); |
| 203 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); | 206 |
| 204 } | 207 } |
| 205 | 208 |
| 206 HistoryUI::~HistoryUI() {} | 209 HistoryUI::~HistoryUI() {} |
| 207 | 210 |
| 208 // static | 211 // static |
| 209 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 212 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
| 210 ui::ScaleFactor scale_factor) { | 213 ui::ScaleFactor scale_factor) { |
| 211 return ResourceBundle::GetSharedInstance(). | 214 return ResourceBundle::GetSharedInstance(). |
| 212 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 215 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
| 213 } | 216 } |
| OLD | NEW |