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."; | |
| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 if (GetExtension()->location() == extensions::Manifest::COMPONENT) { |
| 156 GURL absolute = GURL(params->url); | 158 GURL absolute = GURL(params->url); |
| 157 if (absolute.has_scheme()) | 159 if (absolute.has_scheme()) |
| 158 url = absolute; | 160 url = absolute; |
| 159 } | 161 } |
| 160 | 162 |
| 163 // Show error when url passed isn't local | |
| 164 if (GURL(params->url).has_scheme()) { | |
|
benwells
2014/06/18 22:53:37
Looking 10 lines or so up, this is considered fine
Nikhil
2014/06/19 08:26:28
Done.
| |
| 165 error_ = app_window_constants::kInvalidUrlParameter; | |
| 166 return false; | |
| 167 } | |
| 168 | |
| 161 // TODO(jeremya): figure out a way to pass the opening WebContents through to | 169 // 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 | 170 // AppWindow::Create so we can set the opener at create time rather than |
| 163 // with a hack in AppWindowCustomBindings::GetView(). | 171 // with a hack in AppWindowCustomBindings::GetView(). |
| 164 AppWindow::CreateParams create_params; | 172 AppWindow::CreateParams create_params; |
| 165 app_window::CreateWindowOptions* options = params->options.get(); | 173 app_window::CreateWindowOptions* options = params->options.get(); |
| 166 if (options) { | 174 if (options) { |
| 167 if (options->id.get()) { | 175 if (options->id.get()) { |
| 168 // TODO(mek): use URL if no id specified? | 176 // TODO(mek): use URL if no id specified? |
| 169 // Limit length of id to 256 characters. | 177 // Limit length of id to 256 characters. |
| 170 if (options->id->length() > 256) { | 178 if (options->id->length() > 256) { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 | 491 |
| 484 if (options.frame->as_frame_options->inactive_color.get()) { | 492 if (options.frame->as_frame_options->inactive_color.get()) { |
| 485 error_ = app_window_constants::kInactiveColorWithoutColor; | 493 error_ = app_window_constants::kInactiveColorWithoutColor; |
| 486 return false; | 494 return false; |
| 487 } | 495 } |
| 488 | 496 |
| 489 return true; | 497 return true; |
| 490 } | 498 } |
| 491 | 499 |
| 492 } // namespace extensions | 500 } // namespace extensions |
| OLD | NEW |