Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/shell/browser/shell_browser_main_parts.h" | 5 #include "content/shell/browser/shell_browser_main_parts.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 13 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 14 #include "components/devtools_http_handler/devtools_http_handler.h" | 15 #include "components/devtools_http_handler/devtools_http_handler.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/storage_partition.h" | 17 #include "content/public/browser/storage_partition.h" |
| 17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/common/main_function_params.h" | 19 #include "content/public/common/main_function_params.h" |
| 19 #include "content/public/common/url_constants.h" | 20 #include "content/public/common/url_constants.h" |
| 20 #include "content/shell/browser/layout_test/layout_test_browser_context.h" | 21 #include "content/shell/browser/layout_test/layout_test_browser_context.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 return GURL(); | 58 return GURL(); |
| 58 #endif | 59 #endif |
| 59 | 60 |
| 60 if (args.empty()) | 61 if (args.empty()) |
| 61 return GURL("https://www.google.com/"); | 62 return GURL("https://www.google.com/"); |
| 62 | 63 |
| 63 GURL url(args[0]); | 64 GURL url(args[0]); |
| 64 if (url.is_valid() && url.has_scheme()) | 65 if (url.is_valid() && url.has_scheme()) |
| 65 return url; | 66 return url; |
| 66 | 67 |
| 67 return net::FilePathToFileURL(base::FilePath(args[0])); | 68 return net::FilePathToFileURL( |
| 69 base::MakeAbsoluteFilePath(base::FilePath(args[0]))); | |
| 68 } | 70 } |
| 69 | 71 |
| 70 base::StringPiece PlatformResourceProvider(int key) { | 72 base::StringPiece PlatformResourceProvider(int key) { |
| 71 if (key == IDR_DIR_HEADER_HTML) { | 73 if (key == IDR_DIR_HEADER_HTML) { |
| 72 base::StringPiece html_data = | 74 base::StringPiece html_data = |
| 73 ui::ResourceBundle::GetSharedInstance().GetRawDataResource( | 75 ui::ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 74 IDR_DIR_HEADER_HTML); | 76 IDR_DIR_HEADER_HTML); |
| 75 return html_data; | 77 return html_data; |
| 76 } | 78 } |
| 77 return base::StringPiece(); | 79 return base::StringPiece(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 } | 117 } |
| 116 | 118 |
| 117 void ShellBrowserMainParts::InitializeBrowserContexts() { | 119 void ShellBrowserMainParts::InitializeBrowserContexts() { |
| 118 set_browser_context(new ShellBrowserContext(false, net_log_.get())); | 120 set_browser_context(new ShellBrowserContext(false, net_log_.get())); |
| 119 set_off_the_record_browser_context( | 121 set_off_the_record_browser_context( |
| 120 new ShellBrowserContext(true, net_log_.get())); | 122 new ShellBrowserContext(true, net_log_.get())); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void ShellBrowserMainParts::InitializeMessageLoopContext() { | 125 void ShellBrowserMainParts::InitializeMessageLoopContext() { |
| 124 Shell::CreateNewWindow(browser_context_.get(), | 126 Shell::CreateNewWindow(browser_context_.get(), |
| 125 GetStartupURL(), | 127 GetStartupURL(), |
|
Peter Kasting
2015/04/22 22:40:04
For maximum safety, can you also modify Shell::Cre
| |
| 126 NULL, | 128 NULL, |
| 127 gfx::Size()); | 129 gfx::Size()); |
| 128 } | 130 } |
| 129 | 131 |
| 130 void ShellBrowserMainParts::PreMainMessageLoopRun() { | 132 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
| 131 #if defined(OS_ANDROID) | 133 #if defined(OS_ANDROID) |
| 132 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 134 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 133 switches::kEnableCrashReporter)) { | 135 switches::kEnableCrashReporter)) { |
| 134 base::FilePath crash_dumps_dir = | 136 base::FilePath crash_dumps_dir = |
| 135 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 137 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 159 return !run_message_loop_; | 161 return !run_message_loop_; |
| 160 } | 162 } |
| 161 | 163 |
| 162 void ShellBrowserMainParts::PostMainMessageLoopRun() { | 164 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
| 163 devtools_http_handler_.reset(); | 165 devtools_http_handler_.reset(); |
| 164 browser_context_.reset(); | 166 browser_context_.reset(); |
| 165 off_the_record_browser_context_.reset(); | 167 off_the_record_browser_context_.reset(); |
| 166 } | 168 } |
| 167 | 169 |
| 168 } // namespace | 170 } // namespace |
| OLD | NEW |