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

Unified Diff: chrome/browser/ui/panels/panel_host.cc

Issue 10831299: Allow links in refactored panels to open in a tab (like current panel behavior). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/panel_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_host.cc
diff --git a/chrome/browser/ui/panels/panel_host.cc b/chrome/browser/ui/panels/panel_host.cc
index a01870a80294d31017e929d4b576b8ad9a72c0f2..e0a78fadec3e37eac748c1448bc154ed61382ec0 100644
--- a/chrome/browser/ui/panels/panel_host.cc
+++ b/chrome/browser/ui/panels/panel_host.cc
@@ -10,8 +10,11 @@
#include "chrome/browser/chrome_page_zoom.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/view_type_utils.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension_messages.h"
@@ -72,6 +75,30 @@ SkBitmap PanelHost::GetPageIcon() const {
favicon_tab_helper_->GetFavicon().AsBitmap() : SkBitmap();
}
+content::WebContents* PanelHost::OpenURLFromTab(
+ content::WebContents* source,
+ const content::OpenURLParams& params) {
+ // These dispositions aren't really navigations.
+ if (params.disposition == SUPPRESS_OPEN ||
+ params.disposition == SAVE_TO_DISK ||
+ params.disposition == IGNORE_ACTION)
+ return NULL;
+
+ // Only allow clicks on links.
+ if (params.transition != content::PAGE_TRANSITION_LINK)
+ return NULL;
+
+ // Force all links to open in a new tab.
+ chrome::NavigateParams navigate_params(
+ browser::FindOrCreateTabbedBrowser(profile_),
+ params.url, params.transition);
+ navigate_params.disposition = params.disposition == NEW_BACKGROUND_TAB ?
+ params.disposition : NEW_FOREGROUND_TAB;
+ chrome::Navigate(&navigate_params);
+ return navigate_params.target_contents ?
+ navigate_params.target_contents->web_contents() : NULL;
+}
+
void PanelHost::NavigationStateChanged(const content::WebContents* source,
unsigned changed_flags) {
// Only need to update the title if the title changed while not loading,
« no previous file with comments | « chrome/browser/ui/panels/panel_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698