diff options
author | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-30 21:37:04 +0000 |
---|---|---|
committer | amit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-30 21:37:04 +0000 |
commit | a8af771d9040b87f64b3a85131cfa0e265ac5639 (patch) | |
tree | 6cd5020fcda0b6616be7fec09bd2307743763fc0 /chrome | |
parent | 23cc9a18ab9c4893e3cad94c3683e7ffecefcbf0 (diff) | |
download | chromium_src-a8af771d9040b87f64b3a85131cfa0e265ac5639.zip chromium_src-a8af771d9040b87f64b3a85131cfa0e265ac5639.tar.gz chromium_src-a8af771d9040b87f64b3a85131cfa0e265ac5639.tar.bz2 |
ChromeURLRequestContext fallout
Fix the issues caused by static_cast<ChromeURLRequestContext*>.
There were assumptions in the code that a URLRequestContext*
will always be ChromeURLRequestContext* and resulting
'static_cast's. This assumption is no longer true. Instead,
URLlRequestContext now has a member GetChromeURLRequestContext
that returns a ChromeURLRequestContext* if it really that type.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/160332
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/automation_profile_impl.cc | 36 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 23 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.h | 3 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 3 |
4 files changed, 51 insertions, 14 deletions
diff --git a/chrome/browser/automation/automation_profile_impl.cc b/chrome/browser/automation/automation_profile_impl.cc index 02e2cc1..1cba8d6 100644 --- a/chrome/browser/automation/automation_profile_impl.cc +++ b/chrome/browser/automation/automation_profile_impl.cc @@ -3,27 +3,37 @@ // found in the LICENSE file. #include "chrome/browser/automation/automation_profile_impl.h" +#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/test/automation/automation_messages.h" -#include "net/url_request/url_request_context.h" // A special Request context for automation. Substitute a few things // like cookie store, proxy settings etc to handle them differently // for automation. -class AutomationURLRequestContext : public URLRequestContext { +class AutomationURLRequestContext : public ChromeURLRequestContext { public: AutomationURLRequestContext(URLRequestContext* original_context, - net::CookieStore* automation_cookie_store) { - host_resolver_ = original_context->host_resolver(); - proxy_service_ = original_context->proxy_service(); - http_transaction_factory_ = original_context->http_transaction_factory(); - ftp_transaction_factory_ = original_context->ftp_transaction_factory(); + net::CookieStore* automation_cookie_store) + // All URLRequestContexts in chrome extend from ChromeURLRequestContext + : ChromeURLRequestContext(static_cast<ChromeURLRequestContext*>( + original_context)) { cookie_store_ = automation_cookie_store; - cookie_policy_.set_type(original_context->cookie_policy()->type()); - force_tls_state_ = original_context->force_tls_state(); - // ftp_auth_cache_ = original_context->ftp_auth_cache(); - accept_language_ = original_context->accept_language(); - accept_charset_ = original_context->accept_charset(); - referrer_charset_ = original_context->referrer_charset(); + } + + ~AutomationURLRequestContext() { + // Clear out members before calling base class dtor since we don't + // own any of them. + + // Clear URLRequestContext members. + host_resolver_ = NULL; + proxy_service_ = NULL; + http_transaction_factory_ = NULL; + ftp_transaction_factory_ = NULL; + cookie_store_ = NULL; + force_tls_state_ = NULL; + + // Clear ChromeURLRequestContext members. + prefs_ = NULL; + blacklist_ = NULL; } private: diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 7130b45..f6df4a2 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -324,6 +324,29 @@ ChromeURLRequestContext::ChromeURLRequestContext(Profile* profile) } } +ChromeURLRequestContext::ChromeURLRequestContext( + ChromeURLRequestContext* other) { + // Set URLRequestContext members + host_resolver_ = other->host_resolver_; + proxy_service_ = other->proxy_service_; + http_transaction_factory_ = other->http_transaction_factory_; + ftp_transaction_factory_ = other->ftp_transaction_factory_; + cookie_store_ = other->cookie_store_; + cookie_policy_.set_type(other->cookie_policy_.type()); + force_tls_state_ = other->force_tls_state_; + accept_language_ = other->accept_language_; + accept_charset_ = other->accept_charset_; + referrer_charset_ = other->referrer_charset_; + + // Set ChromeURLRequestContext members + extension_paths_ = other->extension_paths_; + user_script_dir_path_ = other->user_script_dir_path_; + prefs_ = other->prefs_; + blacklist_ = other->blacklist_; + is_media_ = other->is_media_; + is_off_the_record_ = other->is_off_the_record_; +} + // NotificationObserver implementation. void ChromeURLRequestContext::Observe(NotificationType type, const NotificationSource& source, diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index debee5c..f4baea6 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -74,10 +74,11 @@ class ChromeURLRequestContext : public URLRequestContext, // Gets the Privacy Blacklist, if any for this context. const Blacklist* blacklist() const { return blacklist_; } -private: + protected: // Private constructor, use the static factory methods instead. This is // expected to be called on the UI thread. ChromeURLRequestContext(Profile* profile); + ChromeURLRequestContext(ChromeURLRequestContext* other); // Create a request context for media resources from a regular request // context. This helper method is called from CreateOriginalForMedia and diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index 02e77f7..75395af 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -811,6 +811,7 @@ TEST_F(ExternalTabTestType, IncognitoMode) { gfx::Rect(), WS_POPUP, true, + false, false }; HWND external_tab_container = NULL; @@ -849,6 +850,7 @@ TEST_F(ExternalTabTestType, ExternalTabPostMessage) { gfx::Rect(), WS_POPUP, false, + false, false }; HWND external_tab_container = NULL; @@ -892,6 +894,7 @@ TEST_F(ExternalTabTestType, ExternalTabPostMessageTarget) { gfx::Rect(), WS_POPUP, false, + false, false }; HWND external_tab_container = NULL; |