| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/app_window/app_web_contents_helper.h" | 5 #include "extensions/browser/app_window/app_web_contents_helper.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "content/public/browser/native_web_keyboard_event.h" | 8 #include "content/public/browser/native_web_keyboard_event.h" |
| 9 #include "content/public/browser/page_navigator.h" | 9 #include "content/public/browser/page_navigator.h" |
| 10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // now we can't distinguish between those and <meta> refreshes or window.href | 44 // now we can't distinguish between those and <meta> refreshes or window.href |
| 45 // navigations, which we don't want to allow. | 45 // navigations, which we don't want to allow. |
| 46 // TOOD(mihaip): Can we check for user gestures instead? | 46 // TOOD(mihaip): Can we check for user gestures instead? |
| 47 WindowOpenDisposition disposition = params.disposition; | 47 WindowOpenDisposition disposition = params.disposition; |
| 48 if (disposition == CURRENT_TAB) { | 48 if (disposition == CURRENT_TAB) { |
| 49 AddMessageToDevToolsConsole( | 49 AddMessageToDevToolsConsole( |
| 50 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 50 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
| 51 base::StringPrintf( | 51 base::StringPrintf( |
| 52 "Can't open same-window link to \"%s\"; try target=\"_blank\".", | 52 "Can't open same-window link to \"%s\"; try target=\"_blank\".", |
| 53 params.url.spec().c_str())); | 53 params.url.spec().c_str())); |
| 54 return NULL; | 54 return nullptr; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // These dispositions aren't really navigations. | 57 // These dispositions aren't really navigations. |
| 58 if (disposition == SUPPRESS_OPEN || disposition == SAVE_TO_DISK || | 58 if (disposition == SUPPRESS_OPEN || disposition == SAVE_TO_DISK || |
| 59 disposition == IGNORE_ACTION) { | 59 disposition == IGNORE_ACTION) { |
| 60 return NULL; | 60 return nullptr; |
| 61 } | 61 } |
| 62 | 62 |
| 63 content::WebContents* contents = | 63 content::WebContents* contents = |
| 64 app_delegate_->OpenURLFromTab(browser_context_, web_contents_, params); | 64 app_delegate_->OpenURLFromTab(browser_context_, web_contents_, params); |
| 65 if (!contents) { | 65 if (!contents) { |
| 66 AddMessageToDevToolsConsole( | 66 AddMessageToDevToolsConsole( |
| 67 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 67 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
| 68 base::StringPrintf( | 68 base::StringPrintf( |
| 69 "Can't navigate to \"%s\"; apps do not support navigation.", | 69 "Can't navigate to \"%s\"; apps do not support navigation.", |
| 70 params.url.spec().c_str())); | 70 params.url.spec().c_str())); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 void AppWebContentsHelper::AddMessageToDevToolsConsole( | 117 void AppWebContentsHelper::AddMessageToDevToolsConsole( |
| 118 content::ConsoleMessageLevel level, | 118 content::ConsoleMessageLevel level, |
| 119 const std::string& message) const { | 119 const std::string& message) const { |
| 120 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 120 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
| 121 rvh->Send(new ExtensionMsg_AddMessageToConsole( | 121 rvh->Send(new ExtensionMsg_AddMessageToConsole( |
| 122 rvh->GetRoutingID(), level, message)); | 122 rvh->GetRoutingID(), level, message)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace extensions | 125 } // namespace extensions |
| OLD | NEW |