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 "extensions/shell/browser/api/shell/shell_api.h" | 5 #include "extensions/shell/browser/api/shell/shell_api.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "extensions/common/extension.h" | 9 #include "extensions/common/extension.h" |
| 10 #include "extensions/shell/browser/desktop_controller.h" |
10 #include "extensions/shell/browser/shell_app_window.h" | 11 #include "extensions/shell/browser/shell_app_window.h" |
11 #include "extensions/shell/browser/shell_desktop_controller.h" | |
12 #include "extensions/shell/common/api/shell.h" | 12 #include "extensions/shell/common/api/shell.h" |
13 | 13 |
14 using base::DictionaryValue; | 14 using base::DictionaryValue; |
15 | 15 |
16 namespace CreateWindow = extensions::shell_api::shell::CreateWindow; | 16 namespace CreateWindow = extensions::shell_api::shell::CreateWindow; |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
(...skipping 19 matching lines...) Expand all Loading... |
41 ExtensionFunction::ResponseAction ShellCreateWindowFunction::Run() { | 41 ExtensionFunction::ResponseAction ShellCreateWindowFunction::Run() { |
42 scoped_ptr<CreateWindow::Params> params(CreateWindow::Params::Create(*args_)); | 42 scoped_ptr<CreateWindow::Params> params(CreateWindow::Params::Create(*args_)); |
43 EXTENSION_FUNCTION_VALIDATE(params.get()); | 43 EXTENSION_FUNCTION_VALIDATE(params.get()); |
44 | 44 |
45 // Convert "main.html" to "chrome-extension:/<id>/main.html". | 45 // Convert "main.html" to "chrome-extension:/<id>/main.html". |
46 GURL url = extension()->GetResourceURL(params->url); | 46 GURL url = extension()->GetResourceURL(params->url); |
47 if (!url.is_valid()) | 47 if (!url.is_valid()) |
48 return RespondNow(Error(kInvalidArguments)); | 48 return RespondNow(Error(kInvalidArguments)); |
49 | 49 |
50 // The desktop keeps ownership of the window. | 50 // The desktop keeps ownership of the window. |
51 ShellAppWindow* app_window = | 51 ShellAppWindow* app_window = DesktopController::instance()->CreateAppWindow( |
52 ShellDesktopController::instance()->CreateAppWindow(browser_context(), | 52 browser_context(), extension()); |
53 extension()); | |
54 app_window->LoadURL(url); | 53 app_window->LoadURL(url); |
55 | 54 |
56 // Create the reply to send to the renderer. | 55 // Create the reply to send to the renderer. |
57 return RespondNow(OneArgument(CreateResult(app_window))); | 56 return RespondNow(OneArgument(CreateResult(app_window))); |
58 } | 57 } |
59 | 58 |
60 } // namespace extensions | 59 } // namespace extensions |
OLD | NEW |