OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_app_window_api.h" | 5 #include "apps/shell/browser/shell_app_window_api.h" |
6 | 6 |
7 #include "apps/shell/browser/shell_app_window.h" | 7 #include "apps/shell/browser/shell_app_window.h" |
8 #include "apps/shell/browser/shell_desktop_controller.h" | 8 #include "apps/shell/browser/shell_desktop_controller.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 return result; | 45 return result; |
46 } | 46 } |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 ShellAppWindowCreateFunction::ShellAppWindowCreateFunction() {} | 50 ShellAppWindowCreateFunction::ShellAppWindowCreateFunction() {} |
51 | 51 |
52 ShellAppWindowCreateFunction::~ShellAppWindowCreateFunction() {} | 52 ShellAppWindowCreateFunction::~ShellAppWindowCreateFunction() {} |
53 | 53 |
54 bool ShellAppWindowCreateFunction::RunImpl() { | 54 bool ShellAppWindowCreateFunction::RunAsync() { |
55 // Arguments must contain a URL and may contain options and a callback. | 55 // Arguments must contain a URL and may contain options and a callback. |
56 if (args_->GetSize() < 1 || args_->GetSize() > 3) | 56 if (args_->GetSize() < 1 || args_->GetSize() > 3) |
57 return false; | 57 return false; |
58 | 58 |
59 // Extract the URL for the window contents, e.g. "main.html". | 59 // Extract the URL for the window contents, e.g. "main.html". |
60 std::string url_string; | 60 std::string url_string; |
61 if (!args_->GetString(0, &url_string)) | 61 if (!args_->GetString(0, &url_string)) |
62 return false; | 62 return false; |
63 | 63 |
64 // Convert "main.html" to "chrome-extension:/<id>/main.html". | 64 // Convert "main.html" to "chrome-extension:/<id>/main.html". |
65 GURL url = GetExtension()->GetResourceURL(url_string); | 65 GURL url = GetExtension()->GetResourceURL(url_string); |
66 if (!url.is_valid()) | 66 if (!url.is_valid()) |
67 return false; | 67 return false; |
68 | 68 |
69 // The desktop keeps ownership of the window. | 69 // The desktop keeps ownership of the window. |
70 apps::ShellAppWindow* app_window = | 70 apps::ShellAppWindow* app_window = |
71 apps::ShellDesktopController::instance()->CreateAppWindow( | 71 apps::ShellDesktopController::instance()->CreateAppWindow( |
72 browser_context()); | 72 browser_context()); |
73 app_window->LoadURL(url); | 73 app_window->LoadURL(url); |
74 | 74 |
75 // Create the reply to send to the renderer. | 75 // Create the reply to send to the renderer. |
76 DictionaryValue* result = CreateResult(app_window); | 76 DictionaryValue* result = CreateResult(app_window); |
77 SetResult(result); | 77 SetResult(result); |
78 | 78 |
79 SendResponse(true /* success */); | 79 SendResponse(true /* success */); |
80 return true; | 80 return true; |
81 } | 81 } |
82 | 82 |
83 } // namespace extensions | 83 } // namespace extensions |
OLD | NEW |