Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: chrome/browser/ui/webui/settings/site_settings_handler.cc

Issue 2237823003: Site Settings Desktop: Implement USB devices section. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/settings/site_settings_handler.h" 5 #include "chrome/browser/ui/webui/settings/site_settings_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" 14 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
16 #include "chrome/browser/permissions/chooser_context_base.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/webui/site_settings_helper.h" 18 #include "chrome/browser/ui/webui/site_settings_helper.h"
18 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 19 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
19 #include "components/content_settings/core/browser/host_content_settings_map.h" 20 #include "components/content_settings/core/browser/host_content_settings_map.h"
20 #include "components/content_settings/core/common/content_settings_types.h" 21 #include "components/content_settings/core/common/content_settings_types.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/web_ui.h" 23 #include "content/public/browser/web_ui.h"
23 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
24 #include "extensions/common/permissions/api_permission.h" 25 #include "extensions/common/permissions/api_permission.h"
25 #include "extensions/common/permissions/permissions_data.h" 26 #include "extensions/common/permissions/permissions_data.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 void SiteSettingsHandler::RegisterMessages() { 115 void SiteSettingsHandler::RegisterMessages() {
115 web_ui()->RegisterMessageCallback( 116 web_ui()->RegisterMessageCallback(
116 "fetchUsageTotal", 117 "fetchUsageTotal",
117 base::Bind(&SiteSettingsHandler::HandleFetchUsageTotal, 118 base::Bind(&SiteSettingsHandler::HandleFetchUsageTotal,
118 base::Unretained(this))); 119 base::Unretained(this)));
119 web_ui()->RegisterMessageCallback( 120 web_ui()->RegisterMessageCallback(
120 "clearUsage", 121 "clearUsage",
121 base::Bind(&SiteSettingsHandler::HandleClearUsage, 122 base::Bind(&SiteSettingsHandler::HandleClearUsage,
122 base::Unretained(this))); 123 base::Unretained(this)));
123 web_ui()->RegisterMessageCallback( 124 web_ui()->RegisterMessageCallback(
125 "fetchUsbDevices",
126 base::Bind(&SiteSettingsHandler::HandleFetchUsbDevices,
127 base::Unretained(this)));
128 web_ui()->RegisterMessageCallback(
129 "removeUsbDevice",
130 base::Bind(&SiteSettingsHandler::HandleRemoveUsbDevice,
131 base::Unretained(this)));
132 web_ui()->RegisterMessageCallback(
124 "setDefaultValueForContentType", 133 "setDefaultValueForContentType",
125 base::Bind(&SiteSettingsHandler::HandleSetDefaultValueForContentType, 134 base::Bind(&SiteSettingsHandler::HandleSetDefaultValueForContentType,
126 base::Unretained(this))); 135 base::Unretained(this)));
127 web_ui()->RegisterMessageCallback( 136 web_ui()->RegisterMessageCallback(
128 "getDefaultValueForContentType", 137 "getDefaultValueForContentType",
129 base::Bind(&SiteSettingsHandler::HandleGetDefaultValueForContentType, 138 base::Bind(&SiteSettingsHandler::HandleGetDefaultValueForContentType,
130 base::Unretained(this))); 139 base::Unretained(this)));
131 web_ui()->RegisterMessageCallback( 140 web_ui()->RegisterMessageCallback(
132 "getExceptionList", 141 "getExceptionList",
133 base::Bind(&SiteSettingsHandler::HandleGetExceptionList, 142 base::Bind(&SiteSettingsHandler::HandleGetExceptionList,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 base::Bind(&SiteSettingsHandler::OnUsageInfoCleared, 253 base::Bind(&SiteSettingsHandler::OnUsageInfoCleared,
245 base::Unretained(this))); 254 base::Unretained(this)));
246 255
247 // Also clear the *local* storage data. 256 // Also clear the *local* storage data.
248 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper = 257 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper =
249 new BrowsingDataLocalStorageHelper(profile_); 258 new BrowsingDataLocalStorageHelper(profile_);
250 local_storage_helper->DeleteOrigin(url); 259 local_storage_helper->DeleteOrigin(url);
251 } 260 }
252 } 261 }
253 262
263 void SiteSettingsHandler::HandleFetchUsbDevices(const base::ListValue* args) {
264 AllowJavascript();
265
266 CHECK_EQ(1U, args->GetSize());
267 const base::Value* callback_id;
268 CHECK(args->Get(0, &callback_id));
269
270 base::ListValue exceptions;
271 const site_settings::ChooserTypeNameEntry* chooser_type =
272 site_settings::ChooserTypeFromGroupName(site_settings::kGroupTypeUsb);
273 // TODO(finnur): Figure out whether incognito permissions are also needed.
274 site_settings::GetChooserExceptionsFromProfile(
275 profile_, false, *chooser_type, &exceptions);
276 ResolveJavascriptCallback(*callback_id, exceptions);
277 }
278
279 void SiteSettingsHandler::HandleRemoveUsbDevice(const base::ListValue* args) {
280 CHECK_EQ(3U, args->GetSize());
281
282 std::string origin_string;
283 CHECK(args->GetString(0, &origin_string));
284 GURL requesting_origin(origin_string);
285 CHECK(requesting_origin.is_valid());
286
287 std::string embedding_origin_string;
288 CHECK(args->GetString(1, &embedding_origin_string));
289 GURL embedding_origin(embedding_origin_string);
290 CHECK(embedding_origin.is_valid());
291
292 const base::DictionaryValue* object = nullptr;
293 CHECK(args->GetDictionary(2, &object));
294
295 const site_settings::ChooserTypeNameEntry* chooser_type =
296 site_settings::ChooserTypeFromGroupName(site_settings::kGroupTypeUsb);
297 ChooserContextBase* chooser_context = chooser_type->get_context(profile_);
298 chooser_context->RevokeObjectPermission(requesting_origin, embedding_origin,
299 *object);
300 }
301
254 void SiteSettingsHandler::HandleSetDefaultValueForContentType( 302 void SiteSettingsHandler::HandleSetDefaultValueForContentType(
255 const base::ListValue* args) { 303 const base::ListValue* args) {
256 CHECK_EQ(2U, args->GetSize()); 304 CHECK_EQ(2U, args->GetSize());
257 std::string content_type; 305 std::string content_type;
258 CHECK(args->GetString(0, &content_type)); 306 CHECK(args->GetString(0, &content_type));
259 std::string setting; 307 std::string setting;
260 CHECK(args->GetString(1, &setting)); 308 CHECK(args->GetString(1, &setting));
261 ContentSetting default_setting; 309 ContentSetting default_setting;
262 CHECK(content_settings::ContentSettingFromString(setting, &default_setting)); 310 CHECK(content_settings::ContentSettingFromString(setting, &default_setting));
263 311
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 std::string pattern_string; 428 std::string pattern_string;
381 CHECK(args->GetString(1, &pattern_string)); 429 CHECK(args->GetString(1, &pattern_string));
382 430
383 ContentSettingsPattern pattern = 431 ContentSettingsPattern pattern =
384 ContentSettingsPattern::FromString(pattern_string); 432 ContentSettingsPattern::FromString(pattern_string);
385 ResolveJavascriptCallback( 433 ResolveJavascriptCallback(
386 *callback_id, base::FundamentalValue(pattern.IsValid())); 434 *callback_id, base::FundamentalValue(pattern.IsValid()));
387 } 435 }
388 436
389 } // namespace settings 437 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/site_settings_handler.h ('k') | chrome/browser/ui/webui/site_settings_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698