1 // Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that 3 // can be found in the LICENSE file. 4 5 #include "tests/cefclient/browser/client_browser.h" 6 #include "tests/cefclient/browser/main_context.h" 7 8 #include "include/cef_command_line.h" 9 #include "include/cef_crash_util.h" 10 #include "include/cef_file_util.h" 11 #include "tests/shared/common/client_switches.h" 12 13 namespace client { 14 namespace browser { 15 16 namespace { 17 18 class ClientBrowserDelegate : public ClientAppBrowser::Delegate { 19 public: ClientBrowserDelegate()20 ClientBrowserDelegate() {} 21 OnContextInitialized(CefRefPtr<ClientAppBrowser> app)22 void OnContextInitialized(CefRefPtr<ClientAppBrowser> app) override { 23 if (CefCrashReportingEnabled()) { 24 // Set some crash keys for testing purposes. Keys must be defined in the 25 // "crash_reporter.cfg" file. See cef_crash_util.h for details. 26 CefSetCrashKeyValue("testkey_small1", "value1_small_browser"); 27 CefSetCrashKeyValue("testkey_small2", "value2_small_browser"); 28 CefSetCrashKeyValue("testkey_medium1", "value1_medium_browser"); 29 CefSetCrashKeyValue("testkey_medium2", "value2_medium_browser"); 30 CefSetCrashKeyValue("testkey_large1", "value1_large_browser"); 31 CefSetCrashKeyValue("testkey_large2", "value2_large_browser"); 32 } 33 34 const std::string& crl_sets_path = 35 CefCommandLine::GetGlobalCommandLine()->GetSwitchValue( 36 switches::kCRLSetsPath); 37 if (!crl_sets_path.empty()) { 38 // Load the CRLSets file from the specified path. 39 CefLoadCRLSetsFile(crl_sets_path); 40 } 41 } 42 OnBeforeCommandLineProcessing(CefRefPtr<ClientAppBrowser> app,CefRefPtr<CefCommandLine> command_line)43 void OnBeforeCommandLineProcessing( 44 CefRefPtr<ClientAppBrowser> app, 45 CefRefPtr<CefCommandLine> command_line) override { 46 // Append Chromium command line parameters if touch events are enabled 47 if (client::MainContext::Get()->TouchEventsEnabled()) 48 command_line->AppendSwitchWithValue("touch-events", "enabled"); 49 } 50 51 private: 52 DISALLOW_COPY_AND_ASSIGN(ClientBrowserDelegate); 53 IMPLEMENT_REFCOUNTING(ClientBrowserDelegate); 54 }; 55 56 } // namespace 57 CreateDelegates(ClientAppBrowser::DelegateSet & delegates)58void CreateDelegates(ClientAppBrowser::DelegateSet& delegates) { 59 delegates.insert(new ClientBrowserDelegate); 60 } 61 62 } // namespace browser 63 } // namespace client 64