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 "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/app_window_contents.h" | 8 #include "apps/app_window_contents.h" |
| 9 #include "apps/app_window_registry.h" | 9 #include "apps/app_window_registry.h" |
| 10 #include "apps/apps_client.h" | 10 #include "apps/apps_client.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 "The window id can not be more than 256 characters long."; | 45 "The window id can not be more than 256 characters long."; |
| 46 const char kInvalidColorSpecification[] = | 46 const char kInvalidColorSpecification[] = |
| 47 "The color specification could not be parsed."; | 47 "The color specification could not be parsed."; |
| 48 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; | 48 const char kColorWithFrameNone[] = "Windows with no frame cannot have a color."; |
| 49 const char kInactiveColorWithoutColor[] = | 49 const char kInactiveColorWithoutColor[] = |
| 50 "frame.inactiveColor must be used with frame.color."; | 50 "frame.inactiveColor must be used with frame.color."; |
| 51 const char kConflictingBoundsOptions[] = | 51 const char kConflictingBoundsOptions[] = |
| 52 "The $1 property cannot be specified for both inner and outer bounds."; | 52 "The $1 property cannot be specified for both inner and outer bounds."; |
| 53 const char kAlwaysOnTopPermission[] = | 53 const char kAlwaysOnTopPermission[] = |
| 54 "The \"app.window.alwaysOnTop\" permission is required."; | 54 "The \"app.window.alwaysOnTop\" permission is required."; |
| 55 const char kInvalidUrlParameter[] = | |
| 56 "Url passed should be local for security reasons."; | |
|
benwells
2014/06/19 08:40:32
Nit: please rephrase as "The URL used for window c
Nikhil
2014/06/19 08:55:58
Done.
| |
| 55 } // namespace app_window_constants | 57 } // namespace app_window_constants |
| 56 | 58 |
| 57 const char kNoneFrameOption[] = "none"; | 59 const char kNoneFrameOption[] = "none"; |
| 58 // TODO(benwells): Remove HTML titlebar injection. | 60 // TODO(benwells): Remove HTML titlebar injection. |
| 59 const char kHtmlFrameOption[] = "experimental-html"; | 61 const char kHtmlFrameOption[] = "experimental-html"; |
| 60 | 62 |
| 61 namespace { | 63 namespace { |
| 62 | 64 |
| 63 // Opens an inspector window and delays the response to the | 65 // Opens an inspector window and delays the response to the |
| 64 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is | 66 // AppWindowCreateFunction until the DevToolsWindow has finished loading, and is |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 // Don't create app window if the system is shutting down. | 147 // Don't create app window if the system is shutting down. |
| 146 if (extensions::ExtensionsBrowserClient::Get()->IsShuttingDown()) | 148 if (extensions::ExtensionsBrowserClient::Get()->IsShuttingDown()) |
| 147 return false; | 149 return false; |
| 148 | 150 |
| 149 scoped_ptr<Create::Params> params(Create::Params::Create(*args_)); | 151 scoped_ptr<Create::Params> params(Create::Params::Create(*args_)); |
| 150 EXTENSION_FUNCTION_VALIDATE(params.get()); | 152 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 151 | 153 |
| 152 GURL url = GetExtension()->GetResourceURL(params->url); | 154 GURL url = GetExtension()->GetResourceURL(params->url); |
| 153 // Allow absolute URLs for component apps, otherwise prepend the extension | 155 // Allow absolute URLs for component apps, otherwise prepend the extension |
| 154 // path. | 156 // path. |
| 155 if (GetExtension()->location() == extensions::Manifest::COMPONENT) { | 157 GURL absolute = GURL(params->url); |
| 156 GURL absolute = GURL(params->url); | 158 if (absolute.has_scheme()) { |
| 157 if (absolute.has_scheme()) | 159 if (GetExtension()->location() == extensions::Manifest::COMPONENT) { |
| 158 url = absolute; | 160 url = absolute; |
| 161 } else { | |
| 162 // Show error when url passed isn't local. | |
| 163 error_ = app_window_constants::kInvalidUrlParameter; | |
| 164 return false; | |
| 165 } | |
| 159 } | 166 } |
| 160 | 167 |
| 161 // TODO(jeremya): figure out a way to pass the opening WebContents through to | 168 // TODO(jeremya): figure out a way to pass the opening WebContents through to |
| 162 // AppWindow::Create so we can set the opener at create time rather than | 169 // AppWindow::Create so we can set the opener at create time rather than |
| 163 // with a hack in AppWindowCustomBindings::GetView(). | 170 // with a hack in AppWindowCustomBindings::GetView(). |
| 164 AppWindow::CreateParams create_params; | 171 AppWindow::CreateParams create_params; |
| 165 app_window::CreateWindowOptions* options = params->options.get(); | 172 app_window::CreateWindowOptions* options = params->options.get(); |
| 166 if (options) { | 173 if (options) { |
| 167 if (options->id.get()) { | 174 if (options->id.get()) { |
| 168 // TODO(mek): use URL if no id specified? | 175 // TODO(mek): use URL if no id specified? |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 | 490 |
| 484 if (options.frame->as_frame_options->inactive_color.get()) { | 491 if (options.frame->as_frame_options->inactive_color.get()) { |
| 485 error_ = app_window_constants::kInactiveColorWithoutColor; | 492 error_ = app_window_constants::kInactiveColorWithoutColor; |
| 486 return false; | 493 return false; |
| 487 } | 494 } |
| 488 | 495 |
| 489 return true; | 496 return true; |
| 490 } | 497 } |
| 491 | 498 |
| 492 } // namespace extensions | 499 } // namespace extensions |
| OLD | NEW |