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

Side by Side Diff: chrome/browser/supervised_user/child_accounts/permission_request_creator_apiary.cc

Issue 2004043002: Supervised Users Initiated Installs v2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kid_initiated_install
Patch Set: Fixing the build again! Created 4 years, 5 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/child_accounts/permission_request_creat or_apiary.h" 5 #include "chrome/browser/supervised_user/child_accounts/permission_request_creat or_apiary.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 26 matching lines...) Expand all
37 37
38 const char kAuthorizationHeaderFormat[] = "Authorization: Bearer %s"; 38 const char kAuthorizationHeaderFormat[] = "Authorization: Bearer %s";
39 39
40 // Request keys. 40 // Request keys.
41 const char kEventTypeKey[] = "eventType"; 41 const char kEventTypeKey[] = "eventType";
42 const char kObjectRefKey[] = "objectRef"; 42 const char kObjectRefKey[] = "objectRef";
43 const char kStateKey[] = "state"; 43 const char kStateKey[] = "state";
44 44
45 // Request values. 45 // Request values.
46 const char kEventTypeURLRequest[] = "PERMISSION_CHROME_URL"; 46 const char kEventTypeURLRequest[] = "PERMISSION_CHROME_URL";
47 const char kEventTypeInstallRequest[] = "PERMISSION_CHROME_CWS_ITEM_INSTALL";
47 const char kEventTypeUpdateRequest[] = "PERMISSION_CHROME_CWS_ITEM_UPDATE"; 48 const char kEventTypeUpdateRequest[] = "PERMISSION_CHROME_CWS_ITEM_UPDATE";
48 const char kState[] = "PENDING"; 49 const char kState[] = "PENDING";
49 50
50 // Response keys. 51 // Response keys.
51 const char kPermissionRequestKey[] = "permissionRequest"; 52 const char kPermissionRequestKey[] = "permissionRequest";
52 const char kIdKey[] = "id"; 53 const char kIdKey[] = "id";
53 54
54 struct PermissionRequestCreatorApiary::Request { 55 struct PermissionRequestCreatorApiary::Request {
55 Request(const std::string& request_type, 56 Request(const std::string& request_type,
56 const std::string& object_ref, 57 const std::string& object_ref,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 bool PermissionRequestCreatorApiary::IsEnabled() const { 110 bool PermissionRequestCreatorApiary::IsEnabled() const {
110 return true; 111 return true;
111 } 112 }
112 113
113 void PermissionRequestCreatorApiary::CreateURLAccessRequest( 114 void PermissionRequestCreatorApiary::CreateURLAccessRequest(
114 const GURL& url_requested, 115 const GURL& url_requested,
115 const SuccessCallback& callback) { 116 const SuccessCallback& callback) {
116 CreateRequest(kEventTypeURLRequest, url_requested.spec(), callback); 117 CreateRequest(kEventTypeURLRequest, url_requested.spec(), callback);
117 } 118 }
118 119
120 void PermissionRequestCreatorApiary::CreateExtensionInstallRequest(
121 const std::string& id,
122 const SuccessCallback& callback) {
123 CreateRequest(kEventTypeInstallRequest, id, callback);
124 }
125
119 void PermissionRequestCreatorApiary::CreateExtensionUpdateRequest( 126 void PermissionRequestCreatorApiary::CreateExtensionUpdateRequest(
120 const std::string& id, 127 const std::string& id,
121 const SuccessCallback& callback) { 128 const SuccessCallback& callback) {
122 CreateRequest(kEventTypeUpdateRequest, id, callback); 129 CreateRequest(kEventTypeUpdateRequest, id, callback);
123 } 130 }
124 131
125 GURL PermissionRequestCreatorApiary::GetApiUrl() const { 132 GURL PermissionRequestCreatorApiary::GetApiUrl() const {
126 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 133 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
127 switches::kPermissionRequestApiUrl)) { 134 switches::kPermissionRequestApiUrl)) {
128 GURL url(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 135 GURL url(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return; 273 return;
267 } 274 }
268 DispatchResult(it, true); 275 DispatchResult(it, true);
269 } 276 }
270 277
271 void PermissionRequestCreatorApiary::DispatchResult(RequestIterator it, 278 void PermissionRequestCreatorApiary::DispatchResult(RequestIterator it,
272 bool success) { 279 bool success) {
273 (*it)->callback.Run(success); 280 (*it)->callback.Run(success);
274 requests_.erase(it); 281 requests_.erase(it);
275 } 282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698