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

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

Issue 255047: Ensure ChromeURLRequestContext finds out first about extension loading (Closed)
Patch Set: cr changes Created 11 years, 2 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
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/privacy_blacklist/blacklist.h" 10 #include "chrome/browser/privacy_blacklist/blacklist.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 360 }
361 } 361 }
362 362
363 if (profile->GetUserScriptMaster()) 363 if (profile->GetUserScriptMaster())
364 user_script_dir_path_ = profile->GetUserScriptMaster()->user_script_dir(); 364 user_script_dir_path_ = profile->GetUserScriptMaster()->user_script_dir();
365 365
366 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); 366 prefs_->AddPrefObserver(prefs::kAcceptLanguages, this);
367 prefs_->AddPrefObserver(prefs::kCookieBehavior, this); 367 prefs_->AddPrefObserver(prefs::kCookieBehavior, this);
368 prefs_->AddPrefObserver(prefs::kDefaultCharset, this); 368 prefs_->AddPrefObserver(prefs::kDefaultCharset, this);
369 369
370 if (!is_off_the_record_) {
371 registrar_.Add(this, NotificationType::EXTENSION_LOADED,
372 NotificationService::AllSources());
373 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
374 NotificationService::AllSources());
375 }
376
377 ssl_config_service_ = profile->GetSSLConfigService(); 370 ssl_config_service_ = profile->GetSSLConfigService();
378 } 371 }
379 372
380 ChromeURLRequestContext::ChromeURLRequestContext( 373 ChromeURLRequestContext::ChromeURLRequestContext(
381 ChromeURLRequestContext* other) { 374 ChromeURLRequestContext* other) {
382 // Set URLRequestContext members 375 // Set URLRequestContext members
383 host_resolver_ = other->host_resolver_; 376 host_resolver_ = other->host_resolver_;
384 proxy_service_ = other->proxy_service_; 377 proxy_service_ = other->proxy_service_;
385 ssl_config_service_ = other->ssl_config_service_; 378 ssl_config_service_ = other->ssl_config_service_;
386 http_transaction_factory_ = other->http_transaction_factory_; 379 http_transaction_factory_ = other->http_transaction_factory_;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 &ChromeURLRequestContext::OnCookiePolicyChange, 418 &ChromeURLRequestContext::OnCookiePolicyChange,
426 policy_type)); 419 policy_type));
427 } else if (*pref_name_in == prefs::kDefaultCharset) { 420 } else if (*pref_name_in == prefs::kDefaultCharset) {
428 std::string default_charset = 421 std::string default_charset =
429 WideToASCII(prefs->GetString(prefs::kDefaultCharset)); 422 WideToASCII(prefs->GetString(prefs::kDefaultCharset));
430 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, 423 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
431 NewRunnableMethod(this, 424 NewRunnableMethod(this,
432 &ChromeURLRequestContext::OnDefaultCharsetChange, 425 &ChromeURLRequestContext::OnDefaultCharsetChange,
433 default_charset)); 426 default_charset));
434 } 427 }
435 } else if (NotificationType::EXTENSION_LOADED == type) {
436 ExtensionPaths* new_paths = new ExtensionPaths;
437 Extension* extension = Details<Extension>(details).ptr();
438 DCHECK(extension);
439 new_paths->insert(ExtensionPaths::value_type(extension->id(),
440 extension->path()));
441 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
442 NewRunnableMethod(this, &ChromeURLRequestContext::OnNewExtensions,
443 new_paths));
444 } else if (NotificationType::EXTENSION_UNLOADED == type) {
445 Extension* extension = Details<Extension>(details).ptr();
446 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
447 NewRunnableMethod(this, &ChromeURLRequestContext::OnUnloadedExtension,
448 extension->id()));
449 } else { 428 } else {
450 NOTREACHED(); 429 NOTREACHED();
451 } 430 }
452 } 431 }
453 432
454 void ChromeURLRequestContext::CleanupOnUIThread() { 433 void ChromeURLRequestContext::CleanupOnUIThread() {
455 // Unregister for pref notifications. 434 // Unregister for pref notifications.
456 prefs_->RemovePrefObserver(prefs::kAcceptLanguages, this); 435 prefs_->RemovePrefObserver(prefs::kAcceptLanguages, this);
457 prefs_->RemovePrefObserver(prefs::kCookieBehavior, this); 436 prefs_->RemovePrefObserver(prefs::kCookieBehavior, this);
458 prefs_->RemovePrefObserver(prefs::kDefaultCharset, this); 437 prefs_->RemovePrefObserver(prefs::kDefaultCharset, this);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 511
533 void ChromeURLRequestContext::OnDefaultCharsetChange( 512 void ChromeURLRequestContext::OnDefaultCharsetChange(
534 const std::string& default_charset) { 513 const std::string& default_charset) {
535 DCHECK(MessageLoop::current() == 514 DCHECK(MessageLoop::current() ==
536 ChromeThread::GetMessageLoop(ChromeThread::IO)); 515 ChromeThread::GetMessageLoop(ChromeThread::IO));
537 referrer_charset_ = default_charset; 516 referrer_charset_ = default_charset;
538 accept_charset_ = 517 accept_charset_ =
539 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset); 518 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset);
540 } 519 }
541 520
542 void ChromeURLRequestContext::OnNewExtensions(ExtensionPaths* new_paths) { 521 void ChromeURLRequestContext::OnNewExtensions(const std::string& id,
543 extension_paths_.insert(new_paths->begin(), new_paths->end()); 522 const FilePath& path) {
544 delete new_paths; 523 if (!is_off_the_record_) {
Matt Perry 2009/10/01 22:33:59 nit: remove braces
524 extension_paths_[id] = path;
525 }
545 } 526 }
546 527
547 void ChromeURLRequestContext::OnUnloadedExtension( 528 void ChromeURLRequestContext::OnUnloadedExtension(const std::string& id) {
548 const std::string& extension_id) { 529 if (is_off_the_record_)
549 ExtensionPaths::iterator iter = extension_paths_.find(extension_id); 530 return;
531 ExtensionPaths::iterator iter = extension_paths_.find(id);
550 DCHECK(iter != extension_paths_.end()); 532 DCHECK(iter != extension_paths_.end());
551 extension_paths_.erase(iter); 533 extension_paths_.erase(iter);
552 } 534 }
553 535
554 ChromeURLRequestContext::~ChromeURLRequestContext() { 536 ChromeURLRequestContext::~ChromeURLRequestContext() {
555 DCHECK(NULL == prefs_); 537 DCHECK(NULL == prefs_);
556 538
557 if (appcache_service_.get() && appcache_service_->request_context() == this) 539 if (appcache_service_.get() && appcache_service_->request_context() == this)
558 appcache_service_->set_request_context(NULL); 540 appcache_service_->set_request_context(NULL);
559 541
560 NotificationService::current()->Notify( 542 NotificationService::current()->Notify(
561 NotificationType::URL_REQUEST_CONTEXT_RELEASED, 543 NotificationType::URL_REQUEST_CONTEXT_RELEASED,
562 Source<URLRequestContext>(this), 544 Source<URLRequestContext>(this),
563 NotificationService::NoDetails()); 545 NotificationService::NoDetails());
564 546
565 delete ftp_transaction_factory_; 547 delete ftp_transaction_factory_;
566 delete http_transaction_factory_; 548 delete http_transaction_factory_;
567 } 549 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698