| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/engine/app/blimp_engine_config.h" | 5 #include "blimp/engine/app/blimp_engine_config.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "blimp/engine/app/switches.h" | 16 #include "blimp/engine/app/switches.h" |
| 17 #include "cc/base/switches.h" |
| 18 #include "content/public/common/content_switches.h" |
| 19 #include "ui/gl/gl_switches.h" |
| 20 #include "ui/native_theme/native_theme_switches.h" |
| 16 | 21 |
| 17 namespace blimp { | 22 namespace blimp { |
| 18 namespace engine { | 23 namespace engine { |
| 19 | 24 |
| 20 namespace { | 25 namespace { |
| 21 // Gets the client token from the file provided by the command line. If a read | 26 // Gets the client token from the file provided by the command line. If a read |
| 22 // does not succeed, or the switch is malformed, an empty string is returned. | 27 // does not succeed, or the switch is malformed, an empty string is returned. |
| 23 std::string GetClientToken(const base::CommandLine& cmd_line) { | 28 std::string GetClientToken(const base::CommandLine& cmd_line) { |
| 24 std::string file_contents; | 29 std::string file_contents; |
| 25 const base::FilePath path = cmd_line.GetSwitchValuePath(kClientTokenPath); | 30 const base::FilePath path = cmd_line.GetSwitchValuePath(kClientTokenPath); |
| 26 if (!base::ReadFileToString(path, &file_contents)) { | 31 if (!base::ReadFileToString(path, &file_contents)) { |
| 27 LOG(ERROR) << "Could not read client token file at " | 32 LOG(ERROR) << "Could not read client token file at " |
| 28 << (path.empty() ? "(not provided)" : path.AsUTF8Unsafe()); | 33 << (path.empty() ? "(not provided)" : path.AsUTF8Unsafe()); |
| 29 } | 34 } |
| 30 return base::CollapseWhitespaceASCII(file_contents, true); | 35 return base::CollapseWhitespaceASCII(file_contents, true); |
| 31 } | 36 } |
| 32 } // namespace | 37 } // namespace |
| 33 | 38 |
| 39 void SetCommandLineDefaults(base::CommandLine* command_line) { |
| 40 command_line->AppendSwitch(::switches::kEnableOverlayScrollbar); |
| 41 command_line->AppendSwitch(cc::switches::kDisableCachedPictureRaster); |
| 42 command_line->AppendSwitch(::switches::kDisableGpu); |
| 43 command_line->AppendSwitch( |
| 44 "disable-remote-fonts"); // switches::kDisableRemoteFonts is not visible. |
| 45 command_line->AppendSwitch(::switches::kUseRemoteCompositing); |
| 46 command_line->AppendSwitchASCII( |
| 47 ::switches::kUseGL, |
| 48 "osmesa"); // Avoid invoking gpu::CollectDriverVersionNVidia. |
| 49 } |
| 50 |
| 34 BlimpEngineConfig::~BlimpEngineConfig() {} | 51 BlimpEngineConfig::~BlimpEngineConfig() {} |
| 35 | 52 |
| 36 // static | 53 // static |
| 37 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::Create( | 54 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::Create( |
| 38 const base::CommandLine& cmd_line) { | 55 const base::CommandLine& cmd_line) { |
| 39 const std::string client_token = GetClientToken(cmd_line); | 56 const std::string client_token = GetClientToken(cmd_line); |
| 40 if (!client_token.empty()) { | 57 if (!client_token.empty()) { |
| 41 return base::WrapUnique(new BlimpEngineConfig(client_token)); | 58 return base::WrapUnique(new BlimpEngineConfig(client_token)); |
| 42 } | 59 } |
| 43 return nullptr; | 60 return nullptr; |
| 44 } | 61 } |
| 45 | 62 |
| 46 // static | 63 // static |
| 47 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::CreateForTest( | 64 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::CreateForTest( |
| 48 const std::string& client_token) { | 65 const std::string& client_token) { |
| 49 return base::WrapUnique(new BlimpEngineConfig(client_token)); | 66 return base::WrapUnique(new BlimpEngineConfig(client_token)); |
| 50 } | 67 } |
| 51 | 68 |
| 52 const std::string& BlimpEngineConfig::client_token() const { | 69 const std::string& BlimpEngineConfig::client_token() const { |
| 53 return client_token_; | 70 return client_token_; |
| 54 } | 71 } |
| 55 | 72 |
| 56 BlimpEngineConfig::BlimpEngineConfig(const std::string& client_token) | 73 BlimpEngineConfig::BlimpEngineConfig(const std::string& client_token) |
| 57 : client_token_(client_token) {} | 74 : client_token_(client_token) {} |
| 58 | 75 |
| 59 } // namespace engine | 76 } // namespace engine |
| 60 } // namespace blimp | 77 } // namespace blimp |
| OLD | NEW |