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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 #else | 95 #else |
96 const char kIncognitoModeShortcut[] = "(Shift+Ctrl+N)"; | 96 const char kIncognitoModeShortcut[] = "(Shift+Ctrl+N)"; |
97 #endif | 97 #endif |
98 | 98 |
99 // Identifiers for the type of device from which a history entry originated. | 99 // Identifiers for the type of device from which a history entry originated. |
100 static const char kDeviceTypeLaptop[] = "laptop"; | 100 static const char kDeviceTypeLaptop[] = "laptop"; |
101 static const char kDeviceTypePhone[] = "phone"; | 101 static const char kDeviceTypePhone[] = "phone"; |
102 static const char kDeviceTypeTablet[] = "tablet"; | 102 static const char kDeviceTypeTablet[] = "tablet"; |
103 | 103 |
104 content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) { | 104 content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) { |
| 105 PrefService* prefs = profile->GetPrefs(); |
| 106 |
105 content::WebUIDataSource* source = | 107 content::WebUIDataSource* source = |
106 content::WebUIDataSource::Create(chrome::kChromeUIHistoryFrameHost); | 108 content::WebUIDataSource::Create(chrome::kChromeUIHistoryFrameHost); |
107 source->AddBoolean("isUserSignedIn", | 109 source->AddBoolean("isUserSignedIn", |
108 !profile->GetPrefs()->GetString(prefs::kGoogleServicesUsername).empty()); | 110 !prefs->GetString(prefs::kGoogleServicesUsername).empty()); |
109 source->AddLocalizedString("collapseSessionMenuItemText", | 111 source->AddLocalizedString("collapseSessionMenuItemText", |
110 IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION); | 112 IDS_NEW_TAB_OTHER_SESSIONS_COLLAPSE_SESSION); |
111 source->AddLocalizedString("expandSessionMenuItemText", | 113 source->AddLocalizedString("expandSessionMenuItemText", |
112 IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION); | 114 IDS_NEW_TAB_OTHER_SESSIONS_EXPAND_SESSION); |
113 source->AddLocalizedString("restoreSessionMenuItemText", | 115 source->AddLocalizedString("restoreSessionMenuItemText", |
114 IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL); | 116 IDS_NEW_TAB_OTHER_SESSIONS_OPEN_ALL); |
115 source->AddLocalizedString("xMore", IDS_OTHER_DEVICES_X_MORE); | 117 source->AddLocalizedString("xMore", IDS_OTHER_DEVICES_X_MORE); |
116 source->AddLocalizedString("loading", IDS_HISTORY_LOADING); | 118 source->AddLocalizedString("loading", IDS_HISTORY_LOADING); |
117 source->AddLocalizedString("title", IDS_HISTORY_TITLE); | 119 source->AddLocalizedString("title", IDS_HISTORY_TITLE); |
118 source->AddLocalizedString("newest", IDS_HISTORY_NEWEST); | 120 source->AddLocalizedString("newest", IDS_HISTORY_NEWEST); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 IDS_HISTORY_HAS_SYNCED_RESULTS); | 159 IDS_HISTORY_HAS_SYNCED_RESULTS); |
158 source->AddLocalizedString("noSyncedResults", IDS_HISTORY_NO_SYNCED_RESULTS); | 160 source->AddLocalizedString("noSyncedResults", IDS_HISTORY_NO_SYNCED_RESULTS); |
159 source->AddLocalizedString("cancel", IDS_CANCEL); | 161 source->AddLocalizedString("cancel", IDS_CANCEL); |
160 source->AddLocalizedString("deleteConfirm", | 162 source->AddLocalizedString("deleteConfirm", |
161 IDS_HISTORY_DELETE_PRIOR_VISITS_CONFIRM_BUTTON); | 163 IDS_HISTORY_DELETE_PRIOR_VISITS_CONFIRM_BUTTON); |
162 source->AddBoolean("isFullHistorySyncEnabled", | 164 source->AddBoolean("isFullHistorySyncEnabled", |
163 WebHistoryServiceFactory::GetForProfile(profile) != NULL); | 165 WebHistoryServiceFactory::GetForProfile(profile) != NULL); |
164 source->AddBoolean("groupByDomain", | 166 source->AddBoolean("groupByDomain", |
165 CommandLine::ForCurrentProcess()->HasSwitch( | 167 CommandLine::ForCurrentProcess()->HasSwitch( |
166 switches::kHistoryEnableGroupByDomain)); | 168 switches::kHistoryEnableGroupByDomain)); |
| 169 source->AddBoolean("allowDeletingHistory", |
| 170 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory)); |
| 171 |
167 source->SetJsonPath(kStringsJsFile); | 172 source->SetJsonPath(kStringsJsFile); |
168 source->AddResourcePath(kHistoryJsFile, IDR_HISTORY_JS); | 173 source->AddResourcePath(kHistoryJsFile, IDR_HISTORY_JS); |
169 source->AddResourcePath(kOtherDevicesJsFile, IDR_OTHER_DEVICES_JS); | 174 source->AddResourcePath(kOtherDevicesJsFile, IDR_OTHER_DEVICES_JS); |
170 source->SetDefaultResource(IDR_HISTORY_HTML); | 175 source->SetDefaultResource(IDR_HISTORY_HTML); |
171 source->SetUseJsonJSFormatV2(); | 176 source->SetUseJsonJSFormatV2(); |
172 source->DisableDenyXFrameOptions(); | 177 source->DisableDenyXFrameOptions(); |
173 | 178 |
174 #if defined(OS_ANDROID) || defined(OS_IOS) | 179 #if defined(OS_ANDROID) || defined(OS_IOS) |
175 source->AddBoolean("isManagedProfile", false); | 180 source->AddBoolean("isManagedProfile", false); |
176 #else | 181 #else |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 if (!ExtractIntegerValueAtIndex(args, 4, &options.max_count)) { | 558 if (!ExtractIntegerValueAtIndex(args, 4, &options.max_count)) { |
554 NOTREACHED() << "Failed to convert argument 4."; | 559 NOTREACHED() << "Failed to convert argument 4."; |
555 return; | 560 return; |
556 } | 561 } |
557 | 562 |
558 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; | 563 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; |
559 QueryHistory(search_text, options); | 564 QueryHistory(search_text, options); |
560 } | 565 } |
561 | 566 |
562 void BrowsingHistoryHandler::HandleRemoveVisits(const ListValue* args) { | 567 void BrowsingHistoryHandler::HandleRemoveVisits(const ListValue* args) { |
563 if (delete_task_tracker_.HasTrackedTasks()) { | 568 Profile* profile = Profile::FromWebUI(web_ui()); |
| 569 if (delete_task_tracker_.HasTrackedTasks() || |
| 570 !profile->GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)) { |
564 web_ui()->CallJavascriptFunction("deleteFailed"); | 571 web_ui()->CallJavascriptFunction("deleteFailed"); |
565 return; | 572 return; |
566 } | 573 } |
567 | 574 |
568 Profile* profile = Profile::FromWebUI(web_ui()); | |
569 HistoryService* history_service = | 575 HistoryService* history_service = |
570 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); | 576 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); |
571 history::WebHistoryService* web_history = | 577 history::WebHistoryService* web_history = |
572 WebHistoryServiceFactory::GetForProfile(profile); | 578 WebHistoryServiceFactory::GetForProfile(profile); |
573 | 579 |
574 base::Time now = base::Time::Now(); | 580 base::Time now = base::Time::Now(); |
575 std::vector<history::ExpireHistoryArgs> expire_list; | 581 std::vector<history::ExpireHistoryArgs> expire_list; |
576 expire_list.reserve(args->GetSize()); | 582 expire_list.reserve(args->GetSize()); |
577 | 583 |
578 for (ListValue::const_iterator it = args->begin(); it != args->end(); ++it) { | 584 for (ListValue::const_iterator it = args->begin(); it != args->end(); ++it) { |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 1187 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
1182 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 1188 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
1183 } | 1189 } |
1184 | 1190 |
1185 // static | 1191 // static |
1186 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 1192 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
1187 ui::ScaleFactor scale_factor) { | 1193 ui::ScaleFactor scale_factor) { |
1188 return ResourceBundle::GetSharedInstance(). | 1194 return ResourceBundle::GetSharedInstance(). |
1189 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 1195 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
1190 } | 1196 } |
OLD | NEW |