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

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

Powered by Google App Engine
This is Rietveld 408576698