summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_automation.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 05:54:21 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 05:54:21 +0000
commit4c4aae74e9f32f7ff06226b3d5e2fd1723127913 (patch)
tree3c07053473b5ff8e65d25fccfac0c48211cc229c /chrome_frame/chrome_frame_automation.cc
parent5dd879a6fb6d07222d6a940643301a3e0d5bc010 (diff)
downloadchromium_src-4c4aae74e9f32f7ff06226b3d5e2fd1723127913.zip
chromium_src-4c4aae74e9f32f7ff06226b3d5e2fd1723127913.tar.gz
chromium_src-4c4aae74e9f32f7ff06226b3d5e2fd1723127913.tar.bz2
Miscellaneous ChromeFrame code cleanup. The automation client class maintained GURL members holding the url and
referrer. We can stuff this information into the ChromeFrameLaunchParams member maintained by the client. This reduces the complexity in the code related to detecting whether we can navigate up front or after chrome initialization. The ChromeFrame ActiveX now launches the automation server in its implementation of IPersistPropertyBag::Load. This avoids race conditions between launching the automation server and navigating to it via put_src. Review URL: http://codereview.chromium.org/3038038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54284 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_frame_automation.cc')
-rw-r--r--chrome_frame/chrome_frame_automation.cc48
1 files changed, 27 insertions, 21 deletions
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index bed7be2..fdf5831 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -485,7 +485,9 @@ bool ChromeFrameAutomationClient::Initialize(
const ChromeFrameLaunchParams& chrome_launch_params) {
DCHECK(!IsWindow());
chrome_frame_delegate_ = chrome_frame_delegate;
+
chrome_launch_params_ = chrome_launch_params;
+
ui_thread_id_ = PlatformThread::CurrentId();
#ifndef NDEBUG
// In debug mode give more time to work with a debugger.
@@ -523,10 +525,6 @@ bool ChromeFrameAutomationClient::Initialize(
if (chrome_launch_params_.url.is_valid())
navigate_after_initialization_ = false;
- if (!navigate_after_initialization_) {
- chrome_launch_params_.url = url_;
- }
-
proxy_factory_->GetAutomationServer(
static_cast<ProxyFactory::LaunchDelegate*>(this),
chrome_launch_params_, &automation_server_id_);
@@ -591,19 +589,22 @@ bool ChromeFrameAutomationClient::InitiateNavigation(
return false;
}
- // Important: Since we will be using the referrer_ variable from a different
- // thread, we need to force a new std::string buffer instance for the
- // referrer_ GURL variable. Otherwise we can run into strangeness when the
- // GURL is accessed and it could result in a bad URL that can cause the
- // referrer to be dropped or something worse.
- referrer_ = GURL(referrer.c_str());
- url_ = parsed_url;
- navigate_after_initialization_ = false;
+ if (parsed_url != chrome_launch_params_.url) {
+ // Important: Since we will be using the referrer_ variable from a
+ // different thread, we need to force a new std::string buffer instance for
+ // the referrer_ GURL variable. Otherwise we can run into strangeness when
+ // the GURL is accessed and it could result in a bad URL that can cause the
+ // referrer to be dropped or something worse.
+ chrome_launch_params_.referrer = GURL(referrer.c_str());
+ chrome_launch_params_.url = parsed_url;
- if (is_initialized()) {
- BeginNavigate(url_, referrer_);
- } else {
- navigate_after_initialization_ = true;
+ navigate_after_initialization_ = false;
+
+ if (is_initialized()) {
+ BeginNavigate(chrome_launch_params_.url, chrome_launch_params_.referrer);
+ } else {
+ navigate_after_initialization_ = true;
+ }
}
return true;
@@ -648,7 +649,8 @@ void ChromeFrameAutomationClient::BeginNavigate(const GURL& url,
// Could be NULL if we failed to launch Chrome in LaunchAutomationServer()
if (!automation_server_ || !tab_.get()) {
DLOG(WARNING) << "BeginNavigate - can't navigate.";
- ReportNavigationError(AUTOMATION_MSG_NAVIGATION_ERROR, url_.spec());
+ ReportNavigationError(AUTOMATION_MSG_NAVIGATION_ERROR,
+ chrome_launch_params_.url.spec());
return;
}
@@ -674,7 +676,8 @@ void ChromeFrameAutomationClient::BeginNavigate(const GURL& url,
void ChromeFrameAutomationClient::BeginNavigateCompleted(
AutomationMsg_NavigationResponseValues result) {
if (result == AUTOMATION_MSG_NAVIGATION_ERROR)
- ReportNavigationError(AUTOMATION_MSG_NAVIGATION_ERROR, url_.spec());
+ ReportNavigationError(AUTOMATION_MSG_NAVIGATION_ERROR,
+ chrome_launch_params_.url.spec());
}
void ChromeFrameAutomationClient::FindInPage(const std::wstring& search_string,
@@ -794,8 +797,10 @@ void ChromeFrameAutomationClient::CreateExternalTab() {
DCHECK(IsWindow());
DCHECK(automation_server_ != NULL);
- // TODO(ananta)
- // We should pass in the referrer for the initial navigation.
+ if (chrome_launch_params_.url.is_valid()) {
+ navigate_after_initialization_ = false;
+ }
+
const IPC::ExternalTabSettings settings = {
m_hWnd,
gfx::Rect(),
@@ -917,7 +922,8 @@ void ChromeFrameAutomationClient::InitializeComplete(
// If host specified destination URL - navigate. Apparently we do not use
// accelerator table.
if (navigate_after_initialization_) {
- BeginNavigate(url_, referrer_);
+ BeginNavigate(chrome_launch_params_.url,
+ chrome_launch_params_.referrer);
}
}