summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/sync_setup_flow.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 20:58:59 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 20:58:59 +0000
commite8559e55970d8233a0a41973a29df4edc3b78f37 (patch)
treef1cd51574806286bb284fbfd0d4aa3fadec705a6 /chrome/browser/sync/sync_setup_flow.cc
parent3115bf87e34f5c40c93eb9349cda1a040f38573b (diff)
downloadchromium_src-e8559e55970d8233a0a41973a29df4edc3b78f37.zip
chromium_src-e8559e55970d8233a0a41973a29df4edc3b78f37.tar.gz
chromium_src-e8559e55970d8233a0a41973a29df4edc3b78f37.tar.bz2
Made FlowHandler() be created by SyncSetupFlow itself.
Clean up SyncSetupFlow's flow_handler_ if ownership isn't taken away from it. BUG= TEST=SyncSetupWizard unit tests Review URL: http://codereview.chromium.org/405027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/sync_setup_flow.cc')
-rw-r--r--chrome/browser/sync/sync_setup_flow.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc
index 51d513a..f5cdb84 100644
--- a/chrome/browser/sync/sync_setup_flow.cc
+++ b/chrome/browser/sync/sync_setup_flow.cc
@@ -146,8 +146,28 @@ void FlowHandler::ExecuteJavascriptInIFrame(const std::wstring& iframe_xpath,
}
}
+// Use static Run method to get an instance.
+SyncSetupFlow::SyncSetupFlow(SyncSetupWizard::State start_state,
+ SyncSetupWizard::State end_state,
+ const std::string& args,
+ SyncSetupFlowContainer* container,
+ ProfileSyncService* service)
+ : container_(container),
+ dialog_start_args_(args),
+ current_state_(start_state),
+ end_state_(end_state),
+ login_start_time_(base::TimeTicks::Now()),
+ flow_handler_(new FlowHandler()),
+ owns_flow_handler_(true),
+ service_(service) {
+ flow_handler_->set_flow(this);
+}
+
SyncSetupFlow::~SyncSetupFlow() {
flow_handler_->set_flow(NULL);
+ if (owns_flow_handler_) {
+ delete flow_handler_;
+ }
}
void SyncSetupFlow::GetDialogSize(gfx::Size* size) const {
@@ -231,6 +251,9 @@ void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service,
void SyncSetupFlow::GetDOMMessageHandlers(
std::vector<DOMMessageHandler*>* handlers) const {
handlers->push_back(flow_handler_);
+ // We don't own flow_handler_ anymore, but it sticks around until at least
+ // right after OnDialogClosed() is called (and this object is destroyed).
+ owns_flow_handler_ = false;
}
bool SyncSetupFlow::ShouldAdvance(SyncSetupWizard::State state) {
@@ -305,10 +328,8 @@ SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service,
if (!b)
return NULL;
- FlowHandler* handler = new FlowHandler();
SyncSetupFlow* flow = new SyncSetupFlow(start, end, json_args,
- container, handler, service);
- handler->set_flow(flow);
+ container, service);
b->BrowserShowHtmlDialog(flow, NULL);
return flow;
}