| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/test/webdriver/commands/create_session.h" | 5 #include "chrome/test/webdriver/commands/create_session.h" | 
| 6 | 6 | 
| 7 #include <sstream> | 7 #include <sstream> | 
| 8 #include <string> | 8 #include <string> | 
| 9 | 9 | 
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 21                              const DictionaryValue* const parameters) | 21                              const DictionaryValue* const parameters) | 
| 22     : Command(path_segments, parameters) {} | 22     : Command(path_segments, parameters) {} | 
| 23 | 23 | 
| 24 CreateSession::~CreateSession() {} | 24 CreateSession::~CreateSession() {} | 
| 25 | 25 | 
| 26 bool CreateSession::DoesPost() { return true; } | 26 bool CreateSession::DoesPost() { return true; } | 
| 27 | 27 | 
| 28 void CreateSession::ExecutePost(Response* const response) { | 28 void CreateSession::ExecutePost(Response* const response) { | 
| 29   SessionManager* session_manager = SessionManager::GetInstance(); | 29   SessionManager* session_manager = SessionManager::GetInstance(); | 
| 30 | 30 | 
|  | 31   bool native_events_required = false; | 
|  | 32   DictionaryValue* capabilities = NULL; | 
|  | 33   if (GetDictionaryParameter("desiredCapabilities", &capabilities)) { | 
|  | 34     capabilities->GetBoolean("chrome.nativeEvents", &native_events_required); | 
|  | 35   } | 
|  | 36 | 
| 31   // Session manages its own liftime, so do not call delete. | 37   // Session manages its own liftime, so do not call delete. | 
| 32   Session* session = new Session(); | 38   Session* session = new Session(); | 
| 33   if (!session->Init(session_manager->chrome_dir())) { | 39   if (!session->Init(session_manager->chrome_dir())) { | 
| 34     SET_WEBDRIVER_ERROR(response, | 40     SET_WEBDRIVER_ERROR(response, | 
| 35                         "Failed to initialize session", | 41                         "Failed to initialize session", | 
| 36                         kInternalServerError); | 42                         kInternalServerError); | 
| 37     return; | 43     return; | 
| 38   } | 44   } | 
|  | 45   session->set_use_native_events(native_events_required); | 
| 39 | 46 | 
| 40   VLOG(1) << "Created session " << session->id(); | 47   VLOG(1) << "Created session " << session->id(); | 
| 41   std::ostringstream stream; | 48   std::ostringstream stream; | 
| 42   stream << "http://" << session_manager->GetAddress() << "/session/" | 49   stream << "http://" << session_manager->GetAddress() << "/session/" | 
| 43          << session->id(); | 50          << session->id(); | 
| 44   response->SetStatus(kSeeOther); | 51   response->SetStatus(kSeeOther); | 
| 45   response->SetValue(Value::CreateStringValue(stream.str())); | 52   response->SetValue(Value::CreateStringValue(stream.str())); | 
| 46 } | 53 } | 
| 47 | 54 | 
| 48 }  // namespace webdriver | 55 }  // namespace webdriver | 
| OLD | NEW | 
|---|