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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/panels/panel_host.h ('k') | 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/ui/panels/panel_host.h" 5 #include "chrome/browser/ui/panels/panel_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/chrome_page_zoom.h" 10 #include "chrome/browser/chrome_page_zoom.h"
11 #include "chrome/browser/favicon/favicon_tab_helper.h" 11 #include "chrome/browser/favicon/favicon_tab_helper.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_navigator.h"
13 #include "chrome/browser/ui/panels/panel.h" 15 #include "chrome/browser/ui/panels/panel.h"
14 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" 16 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents.h"
15 #include "chrome/browser/view_type_utils.h" 18 #include "chrome/browser/view_type_utils.h"
16 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/extensions/extension_messages.h" 20 #include "chrome/common/extensions/extension_messages.h"
18 #include "content/public/browser/invalidate_type.h" 21 #include "content/public/browser/invalidate_type.h"
19 #include "content/public/browser/navigation_controller.h" 22 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
22 #include "content/public/browser/notification_types.h" 25 #include "content/public/browser/notification_types.h"
23 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
24 #include "content/public/browser/site_instance.h" 27 #include "content/public/browser/site_instance.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 prefs_tab_helper_.reset(); 68 prefs_tab_helper_.reset();
66 web_contents_.reset(); 69 web_contents_.reset();
67 } 70 }
68 71
69 SkBitmap PanelHost::GetPageIcon() const { 72 SkBitmap PanelHost::GetPageIcon() const {
70 // TODO: Make this function return gfx::Image. 73 // TODO: Make this function return gfx::Image.
71 return favicon_tab_helper_.get() ? 74 return favicon_tab_helper_.get() ?
72 favicon_tab_helper_->GetFavicon().AsBitmap() : SkBitmap(); 75 favicon_tab_helper_->GetFavicon().AsBitmap() : SkBitmap();
73 } 76 }
74 77
78 content::WebContents* PanelHost::OpenURLFromTab(
79 content::WebContents* source,
80 const content::OpenURLParams& params) {
81 // These dispositions aren't really navigations.
82 if (params.disposition == SUPPRESS_OPEN ||
83 params.disposition == SAVE_TO_DISK ||
84 params.disposition == IGNORE_ACTION)
85 return NULL;
86
87 // Only allow clicks on links.
88 if (params.transition != content::PAGE_TRANSITION_LINK)
89 return NULL;
90
91 // Force all links to open in a new tab.
92 chrome::NavigateParams navigate_params(
93 browser::FindOrCreateTabbedBrowser(profile_),
94 params.url, params.transition);
95 navigate_params.disposition = params.disposition == NEW_BACKGROUND_TAB ?
96 params.disposition : NEW_FOREGROUND_TAB;
97 chrome::Navigate(&navigate_params);
98 return navigate_params.target_contents ?
99 navigate_params.target_contents->web_contents() : NULL;
100 }
101
75 void PanelHost::NavigationStateChanged(const content::WebContents* source, 102 void PanelHost::NavigationStateChanged(const content::WebContents* source,
76 unsigned changed_flags) { 103 unsigned changed_flags) {
77 // Only need to update the title if the title changed while not loading, 104 // Only need to update the title if the title changed while not loading,
78 // because the title is also updated when loading state changes. 105 // because the title is also updated when loading state changes.
79 if ((changed_flags & content::INVALIDATE_TYPE_TAB) || 106 if ((changed_flags & content::INVALIDATE_TYPE_TAB) ||
80 ((changed_flags & content::INVALIDATE_TYPE_TITLE) && 107 ((changed_flags & content::INVALIDATE_TYPE_TITLE) &&
81 !source->IsLoading())) 108 !source->IsLoading()))
82 panel_->UpdateTitleBar(); 109 panel_->UpdateTitleBar();
83 } 110 }
84 111
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 215 }
189 216
190 void PanelHost::StopLoading() { 217 void PanelHost::StopLoading() {
191 content::RecordAction(UserMetricsAction("Stop")); 218 content::RecordAction(UserMetricsAction("Stop"));
192 web_contents_->Stop(); 219 web_contents_->Stop();
193 } 220 }
194 221
195 void PanelHost::Zoom(content::PageZoom zoom) { 222 void PanelHost::Zoom(content::PageZoom zoom) {
196 chrome_page_zoom::Zoom(web_contents_.get(), zoom); 223 chrome_page_zoom::Zoom(web_contents_.get(), zoom);
197 } 224 }
OLDNEW
« 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