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> | |
8 | |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
9 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 14 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
13 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
15 #include "chrome/browser/ui/webui/browsing_history_handler.h" | 17 #include "chrome/browser/ui/webui/browsing_history_handler.h" |
16 #include "chrome/browser/ui/webui/metrics_handler.h" | 18 #include "chrome/browser/ui/webui/metrics_handler.h" |
17 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
19 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
20 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
23 #include "components/browsing_data_ui/history_notice_utils.h" | |
21 #include "components/prefs/pref_service.h" | 24 #include "components/prefs/pref_service.h" |
22 #include "components/search/search.h" | 25 #include "components/search/search.h" |
23 #include "components/signin/core/browser/signin_manager.h" | 26 #include "components/signin/core/browser/signin_manager.h" |
27 #include "content/public/browser/web_contents.h" | |
24 #include "content/public/browser/web_ui.h" | 28 #include "content/public/browser/web_ui.h" |
25 #include "content/public/browser/web_ui_data_source.h" | 29 #include "content/public/browser/web_ui_data_source.h" |
26 #include "grit/browser_resources.h" | 30 #include "grit/browser_resources.h" |
27 #include "grit/components_scaled_resources.h" | 31 #include "grit/components_scaled_resources.h" |
28 #include "grit/components_strings.h" | 32 #include "grit/components_strings.h" |
29 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
30 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
32 | 36 |
33 #if !defined(OS_ANDROID) | 37 #if !defined(OS_ANDROID) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 web_ui->AddMessageHandler(new MetricsHandler()); | 170 web_ui->AddMessageHandler(new MetricsHandler()); |
167 | 171 |
168 // On mobile we deal with foreign sessions differently. | 172 // On mobile we deal with foreign sessions differently. |
169 #if !defined(OS_ANDROID) | 173 #if !defined(OS_ANDROID) |
170 if (search::IsInstantExtendedAPIEnabled()) { | 174 if (search::IsInstantExtendedAPIEnabled()) { |
171 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); | 175 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); |
172 web_ui->AddMessageHandler(new HistoryLoginHandler()); | 176 web_ui->AddMessageHandler(new HistoryLoginHandler()); |
173 } | 177 } |
174 #endif | 178 #endif |
175 | 179 |
180 // TODO(crbug.com/595332): Since the API to query other forms of browsing | |
181 // history is not ready yet, make it possible to test the history UI as if | |
182 // it were. If the user opens chrome://history/?reset_ofbh, we will assume | |
183 // that other forms of browsing history exist (for all accounts), and we will | |
184 // also reset the one-time notice shown in the Clear Browsing Data dialog. | |
185 // This code should be removed as soon as the API is ready. | |
186 GURL url = web_ui->GetWebContents()->GetVisibleURL(); | |
187 if (url.has_query() && url.query() == "reset_ofbh") { | |
188 Profile::FromWebUI(web_ui)->GetPrefs()->SetInteger( | |
189 prefs::kClearBrowsingDataHistoryNoticeShownTimes, 0); | |
190 browsing_data_ui::testing::kOverrideOtherFormsOfBrowsingHistoryQuery = true; | |
Dan Beam
2016/04/21 03:12:55
this is a constant naming form (kConstantThing)
t
msramek
2016/04/21 08:50:30
Done.
| |
191 } | |
192 | |
176 // Set up the chrome://history-frame/ source. | 193 // Set up the chrome://history-frame/ source. |
177 Profile* profile = Profile::FromWebUI(web_ui); | 194 Profile* profile = Profile::FromWebUI(web_ui); |
178 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); | 195 content::WebUIDataSource::Add(profile, CreateHistoryUIHTMLSource(profile)); |
179 } | 196 } |
180 | 197 |
181 HistoryUI::~HistoryUI() {} | 198 HistoryUI::~HistoryUI() {} |
182 | 199 |
183 // static | 200 // static |
184 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 201 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
185 ui::ScaleFactor scale_factor) { | 202 ui::ScaleFactor scale_factor) { |
186 return ResourceBundle::GetSharedInstance(). | 203 return ResourceBundle::GetSharedInstance(). |
187 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 204 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
188 } | 205 } |
OLD | NEW |