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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 source->AddLocalizedString("lockButton", IDS_HISTORY_LOCK_BUTTON); | 156 source->AddLocalizedString("lockButton", IDS_HISTORY_LOCK_BUTTON); |
155 source->AddLocalizedString("unlockButton", IDS_HISTORY_UNLOCK_BUTTON); | 157 source->AddLocalizedString("unlockButton", IDS_HISTORY_UNLOCK_BUTTON); |
156 source->AddLocalizedString("hasSyncedResults", | 158 source->AddLocalizedString("hasSyncedResults", |
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->AddBoolean("isFullHistorySyncEnabled", | 161 source->AddBoolean("isFullHistorySyncEnabled", |
160 WebHistoryServiceFactory::GetForProfile(profile) != NULL); | 162 WebHistoryServiceFactory::GetForProfile(profile) != NULL); |
161 source->AddBoolean("groupByDomain", | 163 source->AddBoolean("groupByDomain", |
162 CommandLine::ForCurrentProcess()->HasSwitch( | 164 CommandLine::ForCurrentProcess()->HasSwitch( |
163 switches::kHistoryEnableGroupByDomain)); | 165 switches::kHistoryEnableGroupByDomain)); |
166 source->AddBoolean("allowDeletingHistory", | |
167 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory)); | |
168 | |
164 source->SetJsonPath(kStringsJsFile); | 169 source->SetJsonPath(kStringsJsFile); |
165 source->AddResourcePath(kHistoryJsFile, IDR_HISTORY_JS); | 170 source->AddResourcePath(kHistoryJsFile, IDR_HISTORY_JS); |
166 source->AddResourcePath(kOtherDevicesJsFile, IDR_OTHER_DEVICES_JS); | 171 source->AddResourcePath(kOtherDevicesJsFile, IDR_OTHER_DEVICES_JS); |
167 source->SetDefaultResource(IDR_HISTORY_HTML); | 172 source->SetDefaultResource(IDR_HISTORY_HTML); |
168 source->SetUseJsonJSFormatV2(); | 173 source->SetUseJsonJSFormatV2(); |
169 source->DisableDenyXFrameOptions(); | 174 source->DisableDenyXFrameOptions(); |
170 | 175 |
171 #if defined(OS_ANDROID) || defined(OS_IOS) | 176 #if defined(OS_ANDROID) || defined(OS_IOS) |
172 source->AddBoolean("isManagedProfile", false); | 177 source->AddBoolean("isManagedProfile", false); |
173 #else | 178 #else |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 if (!ExtractIntegerValueAtIndex(args, 4, &options.max_count)) { | 552 if (!ExtractIntegerValueAtIndex(args, 4, &options.max_count)) { |
548 NOTREACHED() << "Failed to convert argument 4."; | 553 NOTREACHED() << "Failed to convert argument 4."; |
549 return; | 554 return; |
550 } | 555 } |
551 | 556 |
552 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; | 557 options.duplicate_policy = history::QueryOptions::REMOVE_DUPLICATES_PER_DAY; |
553 QueryHistory(search_text, options); | 558 QueryHistory(search_text, options); |
554 } | 559 } |
555 | 560 |
556 void BrowsingHistoryHandler::HandleRemoveVisits(const ListValue* args) { | 561 void BrowsingHistoryHandler::HandleRemoveVisits(const ListValue* args) { |
562 Profile* profile = Profile::FromWebUI(web_ui()); | |
563 if (!profile->GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory)) { | |
Patrick Dubroy
2013/04/18 14:15:19
Maybe just OR this onto the other condition below?
Pam (message me for reviews)
2013/04/18 14:41:44
Done. Done. Done. I'll spare you the spam. It's al
| |
564 web_ui()->CallJavascriptFunction("deleteFailed"); | |
565 return; | |
566 } | |
567 | |
557 if (delete_task_tracker_.HasTrackedTasks()) { | 568 if (delete_task_tracker_.HasTrackedTasks()) { |
558 web_ui()->CallJavascriptFunction("deleteFailed"); | 569 web_ui()->CallJavascriptFunction("deleteFailed"); |
559 return; | 570 return; |
560 } | 571 } |
561 | 572 |
562 Profile* profile = Profile::FromWebUI(web_ui()); | |
563 HistoryService* history_service = | 573 HistoryService* history_service = |
564 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); | 574 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); |
565 history::WebHistoryService* web_history = | 575 history::WebHistoryService* web_history = |
566 WebHistoryServiceFactory::GetForProfile(profile); | 576 WebHistoryServiceFactory::GetForProfile(profile); |
567 | 577 |
568 base::Time now = base::Time::Now(); | 578 base::Time now = base::Time::Now(); |
569 std::vector<history::ExpireHistoryArgs> expire_list; | 579 std::vector<history::ExpireHistoryArgs> expire_list; |
570 expire_list.reserve(args->GetSize()); | 580 expire_list.reserve(args->GetSize()); |
571 | 581 |
572 for (ListValue::const_iterator it = args->begin(); it != args->end(); ++it) { | 582 for (ListValue::const_iterator it = args->begin(); it != args->end(); ++it) { |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1170 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 1180 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
1171 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 1181 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
1172 } | 1182 } |
1173 | 1183 |
1174 // static | 1184 // static |
1175 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 1185 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
1176 ui::ScaleFactor scale_factor) { | 1186 ui::ScaleFactor scale_factor) { |
1177 return ResourceBundle::GetSharedInstance(). | 1187 return ResourceBundle::GetSharedInstance(). |
1178 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 1188 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
1179 } | 1189 } |
OLD | NEW |