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

Side by Side Diff: chrome/browser/supervised_user/permission_request_creator_apiary.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_apiary.h" 5 #include "chrome/browser/supervised_user/permission_request_creator_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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); 55 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile);
56 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper( 56 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper(
57 new SupervisedUserSigninManagerWrapper(profile, signin)); 57 new SupervisedUserSigninManagerWrapper(profile, signin));
58 scoped_ptr<PermissionRequestCreator> creator( 58 scoped_ptr<PermissionRequestCreator> creator(
59 new PermissionRequestCreatorApiary( 59 new PermissionRequestCreatorApiary(
60 token_service, signin_wrapper.Pass(), profile->GetRequestContext())); 60 token_service, signin_wrapper.Pass(), profile->GetRequestContext()));
61 return creator.Pass(); 61 return creator.Pass();
62 } 62 }
63 63
64 void PermissionRequestCreatorApiary::CreatePermissionRequest( 64 void PermissionRequestCreatorApiary::CreatePermissionRequest(
65 const std::string& url_requested, 65 const GURL& url_requested,
66 const base::Closure& callback) { 66 const base::Closure& callback) {
67 url_requested_ = url_requested; 67 url_requested_ = url_requested;
68 callback_ = callback; 68 callback_ = callback;
69 StartFetching(); 69 StartFetching();
70 } 70 }
71 71
72 void PermissionRequestCreatorApiary::StartFetching() { 72 void PermissionRequestCreatorApiary::StartFetching() {
73 OAuth2TokenService::ScopeSet scopes; 73 OAuth2TokenService::ScopeSet scopes;
74 if (CommandLine::ForCurrentProcess()->HasSwitch( 74 if (CommandLine::ForCurrentProcess()->HasSwitch(
75 switches::kPermissionRequestApiScope)) { 75 switches::kPermissionRequestApiScope)) {
(...skipping 20 matching lines...) Expand all
96 96
97 url_fetcher_->SetRequestContext(context_); 97 url_fetcher_->SetRequestContext(context_);
98 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 98 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
99 net::LOAD_DO_NOT_SAVE_COOKIES); 99 net::LOAD_DO_NOT_SAVE_COOKIES);
100 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); 100 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries);
101 url_fetcher_->AddExtraRequestHeader( 101 url_fetcher_->AddExtraRequestHeader(
102 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str())); 102 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str()));
103 103
104 base::DictionaryValue dict; 104 base::DictionaryValue dict;
105 dict.SetStringWithoutPathExpansion("namespace", kNamespace); 105 dict.SetStringWithoutPathExpansion("namespace", kNamespace);
106 dict.SetStringWithoutPathExpansion("objectRef", url_requested_); 106 dict.SetStringWithoutPathExpansion("objectRef", url_requested_.spec());
107 dict.SetStringWithoutPathExpansion("state", kState); 107 dict.SetStringWithoutPathExpansion("state", kState);
108 std::string body; 108 std::string body;
109 base::JSONWriter::Write(&dict, &body); 109 base::JSONWriter::Write(&dict, &body);
110 url_fetcher_->SetUploadData("application/json", body); 110 url_fetcher_->SetUploadData("application/json", body);
111 111
112 url_fetcher_->Start(); 112 url_fetcher_->Start();
113 } 113 }
114 114
115 void PermissionRequestCreatorApiary::OnGetTokenFailure( 115 void PermissionRequestCreatorApiary::OnGetTokenFailure(
116 const OAuth2TokenService::Request* request, 116 const OAuth2TokenService::Request* request,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void PermissionRequestCreatorApiary::DispatchNetworkError(int error_code) { 166 void PermissionRequestCreatorApiary::DispatchNetworkError(int error_code) {
167 DispatchGoogleServiceAuthError( 167 DispatchGoogleServiceAuthError(
168 GoogleServiceAuthError::FromConnectionError(error_code)); 168 GoogleServiceAuthError::FromConnectionError(error_code));
169 } 169 }
170 170
171 void PermissionRequestCreatorApiary::DispatchGoogleServiceAuthError( 171 void PermissionRequestCreatorApiary::DispatchGoogleServiceAuthError(
172 const GoogleServiceAuthError& error) { 172 const GoogleServiceAuthError& error) {
173 callback_.Run(); 173 callback_.Run();
174 callback_.Reset(); 174 callback_.Reset();
175 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698