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

Side by Side Diff: apps/shell/browser/shell_browser_main_parts.cc

Issue 224723022: Add the first app_shell_browsertest test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "apps/shell/browser/shell_browser_main_parts.h" 5 #include "apps/shell/browser/shell_browser_main_parts.h"
6 6
7 #include "apps/shell/browser/shell_browser_context.h" 7 #include "apps/shell/browser/shell_browser_context.h"
8 #include "apps/shell/browser/shell_desktop_controller.h" 8 #include "apps/shell/browser/shell_desktop_controller.h"
9 #include "apps/shell/browser/shell_extension_system.h" 9 #include "apps/shell/browser/shell_extension_system.h"
10 #include "apps/shell/browser/shell_extension_system_factory.h" 10 #include "apps/shell/browser/shell_extension_system_factory.h"
(...skipping 25 matching lines...) Expand all
36 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt(); 36 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
37 extensions::ShellExtensionSystemFactory::GetInstance(); 37 extensions::ShellExtensionSystemFactory::GetInstance();
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 namespace apps { 42 namespace apps {
43 43
44 ShellBrowserMainParts::ShellBrowserMainParts( 44 ShellBrowserMainParts::ShellBrowserMainParts(
45 const content::MainFunctionParams& parameters) 45 const content::MainFunctionParams& parameters)
46 : extension_system_(NULL), parameters_(parameters) {} 46 : extension_system_(NULL),
47 parameters_(parameters),
48 run_message_loop_(true) {}
47 49
48 ShellBrowserMainParts::~ShellBrowserMainParts() { 50 ShellBrowserMainParts::~ShellBrowserMainParts() {
49 } 51 }
50 52
51 void ShellBrowserMainParts::PreMainMessageLoopStart() { 53 void ShellBrowserMainParts::PreMainMessageLoopStart() {
52 // TODO(jamescook): Initialize touch here? 54 // TODO(jamescook): Initialize touch here?
53 } 55 }
54 56
55 void ShellBrowserMainParts::PostMainMessageLoopStart() { 57 void ShellBrowserMainParts::PostMainMessageLoopStart() {
56 } 58 }
57 59
58 void ShellBrowserMainParts::PreEarlyInitialization() { 60 void ShellBrowserMainParts::PreEarlyInitialization() {
59 } 61 }
60 62
61 int ShellBrowserMainParts::PreCreateThreads() { 63 int ShellBrowserMainParts::PreCreateThreads() {
62 // TODO(jamescook): Initialize chromeos::CrosSettings here? 64 // TODO(jamescook): Initialize chromeos::CrosSettings here?
63 65
64 // Return no error. 66 // Return no error.
65 return 0; 67 return 0;
66 } 68 }
67 69
68 void ShellBrowserMainParts::PreMainMessageLoopRun() { 70 void ShellBrowserMainParts::PreMainMessageLoopRun() {
71 // Initialize our "profile" equivalent.
72 browser_context_.reset(new ShellBrowserContext);
73
69 desktop_controller_.reset(new ShellDesktopController); 74 desktop_controller_.reset(new ShellDesktopController);
70 desktop_controller_->GetWindowTreeHost()->AddObserver(this); 75 desktop_controller_->GetWindowTreeHost()->AddObserver(this);
71 76
72 // NOTE: Much of this is culled from chrome/test/base/chrome_test_suite.cc 77 // NOTE: Much of this is culled from chrome/test/base/chrome_test_suite.cc
73 // TODO(jamescook): Initialize chromeos::UserManager. 78 // TODO(jamescook): Initialize chromeos::UserManager.
74 net_log_.reset(new content::ShellNetLog("app_shell")); 79 net_log_.reset(new content::ShellNetLog("app_shell"));
75 80
76 // Initialize our "profile" equivalent.
77 browser_context_.reset(new ShellBrowserContext);
78
79 extensions_client_.reset(new ShellExtensionsClient()); 81 extensions_client_.reset(new ShellExtensionsClient());
80 extensions::ExtensionsClient::Set(extensions_client_.get()); 82 extensions::ExtensionsClient::Set(extensions_client_.get());
81 83
82 extensions_browser_client_.reset( 84 extensions_browser_client_.reset(
83 new extensions::ShellExtensionsBrowserClient(browser_context_.get())); 85 new extensions::ShellExtensionsBrowserClient(browser_context_.get()));
84 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); 86 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
85 87
86 // Create our custom ExtensionSystem first because other 88 // Create our custom ExtensionSystem first because other
87 // KeyedServices depend on it. 89 // KeyedServices depend on it.
88 // TODO(yoz): Move this after EnsureBrowserContextKeyedServiceFactoriesBuilt. 90 // TODO(yoz): Move this after EnsureBrowserContextKeyedServiceFactoriesBuilt.
89 CreateExtensionSystem(); 91 CreateExtensionSystem();
90 92
91 ::EnsureBrowserContextKeyedServiceFactoriesBuilt(); 93 ::EnsureBrowserContextKeyedServiceFactoriesBuilt();
92 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( 94 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices(
93 browser_context_.get()); 95 browser_context_.get());
94 96
95 devtools_delegate_.reset( 97 devtools_delegate_.reset(
96 new content::ShellDevToolsDelegate(browser_context_.get())); 98 new content::ShellDevToolsDelegate(browser_context_.get()));
97 99
98 // For running browser tests.
99 // TODO(yoz): This is set up to exit prematurely because we don't have
100 // any tests yet.
101 if (parameters_.ui_task) {
102 parameters_.ui_task->Run();
103 delete parameters_.ui_task;
104 return;
105 }
106
107 const std::string kAppSwitch = "app"; 100 const std::string kAppSwitch = "app";
108 CommandLine* command_line = CommandLine::ForCurrentProcess(); 101 CommandLine* command_line = CommandLine::ForCurrentProcess();
109 if (command_line->HasSwitch(kAppSwitch)) { 102 if (command_line->HasSwitch(kAppSwitch)) {
110 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch)); 103 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch));
111 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir); 104 base::FilePath app_absolute_dir = base::MakeAbsoluteFilePath(app_dir);
112 extension_system_->LoadAndLaunchApp(app_absolute_dir); 105 extension_system_->LoadAndLaunchApp(app_absolute_dir);
106 } else if (parameters_.ui_task) {
107 // For running browser tests.
108 parameters_.ui_task->Run();
109 delete parameters_.ui_task;
110 run_message_loop_ = false;
113 } else { 111 } else {
114 LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future"; 112 LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future";
115 } 113 }
116 } 114 }
117 115
118 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { 116 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
117 if (!run_message_loop_)
118 return true;
119 // TODO(yoz): just return false here?
119 base::RunLoop run_loop; 120 base::RunLoop run_loop;
120 run_loop.Run(); 121 run_loop.Run();
121 *result_code = content::RESULT_CODE_NORMAL_EXIT; 122 *result_code = content::RESULT_CODE_NORMAL_EXIT;
122 return true; 123 return true;
123 } 124 }
124 125
125 void ShellBrowserMainParts::PostMainMessageLoopRun() { 126 void ShellBrowserMainParts::PostMainMessageLoopRun() {
126 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( 127 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
127 browser_context_.get()); 128 browser_context_.get());
128 extension_system_ = NULL; 129 extension_system_ = NULL;
(...skipping 13 matching lines...) Expand all
142 } 143 }
143 144
144 void ShellBrowserMainParts::CreateExtensionSystem() { 145 void ShellBrowserMainParts::CreateExtensionSystem() {
145 DCHECK(browser_context_); 146 DCHECK(browser_context_);
146 extension_system_ = static_cast<ShellExtensionSystem*>( 147 extension_system_ = static_cast<ShellExtensionSystem*>(
147 ExtensionSystem::Get(browser_context_.get())); 148 ExtensionSystem::Get(browser_context_.get()));
148 extension_system_->InitForRegularProfile(true); 149 extension_system_->InitForRegularProfile(true);
149 } 150 }
150 151
151 } // namespace apps 152 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698