Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: blimp/engine/app/blimp_engine_config.cc

Issue 1929723002: [Blimp] Adds blimp engine browser test framework and LoadUrl test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addresses comments and rebases Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/native_theme/native_theme_switches.h"
16 20
17 namespace blimp { 21 namespace blimp {
18 namespace engine { 22 namespace engine {
19 23
20 namespace { 24 namespace {
21 // Gets the client token from the file provided by the command line. If a read 25 // Gets the client token from the command line. Either from the token provided,
26 // or from the file provided by the command line. If a file 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 token;
25 const base::FilePath path = cmd_line.GetSwitchValuePath(kClientTokenPath); 30 if (cmd_line.HasSwitch(kClientToken)) {
Kevin M 2016/05/02 21:32:39 As this is just a test hook, I don't think it's ap
haibinlu 2016/05/03 19:32:43 reverted. per offline discussion, added a data fil
26 if (!base::ReadFileToString(path, &file_contents)) { 31 token = cmd_line.GetSwitchValueASCII(kClientToken);
27 LOG(ERROR) << "Could not read client token file at " 32 } else {
28 << (path.empty() ? "(not provided)" : path.AsUTF8Unsafe()); 33 DCHECK(cmd_line.HasSwitch(kClientTokenPath));
34 const base::FilePath path = cmd_line.GetSwitchValuePath(kClientTokenPath);
35 if (!base::ReadFileToString(path, &token)) {
36 LOG(ERROR) << "Could not read client token file at "
37 << (path.empty() ? "(not provided)" : path.AsUTF8Unsafe());
38 }
29 } 39 }
30 return base::CollapseWhitespaceASCII(file_contents, true); 40 return base::CollapseWhitespaceASCII(token, true);
31 } 41 }
32 } // namespace 42 } // namespace
33 43
44 void SetUpCommandLine(base::CommandLine* command_line) {
45 command_line->AppendSwitch(::switches::kEnableOverlayScrollbar);
46 command_line->AppendSwitch(cc::switches::kDisableCachedPictureRaster);
47 command_line->AppendSwitch(::switches::kDisableGpu);
48 command_line->AppendSwitch(
49 "disable-remote-fonts"); // switches::kDisableRemoteFonts is not visible.
50 command_line->AppendSwitch(::switches::kUseRemoteCompositing);
51 command_line->AppendSwitchASCII(
52 ::switches::kUseGL,
53 "osmesa"); // Avoid invoking gpu::CollectDriverVersionNVidia.
54 }
55
34 BlimpEngineConfig::~BlimpEngineConfig() {} 56 BlimpEngineConfig::~BlimpEngineConfig() {}
35 57
36 // static 58 // static
37 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::Create( 59 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::Create(
38 const base::CommandLine& cmd_line) { 60 const base::CommandLine& cmd_line) {
39 const std::string client_token = GetClientToken(cmd_line); 61 const std::string client_token = GetClientToken(cmd_line);
40 if (!client_token.empty()) { 62 if (!client_token.empty()) {
41 return base::WrapUnique(new BlimpEngineConfig(client_token)); 63 return base::WrapUnique(new BlimpEngineConfig(client_token));
42 } 64 }
43 return nullptr; 65 return nullptr;
44 } 66 }
45 67
46 // static 68 // static
47 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::CreateForTest( 69 std::unique_ptr<BlimpEngineConfig> BlimpEngineConfig::CreateForTest(
48 const std::string& client_token) { 70 const std::string& client_token) {
49 return base::WrapUnique(new BlimpEngineConfig(client_token)); 71 return base::WrapUnique(new BlimpEngineConfig(client_token));
50 } 72 }
51 73
52 const std::string& BlimpEngineConfig::client_token() const { 74 const std::string& BlimpEngineConfig::client_token() const {
53 return client_token_; 75 return client_token_;
54 } 76 }
55 77
56 BlimpEngineConfig::BlimpEngineConfig(const std::string& client_token) 78 BlimpEngineConfig::BlimpEngineConfig(const std::string& client_token)
57 : client_token_(client_token) {} 79 : client_token_(client_token) {}
58 80
59 } // namespace engine 81 } // namespace engine
60 } // namespace blimp 82 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698