| 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_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 | 39 |
| 40 content::WebContents* AppWebContentsHelper::OpenURLFromTab( | 40 content::WebContents* AppWebContentsHelper::OpenURLFromTab( |
| 41 const content::OpenURLParams& params) const { | 41 const content::OpenURLParams& params) const { |
| 42 // Don't allow the current tab to be navigated. It would be nice to map all | 42 // Don't allow the current tab to be navigated. It would be nice to map all |
| 43 // anchor tags (even those without target="_blank") to new tabs, but right | 43 // anchor tags (even those without target="_blank") to new tabs, but right |
| 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 == WindowOpenDisposition::CURRENT_TAB) { |
| 49 web_contents_->GetMainFrame()->AddMessageToConsole( | 49 web_contents_->GetMainFrame()->AddMessageToConsole( |
| 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 NULL; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // These dispositions aren't really navigations. | 57 // These dispositions aren't really navigations. |
| 58 if (disposition == SAVE_TO_DISK || disposition == IGNORE_ACTION) | 58 if (disposition == WindowOpenDisposition::SAVE_TO_DISK || |
| 59 disposition == WindowOpenDisposition::IGNORE_ACTION) |
| 59 return NULL; | 60 return NULL; |
| 60 | 61 |
| 61 content::WebContents* contents = | 62 content::WebContents* contents = |
| 62 app_delegate_->OpenURLFromTab(browser_context_, web_contents_, params); | 63 app_delegate_->OpenURLFromTab(browser_context_, web_contents_, params); |
| 63 if (!contents) { | 64 if (!contents) { |
| 64 web_contents_->GetMainFrame()->AddMessageToConsole( | 65 web_contents_->GetMainFrame()->AddMessageToConsole( |
| 65 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 66 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
| 66 base::StringPrintf( | 67 base::StringPrintf( |
| 67 "Can't navigate to \"%s\"; apps do not support navigation.", | 68 "Can't navigate to \"%s\"; apps do not support navigation.", |
| 68 params.url.spec().c_str())); | 69 params.url.spec().c_str())); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 web_contents_, security_origin, type, extension); | 105 web_contents_, security_origin, type, extension); |
| 105 } | 106 } |
| 106 | 107 |
| 107 const Extension* AppWebContentsHelper::GetExtension() const { | 108 const Extension* AppWebContentsHelper::GetExtension() const { |
| 108 return ExtensionRegistry::Get(browser_context_) | 109 return ExtensionRegistry::Get(browser_context_) |
| 109 ->enabled_extensions() | 110 ->enabled_extensions() |
| 110 .GetByID(extension_id_); | 111 .GetByID(extension_id_); |
| 111 } | 112 } |
| 112 | 113 |
| 113 } // namespace extensions | 114 } // namespace extensions |
| OLD | NEW |