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

Side by Side Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 10836305: Ensure that isolated apps use the right cookies for media requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits Created 8 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 | Annotate | Revision Log
OLDNEW
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/net/chrome_url_request_context.h" 5 #include "chrome/browser/net/chrome_url_request_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 main_request_context_getter_->GetIOContext(), app_id_); 87 main_request_context_getter_->GetIOContext(), app_id_);
88 } 88 }
89 89
90 private: 90 private:
91 const ProfileIOData* const profile_io_data_; 91 const ProfileIOData* const profile_io_data_;
92 const std::string app_id_; 92 const std::string app_id_;
93 scoped_refptr<ChromeURLRequestContextGetter> 93 scoped_refptr<ChromeURLRequestContextGetter>
94 main_request_context_getter_; 94 main_request_context_getter_;
95 }; 95 };
96 96
97 // Factory that creates the media ChromeURLRequestContext for a given isolated
98 // app. The media context is based on the corresponding isolated app's context.
99 // Takes the |main_context| so that it can create the isolated app's context
willchan no longer on Chromium 2012/08/20 23:04:51 Do you think we should rename this to isolated_mai
Charlie Reis 2012/08/20 23:49:44 No, I actually mean the main context for the profi
100 // if necessary.
101 class FactoryForIsolatedMedia : public ChromeURLRequestContextFactory {
102 public:
103 FactoryForIsolatedMedia(const ProfileIOData* profile_io_data,
104 const std::string& app_id,
105 ChromeURLRequestContextGetter* main_context)
106 : profile_io_data_(profile_io_data),
107 app_id_(app_id),
108 main_request_context_getter_(main_context) {}
109
110 virtual ChromeURLRequestContext* Create() OVERRIDE {
111 // We will copy most of the state from the corresopnding app's
112 // request context, which we obtain using the main context.
113 return profile_io_data_->GetIsolatedMediaRequestContext(
114 main_request_context_getter_->GetIOContext(), app_id_);
115 }
116
117 private:
118 const ProfileIOData* const profile_io_data_;
119 const std::string app_id_;
120 scoped_refptr<ChromeURLRequestContextGetter>
121 main_request_context_getter_;
122 };
123
97 // Factory that creates the ChromeURLRequestContext for media. 124 // Factory that creates the ChromeURLRequestContext for media.
98 class FactoryForMedia : public ChromeURLRequestContextFactory { 125 class FactoryForMedia : public ChromeURLRequestContextFactory {
99 public: 126 public:
100 explicit FactoryForMedia(const ProfileIOData* profile_io_data) 127 explicit FactoryForMedia(const ProfileIOData* profile_io_data)
101 : profile_io_data_(profile_io_data) { 128 : profile_io_data_(profile_io_data) {
102 } 129 }
103 130
104 virtual ChromeURLRequestContext* Create() OVERRIDE { 131 virtual ChromeURLRequestContext* Create() OVERRIDE {
105 return profile_io_data_->GetMediaRequestContext(); 132 return profile_io_data_->GetMediaRequestContext();
106 } 133 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 DCHECK(!profile->IsOffTheRecord()); 218 DCHECK(!profile->IsOffTheRecord());
192 ChromeURLRequestContextGetter* main_context = 219 ChromeURLRequestContextGetter* main_context =
193 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); 220 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
194 return new ChromeURLRequestContextGetter( 221 return new ChromeURLRequestContextGetter(
195 profile, 222 profile,
196 new FactoryForIsolatedApp(profile_io_data, app_id, main_context)); 223 new FactoryForIsolatedApp(profile_io_data, app_id, main_context));
197 } 224 }
198 225
199 // static 226 // static
200 ChromeURLRequestContextGetter* 227 ChromeURLRequestContextGetter*
228 ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia(
229 Profile* profile,
230 const ProfileIOData* profile_io_data,
231 const std::string& app_id) {
232 DCHECK(!profile->IsOffTheRecord());
233 ChromeURLRequestContextGetter* main_context =
234 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
235 return new ChromeURLRequestContextGetter(
236 profile,
237 new FactoryForIsolatedMedia(profile_io_data, app_id, main_context));
238 }
239
240 // static
241 ChromeURLRequestContextGetter*
201 ChromeURLRequestContextGetter::CreateOffTheRecord( 242 ChromeURLRequestContextGetter::CreateOffTheRecord(
202 Profile* profile, const ProfileIOData* profile_io_data) { 243 Profile* profile, const ProfileIOData* profile_io_data) {
203 DCHECK(profile->IsOffTheRecord()); 244 DCHECK(profile->IsOffTheRecord());
204 return new ChromeURLRequestContextGetter( 245 return new ChromeURLRequestContextGetter(
205 profile, new FactoryForMain(profile_io_data)); 246 profile, new FactoryForMain(profile_io_data));
206 } 247 }
207 248
208 // static 249 // static
209 ChromeURLRequestContextGetter* 250 ChromeURLRequestContextGetter*
210 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions( 251 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); 380 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language));
340 } 381 }
341 382
342 void ChromeURLRequestContext::OnDefaultCharsetChange( 383 void ChromeURLRequestContext::OnDefaultCharsetChange(
343 const std::string& default_charset) { 384 const std::string& default_charset) {
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
345 set_referrer_charset(default_charset); 386 set_referrer_charset(default_charset);
346 set_accept_charset( 387 set_accept_charset(
347 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); 388 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset));
348 } 389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698