OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/dom_ui/html_dialog_tab_contents_delegate.h" | 5 #include "chrome/browser/dom_ui/html_dialog_tab_contents_delegate.h" |
6 | 6 |
7 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
8 #include "chrome/browser/browser_window.h" | 8 #include "chrome/browser/browser_navigator.h" |
9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
11 #include "chrome/browser/tabs/tab_strip_model.h" | 11 #include "chrome/browser/tabs/tab_strip_model.h" |
12 | 12 |
13 // Incognito profiles are not long-lived, so we always want to store a | 13 // Incognito profiles are not long-lived, so we always want to store a |
14 // non-incognito profile. | 14 // non-incognito profile. |
15 // | 15 // |
16 // TODO(akalin): Should we make it so that we have a default incognito | 16 // TODO(akalin): Should we make it so that we have a default incognito |
17 // profile that's long-lived? Of course, we'd still have to clear it out | 17 // profile that's long-lived? Of course, we'd still have to clear it out |
18 // when all incognito browsers close. | 18 // when all incognito browsers close. |
(...skipping 14 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 void HtmlDialogTabContentsDelegate::OpenURLFromTab( | 35 void HtmlDialogTabContentsDelegate::OpenURLFromTab( |
36 TabContents* source, const GURL& url, const GURL& referrer, | 36 TabContents* source, const GURL& url, const GURL& referrer, |
37 WindowOpenDisposition disposition, PageTransition::Type transition) { | 37 WindowOpenDisposition disposition, PageTransition::Type transition) { |
38 if (profile_) { | 38 if (profile_) { |
39 // Force all links to open in a new window, ignoring the incoming | 39 // Force all links to open in a new window, ignoring the incoming |
40 // disposition. This is a tabless, modal dialog so we can't just | 40 // disposition. This is a tabless, modal dialog so we can't just |
41 // open it in the current frame. Code adapted from | 41 // open it in the current frame. Code adapted from |
42 // Browser::OpenURLFromTab() with disposition == NEW_WINDOW. | 42 // Browser::OpenURLFromTab() with disposition == NEW_WINDOW. |
43 Browser* browser = CreateBrowser(); | 43 browser::NavigateParams params(CreateBrowser(), url, transition); |
44 Browser::AddTabWithURLParams params(url, transition); | |
45 params.referrer = referrer; | 44 params.referrer = referrer; |
46 browser->AddTabWithURL(¶ms); | 45 params.disposition = NEW_FOREGROUND_TAB; |
47 browser->window()->Show(); | 46 params.show_window = true; |
| 47 browser::Navigate(¶ms); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 void HtmlDialogTabContentsDelegate::NavigationStateChanged( | 51 void HtmlDialogTabContentsDelegate::NavigationStateChanged( |
52 const TabContents* source, unsigned changed_flags) { | 52 const TabContents* source, unsigned changed_flags) { |
53 // We shouldn't receive any NavigationStateChanged except the first | 53 // We shouldn't receive any NavigationStateChanged except the first |
54 // one, which we ignore because we're a dialog box. | 54 // one, which we ignore because we're a dialog box. |
55 } | 55 } |
56 | 56 |
57 void HtmlDialogTabContentsDelegate::AddNewContents( | 57 void HtmlDialogTabContentsDelegate::AddNewContents( |
58 TabContents* source, TabContents* new_contents, | 58 TabContents* source, TabContents* new_contents, |
59 WindowOpenDisposition disposition, const gfx::Rect& initial_pos, | 59 WindowOpenDisposition disposition, const gfx::Rect& initial_pos, |
60 bool user_gesture) { | 60 bool user_gesture) { |
61 if (profile_) { | 61 if (profile_) { |
62 // Force this to open in a new window, too. Code adapted from | 62 // Force this to open in a new window so that it appears at the top |
63 // Browser::AddNewContents() with disposition == NEW_WINDOW. | 63 // of the z-index. |
64 Browser* browser = CreateBrowser(); | 64 browser::NavigateParams params(CreateBrowser(), new_contents); |
65 static_cast<TabContentsDelegate*>(browser)-> | 65 params.source_contents = source; |
66 AddNewContents(source, new_contents, NEW_FOREGROUND_TAB, | 66 params.disposition = NEW_FOREGROUND_TAB; |
67 initial_pos, user_gesture); | 67 params.window_bounds = initial_pos; |
68 browser->window()->Show(); | 68 params.show_window = true; |
| 69 browser::Navigate(¶ms); |
69 } | 70 } |
70 } | 71 } |
71 | 72 |
72 void HtmlDialogTabContentsDelegate::ActivateContents(TabContents* contents) { | 73 void HtmlDialogTabContentsDelegate::ActivateContents(TabContents* contents) { |
73 // We don't do anything here because there's only one TabContents in | 74 // We don't do anything here because there's only one TabContents in |
74 // this frame and we don't have a TabStripModel. | 75 // this frame and we don't have a TabStripModel. |
75 } | 76 } |
76 | 77 |
77 void HtmlDialogTabContentsDelegate::DeactivateContents(TabContents* contents) { | 78 void HtmlDialogTabContentsDelegate::DeactivateContents(TabContents* contents) { |
78 // We don't care about this notification (called when a user gesture triggers | 79 // We don't care about this notification (called when a user gesture triggers |
(...skipping 25 matching lines...) Expand all Loading... |
104 const GURL& url) { | 105 const GURL& url) { |
105 // Ignored. | 106 // Ignored. |
106 } | 107 } |
107 | 108 |
108 bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory( | 109 bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory( |
109 const history::HistoryAddPageArgs& add_page_args, | 110 const history::HistoryAddPageArgs& add_page_args, |
110 NavigationType::Type navigation_type) { | 111 NavigationType::Type navigation_type) { |
111 return false; | 112 return false; |
112 } | 113 } |
113 | 114 |
OLD | NEW |