Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: chrome/browser/extensions/api/app_window/app_window_api.cc

Issue 343433005: Show error for invalid url in chrome.app.window.create() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 GURL url = GetExtension()->GetResourceURL(params->url); 152 GURL url = GetExtension()->GetResourceURL(params->url);
153 // Allow absolute URLs for component apps, otherwise prepend the extension 153 // Allow absolute URLs for component apps, otherwise prepend the extension
154 // path. 154 // path.
155 if (GetExtension()->location() == extensions::Manifest::COMPONENT) { 155 if (GetExtension()->location() == extensions::Manifest::COMPONENT) {
156 GURL absolute = GURL(params->url); 156 GURL absolute = GURL(params->url);
157 if (absolute.has_scheme()) 157 if (absolute.has_scheme())
158 url = absolute; 158 url = absolute;
159 } 159 }
160 160
161 // Show warning when url passed isn't local
162 if (GURL(params->url).has_scheme()) {
163 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_WARNING,
benwells 2014/06/18 03:22:17 Errors from APIs are generally communicated via ch
Nikhil 2014/06/18 08:52:39 Done.
164 "Url passed as parameter to chrome.app.window.create() "
165 "should be local for security reasons.");
166 }
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?
169 // Limit length of id to 256 characters. 176 // Limit length of id to 256 characters.
170 if (options->id->length() > 256) { 177 if (options->id->length() > 256) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698