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

Side by Side Diff: chrome/browser/supervised_user/permission_request_creator_sync.cc

Issue 522633002: Supervised users: Escape the URL only in permission requests sent through Sync (not Apiary). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/supervised_user/permission_request_creator_sync.h" 5 #include "chrome/browser/supervised_user/permission_request_creator_sync.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" 9 #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
10 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service .h" 10 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service .h"
11 #include "net/base/escape.h"
12 #include "url/gurl.h"
11 13
12 using base::Time; 14 using base::Time;
13 15
14 const char kSupervisedUserAccessRequestKeyPrefix[] = 16 const char kSupervisedUserAccessRequestKeyPrefix[] =
15 "X-ManagedUser-AccessRequests"; 17 "X-ManagedUser-AccessRequests";
16 const char kSupervisedUserAccessRequestTime[] = "timestamp"; 18 const char kSupervisedUserAccessRequestTime[] = "timestamp";
17 const char kSupervisedUserName[] = "name"; 19 const char kSupervisedUserName[] = "name";
18 20
19 // Key for the notification setting of the custodian. This is a shared setting 21 // Key for the notification setting of the custodian. This is a shared setting
20 // so we can include the setting in the access request data that is used to 22 // so we can include the setting in the access request data that is used to
21 // trigger notifications. 23 // trigger notifications.
22 const char kNotificationSetting[] = "custodian-notification-setting"; 24 const char kNotificationSetting[] = "custodian-notification-setting";
23 25
24 PermissionRequestCreatorSync::PermissionRequestCreatorSync( 26 PermissionRequestCreatorSync::PermissionRequestCreatorSync(
25 SupervisedUserSettingsService* settings_service, 27 SupervisedUserSettingsService* settings_service,
26 SupervisedUserSharedSettingsService* shared_settings_service, 28 SupervisedUserSharedSettingsService* shared_settings_service,
27 const std::string& name, 29 const std::string& name,
28 const std::string& supervised_user_id) 30 const std::string& supervised_user_id)
29 : settings_service_(settings_service), 31 : settings_service_(settings_service),
30 shared_settings_service_(shared_settings_service), 32 shared_settings_service_(shared_settings_service),
31 name_(name), 33 name_(name),
32 supervised_user_id_(supervised_user_id) { 34 supervised_user_id_(supervised_user_id) {
33 } 35 }
34 36
35 PermissionRequestCreatorSync::~PermissionRequestCreatorSync() {} 37 PermissionRequestCreatorSync::~PermissionRequestCreatorSync() {}
36 38
37 void PermissionRequestCreatorSync::CreatePermissionRequest( 39 void PermissionRequestCreatorSync::CreatePermissionRequest(
38 const std::string& url_requested, 40 const GURL& url_requested,
39 const base::Closure& callback) { 41 const base::Closure& callback) {
40 // Add the prefix. 42 // Escape the URL and add the prefix.
41 std::string key = SupervisedUserSettingsService::MakeSplitSettingKey( 43 std::string key = SupervisedUserSettingsService::MakeSplitSettingKey(
42 kSupervisedUserAccessRequestKeyPrefix, url_requested); 44 kSupervisedUserAccessRequestKeyPrefix,
45 net::EscapeQueryParamValue(url_requested.spec(), true));
43 46
44 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 47 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
45 48
46 // TODO(sergiu): Use sane time here when it's ready. 49 // TODO(sergiu): Use sane time here when it's ready.
47 dict->SetDouble(kSupervisedUserAccessRequestTime, 50 dict->SetDouble(kSupervisedUserAccessRequestTime,
48 base::Time::Now().ToJsTime()); 51 base::Time::Now().ToJsTime());
49 52
50 dict->SetString(kSupervisedUserName, name_); 53 dict->SetString(kSupervisedUserName, name_);
51 54
52 // Copy the notification setting of the custodian. 55 // Copy the notification setting of the custodian.
53 const base::Value* value = shared_settings_service_->GetValue( 56 const base::Value* value = shared_settings_service_->GetValue(
54 supervised_user_id_, kNotificationSetting); 57 supervised_user_id_, kNotificationSetting);
55 bool notifications_enabled = false; 58 bool notifications_enabled = false;
56 if (value) { 59 if (value) {
57 bool success = value->GetAsBoolean(&notifications_enabled); 60 bool success = value->GetAsBoolean(&notifications_enabled);
58 DCHECK(success); 61 DCHECK(success);
59 } 62 }
60 dict->SetBoolean(kNotificationSetting, notifications_enabled); 63 dict->SetBoolean(kNotificationSetting, notifications_enabled);
61 64
62 settings_service_->UploadItem(key, dict.PassAs<base::Value>()); 65 settings_service_->UploadItem(key, dict.PassAs<base::Value>());
63 66
64 callback.Run(); 67 callback.Run();
65 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698