1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_MOBILE_EMULATION_OVERRIDE_MANAGER_H_ 6 #define CHROME_TEST_CHROMEDRIVER_CHROME_MOBILE_EMULATION_OVERRIDE_MANAGER_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 #include "base/compiler_specific.h" 12 #include "base/memory/scoped_ptr.h" 13 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" 14 15 namespace base { 16 class DictionaryValue; 17 } 18 19 struct BrowserInfo; 20 class DevToolsClient; 21 struct DeviceMetrics; 22 class Status; 23 24 // Overrides the device metrics, if requested, for the duration of the 25 // given |DevToolsClient|'s lifetime. 26 class MobileEmulationOverrideManager : public DevToolsEventListener { 27 public: 28 MobileEmulationOverrideManager(DevToolsClient* client, 29 const DeviceMetrics* device_metrics, 30 const BrowserInfo* browser_info); 31 virtual ~MobileEmulationOverrideManager(); 32 33 // Overridden from DevToolsEventListener: 34 virtual Status OnConnected(DevToolsClient* client) OVERRIDE; 35 virtual Status OnEvent(DevToolsClient* client, 36 const std::string& method, 37 const base::DictionaryValue& params) OVERRIDE; 38 39 private: 40 Status ApplyOverrideIfNeeded(); 41 42 DevToolsClient* client_; 43 const DeviceMetrics* overridden_device_metrics_; 44 const BrowserInfo* browser_info_; 45 46 DISALLOW_COPY_AND_ASSIGN(MobileEmulationOverrideManager); 47 }; 48 49 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_MOBILE_EMULATION_OVERRIDE_MANAGER_H_ 50