OLD | NEW |
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 "chrome/browser/extensions/api/app_window/app_window_api.h" | 5 #include "chrome/browser/extensions/api/app_window/app_window_api.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_window_controller.h" | 9 #include "chrome/browser/extensions/extension_window_controller.h" |
10 #include "chrome/browser/extensions/extension_window_list.h" | 10 #include "chrome/browser/extensions/extension_window_list.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 bool AppWindowCreateFunction::RunImpl() { | 24 bool AppWindowCreateFunction::RunImpl() { |
25 scoped_ptr<Create::Params> params(Create::Params::Create(*args_)); | 25 scoped_ptr<Create::Params> params(Create::Params::Create(*args_)); |
26 EXTENSION_FUNCTION_VALIDATE(params.get()); | 26 EXTENSION_FUNCTION_VALIDATE(params.get()); |
27 | 27 |
28 GURL url = GetExtension()->GetResourceURL(params->url); | 28 GURL url = GetExtension()->GetResourceURL(params->url); |
29 | 29 |
30 // TODO(jeremya): figure out a way to pass the opening WebContents through to | 30 // TODO(jeremya): figure out a way to pass the opening WebContents through to |
31 // ShellWindow::Create so we can set the opener at create time rather than | 31 // ShellWindow::Create so we can set the opener at create time rather than |
32 // with a hack in AppWindowCustomBindings::GetView(). | 32 // with a hack in AppWindowCustomBindings::GetView(). |
33 ShellWindow::CreateParams create_params; | 33 ShellWindow::CreateParams create_params; |
34 if (params->options.width.get()) | 34 app_window::CreateWindowOptions* options = params->options.get(); |
35 create_params.bounds.set_width(*params->options.width.get()); | 35 if (options) { |
36 if (params->options.height.get()) | 36 if (options->width.get()) |
37 create_params.bounds.set_height(*params->options.height.get()); | 37 create_params.bounds.set_width(*options->width.get()); |
38 if (params->options.left.get()) | 38 if (options->height.get()) |
39 create_params.bounds.set_x(*params->options.left.get()); | 39 create_params.bounds.set_height(*options->height.get()); |
40 if (params->options.top.get()) | 40 if (options->left.get()) |
41 create_params.bounds.set_y(*params->options.top.get()); | 41 create_params.bounds.set_x(*options->left.get()); |
| 42 if (options->top.get()) |
| 43 create_params.bounds.set_y(*options->top.get()); |
| 44 } |
42 ShellWindow* shell_window = | 45 ShellWindow* shell_window = |
43 ShellWindow::Create(profile(), GetExtension(), url, create_params); | 46 ShellWindow::Create(profile(), GetExtension(), url, create_params); |
44 shell_window->Show(); | 47 shell_window->Show(); |
45 | 48 |
46 content::WebContents* created_contents = shell_window->web_contents(); | 49 content::WebContents* created_contents = shell_window->web_contents(); |
47 int view_id = created_contents->GetRenderViewHost()->GetRoutingID(); | 50 int view_id = created_contents->GetRenderViewHost()->GetRoutingID(); |
48 | 51 |
49 result_.reset(base::Value::CreateIntegerValue(view_id)); | 52 result_.reset(base::Value::CreateIntegerValue(view_id)); |
50 return true; | 53 return true; |
51 } | 54 } |
52 | 55 |
53 } // namespace extensions | 56 } // namespace extensions |
OLD | NEW |