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

Side by Side Diff: apps/shell/app_shell_browser_main_parts.cc

Issue 99053008: Rename apps::AppShell* to apps::Shell* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "apps/shell/app_shell_browser_main_parts.h"
6
7 #include "apps/app_load_service.h"
8 #include "apps/shell/app_shell_browser_context.h"
9 #include "apps/shell/app_shell_extensions_browser_client.h"
10 #include "apps/shell/web_view_window.h"
11 #include "base/command_line.h"
12 #include "base/file_util.h"
13 #include "base/files/file_path.h"
14 #include "base/path_service.h"
15 #include "base/run_loop.h"
16 #include "chrome/common/chrome_paths.h"
17 #include "chromeos/chromeos_paths.h"
18 #include "content/public/common/result_codes.h"
19 #include "extensions/common/extension_paths.h"
20 #include "ui/aura/env.h"
21 #include "ui/aura/root_window.h"
22 #include "ui/aura/test/test_screen.h"
23 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/gfx/screen.h"
25 #include "ui/wm/test/wm_test_helper.h"
26
27 namespace apps {
28
29 AppShellBrowserMainParts::AppShellBrowserMainParts(
30 const content::MainFunctionParams& parameters) {
31 }
32
33 AppShellBrowserMainParts::~AppShellBrowserMainParts() {
34 }
35
36 void AppShellBrowserMainParts::CreateRootWindow() {
37 // TODO(jamescook): Replace this with a real Screen implementation.
38 gfx::Screen::SetScreenInstance(
39 gfx::SCREEN_TYPE_NATIVE, aura::TestScreen::Create());
40 // Set up basic pieces of views::corewm.
41 wm_test_helper_.reset(new wm::WMTestHelper(gfx::Size(800, 600)));
42 // Ensure the X window gets mapped.
43 wm_test_helper_->root_window()->host()->Show();
44 }
45
46 void AppShellBrowserMainParts::LoadAndLaunchApp(const base::FilePath& app_dir) {
47 base::FilePath current_dir;
48 CHECK(file_util::GetCurrentDirectory(&current_dir));
49
50 // HACK: This allows us to see how far we can get without crashing.
51 Profile* profile = reinterpret_cast<Profile*>(browser_context_.get());
52 LOG(WARNING) << "-----------------------------------";
53 LOG(WARNING) << "app_shell is expected to crash now.";
54 LOG(WARNING) << "-----------------------------------";
55
56 apps::AppLoadService* app_load_service =
57 apps::AppLoadService::Get(profile);
58 DCHECK(app_load_service);
59 if (!app_load_service->LoadAndLaunch(
60 app_dir, *CommandLine::ForCurrentProcess(), current_dir)) {
61 LOG(ERROR) << "Unable to launch app at \"" << app_dir.value() << "\"";
62 }
63 }
64
65 void AppShellBrowserMainParts::PreMainMessageLoopStart() {
66 // TODO(jamescook): Initialize touch here?
67 }
68
69 void AppShellBrowserMainParts::PostMainMessageLoopStart() {
70 }
71
72 void AppShellBrowserMainParts::PreEarlyInitialization() {
73 }
74
75 int AppShellBrowserMainParts::PreCreateThreads() {
76 // TODO(jamescook): Initialize chromeos::CrosSettings here?
77
78 // Return no error.
79 return 0;
80 }
81
82 void AppShellBrowserMainParts::PreMainMessageLoopRun() {
83 // NOTE: Much of this is culled from chrome/test/base/chrome_test_suite.cc
84 // Set up all the paths to load files.
85 chrome::RegisterPathProvider();
86 chromeos::RegisterPathProvider();
87 extensions::RegisterPathProvider();
88
89 // The extensions system needs manifest data from the Chrome PAK file.
90 base::FilePath resources_pack_path;
91 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
92 ResourceBundle::GetSharedInstance().AddDataPackFromPath(
93 resources_pack_path, ui::SCALE_FACTOR_NONE);
94
95 // TODO(jamescook): Initialize chromeos::UserManager.
96
97 // Initialize our "profile" equivalent.
98 browser_context_.reset(new AppShellBrowserContext);
99
100 // TODO(jamescook): Initialize ExtensionsClient.
101 extensions_browser_client_.reset(
102 new AppShellExtensionsBrowserClient(browser_context_.get()));
103 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
104
105 // TODO(jamescook): Initialize policy::ProfilePolicyConnector.
106 // TODO(jamescook): Initialize ExtensionSystem and InitForRegularProfile.
107 // TODO(jamescook): CreateBrowserContextServices using
108 // BrowserContextDependencyManager.
109
110 CreateRootWindow();
111
112 const std::string kAppSwitch = "app";
113 CommandLine* command_line = CommandLine::ForCurrentProcess();
114 if (command_line->HasSwitch(kAppSwitch)) {
115 base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch));
116 LoadAndLaunchApp(app_dir);
117 } else {
118 // TODO(jamescook): Create an apps::ShellWindow here. For now, create a
119 // window with a WebView just to ensure that the content module is properly
120 // initialized.
121 ShowWebViewWindow(browser_context_.get(),
122 wm_test_helper_->root_window()->window());
123 }
124 }
125
126 bool AppShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
127 base::RunLoop run_loop;
128 run_loop.Run();
129 *result_code = content::RESULT_CODE_NORMAL_EXIT;
130 return true;
131 }
132
133 void AppShellBrowserMainParts::PostMainMessageLoopRun() {
134 extensions::ExtensionsBrowserClient::Set(NULL);
135 extensions_browser_client_.reset();
136 browser_context_.reset();
137 wm_test_helper_.reset();
138 aura::Env::DeleteInstance();
139 }
140
141 } // namespace apps
OLDNEW
« no previous file with comments | « apps/shell/app_shell_browser_main_parts.h ('k') | apps/shell/app_shell_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698