Chromium Code Reviews| 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/shell_window_registry.h" | 9 #include "chrome/browser/extensions/shell_window_registry.h" |
| 10 #include "chrome/browser/extensions/window_controller.h" | 10 #include "chrome/browser/extensions/window_controller.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 EXTENSION_FUNCTION_VALIDATE(params.get()); | 51 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 52 | 52 |
| 53 GURL url = GetExtension()->GetResourceURL(params->url); | 53 GURL url = GetExtension()->GetResourceURL(params->url); |
| 54 | 54 |
| 55 // TODO(jeremya): figure out a way to pass the opening WebContents through to | 55 // TODO(jeremya): figure out a way to pass the opening WebContents through to |
| 56 // ShellWindow::Create so we can set the opener at create time rather than | 56 // ShellWindow::Create so we can set the opener at create time rather than |
| 57 // with a hack in AppWindowCustomBindings::GetView(). | 57 // with a hack in AppWindowCustomBindings::GetView(). |
| 58 ShellWindow::CreateParams create_params; | 58 ShellWindow::CreateParams create_params; |
| 59 app_window::CreateWindowOptions* options = params->options.get(); | 59 app_window::CreateWindowOptions* options = params->options.get(); |
| 60 if (options) { | 60 if (options) { |
| 61 if (options->width.get()) | 61 if (options->id.get()) { |
| 62 create_params.bounds.set_width(*options->width.get()); | 62 // TODO(mek): use URL if no id specified? |
| 63 if (options->height.get()) | 63 // Limit length of id to 256 characters. |
| 64 create_params.bounds.set_height(*options->height.get()); | 64 if (options->id->length() > 256) |
| 65 if (options->left.get()) | 65 create_params.window_key = options->id->substr(0, 256); |
|
asargent_no_longer_on_chrome
2012/08/29 19:54:18
Instead of silently truncating, let's instead retu
| |
| 66 create_params.bounds.set_x(*options->left.get()); | 66 else |
| 67 if (options->top.get()) | 67 create_params.window_key = *options->id; |
| 68 create_params.bounds.set_y(*options->top.get()); | 68 } |
| 69 | |
| 70 if (options->default_width.get()) | |
| 71 create_params.bounds.set_width(*options->default_width.get()); | |
| 72 if (options->default_height.get()) | |
| 73 create_params.bounds.set_height(*options->default_height.get()); | |
| 74 if (options->default_left.get()) | |
| 75 create_params.bounds.set_x(*options->default_left.get()); | |
| 76 if (options->default_top.get()) | |
| 77 create_params.bounds.set_y(*options->default_top.get()); | |
| 78 | |
| 79 | |
| 80 if (options->width.get() || options->height.get()) { | |
| 81 if (options->width.get()) | |
| 82 create_params.bounds.set_width(*options->width.get()); | |
| 83 if (options->height.get()) | |
| 84 create_params.bounds.set_height(*options->height.get()); | |
| 85 create_params.restoreSize = false; | |
| 86 } | |
| 87 | |
| 88 if (options->left.get() || options->top.get()) { | |
| 89 if (options->left.get()) | |
| 90 create_params.bounds.set_x(*options->left.get()); | |
| 91 if (options->top.get()) | |
| 92 create_params.bounds.set_y(*options->top.get()); | |
| 93 create_params.restorePosition = false; | |
| 94 } | |
| 69 | 95 |
| 70 if (options->frame.get()) { | 96 if (options->frame.get()) { |
| 71 create_params.frame = *options->frame == kNoneFrameOption ? | 97 create_params.frame = *options->frame == kNoneFrameOption ? |
| 72 ShellWindow::CreateParams::FRAME_NONE : | 98 ShellWindow::CreateParams::FRAME_NONE : |
| 73 ShellWindow::CreateParams::FRAME_CHROME; | 99 ShellWindow::CreateParams::FRAME_CHROME; |
| 74 } | 100 } |
| 75 | 101 |
| 76 gfx::Size& minimum_size = create_params.minimum_size; | 102 gfx::Size& minimum_size = create_params.minimum_size; |
| 77 if (options->min_width.get()) | 103 if (options->min_width.get()) |
| 78 minimum_size.set_width(*options->min_width); | 104 minimum_size.set_width(*options->min_width); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 window->GetBaseWindow()->Minimize(); | 153 window->GetBaseWindow()->Minimize(); |
| 128 return true; | 154 return true; |
| 129 } | 155 } |
| 130 | 156 |
| 131 bool AppWindowRestoreFunction::RunWithWindow(ShellWindow* window) { | 157 bool AppWindowRestoreFunction::RunWithWindow(ShellWindow* window) { |
| 132 window->GetBaseWindow()->Restore(); | 158 window->GetBaseWindow()->Restore(); |
| 133 return true; | 159 return true; |
| 134 } | 160 } |
| 135 | 161 |
| 136 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |