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