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

Side by Side Diff: content/shell/shell_browser_main.cc

Issue 10035034: Implement the skeleton of an android content shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed drawable png as it was checked in separately. Created 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shell_browser_main.h" 5 #include "content/shell/shell_browser_main.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
10 #include "content/public/browser/browser_main_runner.h" 11 #include "content/public/browser/browser_main_runner.h"
11 #include "content/shell/shell.h" 12 #include "content/shell/shell.h"
12 #include "content/shell/shell_browser_context.h" 13 #include "content/shell/shell_browser_context.h"
13 #include "content/shell/shell_content_browser_client.h" 14 #include "content/shell/shell_content_browser_client.h"
14 #include "content/shell/shell_switches.h" 15 #include "content/shell/shell_switches.h"
15 #include "webkit/support/webkit_support.h" 16 #include "webkit/support/webkit_support.h"
16 17
17 namespace { 18 namespace {
18 19
19 GURL GetURLForLayoutTest(const char* test_name) { 20 GURL GetURLForLayoutTest(const char* test_name) {
21 #if defined(OS_ANDROID)
22 // DumpRenderTree is not currently supported for Android using the content
23 // shell.
24 NOTIMPLEMENTED();
25 return GURL::EmptyGURL();
26 #else
20 std::string path_or_url = test_name; 27 std::string path_or_url = test_name;
21 std::string pixel_hash; 28 std::string pixel_hash;
22 std::string timeout; 29 std::string timeout;
23 std::string::size_type separator_position = path_or_url.find(' '); 30 std::string::size_type separator_position = path_or_url.find(' ');
24 if (separator_position != std::string::npos) { 31 if (separator_position != std::string::npos) {
25 timeout = path_or_url.substr(separator_position + 1); 32 timeout = path_or_url.substr(separator_position + 1);
26 path_or_url.erase(separator_position); 33 path_or_url.erase(separator_position);
27 separator_position = path_or_url.find(' '); 34 separator_position = path_or_url.find(' ');
28 if (separator_position != std::string::npos) { 35 if (separator_position != std::string::npos) {
29 pixel_hash = timeout.substr(separator_position + 1); 36 pixel_hash = timeout.substr(separator_position + 1);
30 timeout.erase(separator_position); 37 timeout.erase(separator_position);
31 } 38 }
32 } 39 }
33 // TODO(jochen): use pixel_hash and timeout. 40 // TODO(jochen): use pixel_hash and timeout.
34 GURL test_url = webkit_support::CreateURLForPathOrURL(path_or_url); 41 GURL test_url = webkit_support::CreateURLForPathOrURL(path_or_url);
35 { 42 {
36 // We're outside of the message loop here, and this is a test. 43 // We're outside of the message loop here, and this is a test.
37 base::ThreadRestrictions::ScopedAllowIO allow_io; 44 base::ThreadRestrictions::ScopedAllowIO allow_io;
38 webkit_support::SetCurrentDirectoryForFileURL(test_url); 45 webkit_support::SetCurrentDirectoryForFileURL(test_url);
39 } 46 }
40 return test_url; 47 return test_url;
48 #endif
41 } 49 }
42 50
43 } // namespace 51 } // namespace
44 52
45 // Main routine for running as the Browser process. 53 // Main routine for running as the Browser process.
46 int ShellBrowserMain(const content::MainFunctionParams& parameters) { 54 int ShellBrowserMain(const content::MainFunctionParams& parameters) {
47 scoped_ptr<content::BrowserMainRunner> main_runner_( 55 scoped_ptr<content::BrowserMainRunner> main_runner_(
48 content::BrowserMainRunner::Create()); 56 content::BrowserMainRunner::Create());
49 57
50 int exit_code = main_runner_->Initialize(parameters); 58 int exit_code = main_runner_->Initialize(parameters);
59
60 #if defined(OS_ANDROID)
61 DCHECK(exit_code < 0);
62
63 // Return 0 so that we do NOT trigger the default behavior. On Android, the
64 // UI message loop is managed by the Java application.
65 return 0;
66 #else
51 if (exit_code >= 0) 67 if (exit_code >= 0)
52 return exit_code; 68 return exit_code;
53 69
54 bool layout_test_mode = 70 bool layout_test_mode =
55 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree); 71 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree);
56 72
57 if (layout_test_mode) { 73 if (layout_test_mode) {
58 char test_string[2048]; 74 char test_string[2048];
59 content::ShellBrowserContext* browser_context = 75 content::ShellBrowserContext* browser_context =
60 static_cast<content::ShellContentBrowserClient*>( 76 static_cast<content::ShellContentBrowserClient*>(
(...skipping 17 matching lines...) Expand all
78 content::Shell::CloseAllWindows(); 94 content::Shell::CloseAllWindows();
79 } 95 }
80 exit_code = 0; 96 exit_code = 0;
81 } else { 97 } else {
82 exit_code = main_runner_->Run(); 98 exit_code = main_runner_->Run();
83 } 99 }
84 100
85 main_runner_->Shutdown(); 101 main_runner_->Shutdown();
86 102
87 return exit_code; 103 return exit_code;
104 #endif
88 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698