OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webui/html_dialog_tab_contents_delegate.h" | 5 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/tabs/tab_strip_model.h" | 8 #include "chrome/browser/tabs/tab_strip_model.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 HtmlDialogTabContentsDelegate::~HtmlDialogTabContentsDelegate() {} | 26 HtmlDialogTabContentsDelegate::~HtmlDialogTabContentsDelegate() {} |
27 | 27 |
28 Profile* HtmlDialogTabContentsDelegate::profile() const { return profile_; } | 28 Profile* HtmlDialogTabContentsDelegate::profile() const { return profile_; } |
29 | 29 |
30 void HtmlDialogTabContentsDelegate::Detach() { | 30 void HtmlDialogTabContentsDelegate::Detach() { |
31 profile_ = NULL; | 31 profile_ = NULL; |
32 } | 32 } |
33 | 33 |
34 WebContents* HtmlDialogTabContentsDelegate::OpenURLFromTab( | 34 WebContents* HtmlDialogTabContentsDelegate::OpenURLFromTab( |
35 WebContents* source, const OpenURLParams& params) { | 35 WebContents* source, const OpenURLParams& params) { |
36 if (profile_) { | 36 WebContents* new_contents = NULL; |
37 // Specify a NULL browser for navigation. This will cause Navigate() | 37 StaticOpenURLFromTab(profile_, source, params, &new_contents); |
38 // to find a browser matching params.profile or create a new one. | 38 return new_contents; |
39 Browser* browser = NULL; | 39 } |
40 browser::NavigateParams nav_params(browser, params.url, params.transition); | 40 |
41 nav_params.profile = profile_; | 41 // static |
42 nav_params.referrer = params.referrer; | 42 Browser* HtmlDialogTabContentsDelegate::StaticOpenURLFromTab( |
43 if (source && source->IsCrashed() && | 43 Profile* profile, |
James Hawkins
2012/01/31 00:23:22
Optional: Save space and put more than one paramet
sail
2012/01/31 01:03:46
Done.
| |
44 params.disposition == CURRENT_TAB && | 44 WebContents* source, |
45 params.transition == content::PAGE_TRANSITION_LINK) | 45 const OpenURLParams& params, |
46 nav_params.disposition = NEW_FOREGROUND_TAB; | 46 WebContents** out_new_contents) { |
47 else | 47 if (!profile) |
James Hawkins
2012/01/31 00:23:22
Under what circumstances is profile NULL?
sail
2012/01/31 01:03:46
I'm not sure. This is just existing code that I mo
| |
48 nav_params.disposition = params.disposition; | 48 return NULL; |
49 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; | 49 |
50 nav_params.user_gesture = true; | 50 // Specify a NULL browser for navigation. This will cause Navigate() |
51 browser::Navigate(&nav_params); | 51 // to find a browser matching params.profile or create a new one. |
52 return nav_params.target_contents ? | 52 Browser* browser = NULL; |
53 nav_params.target_contents->web_contents() : NULL; | 53 browser::NavigateParams nav_params(browser, params.url, params.transition); |
54 nav_params.profile = profile; | |
55 nav_params.referrer = params.referrer; | |
56 if (source && source->IsCrashed() && | |
57 params.disposition == CURRENT_TAB && | |
58 params.transition == content::PAGE_TRANSITION_LINK) { | |
59 nav_params.disposition = NEW_FOREGROUND_TAB; | |
60 } else { | |
61 nav_params.disposition = params.disposition; | |
54 } | 62 } |
55 return NULL; | 63 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; |
64 nav_params.user_gesture = true; | |
65 browser::Navigate(&nav_params); | |
66 *out_new_contents = nav_params.target_contents ? | |
67 nav_params.target_contents->web_contents() : NULL; | |
68 return nav_params.browser; | |
56 } | 69 } |
57 | 70 |
58 void HtmlDialogTabContentsDelegate::AddNewContents( | 71 void HtmlDialogTabContentsDelegate::AddNewContents( |
59 WebContents* source, WebContents* new_contents, | 72 WebContents* source, WebContents* new_contents, |
60 WindowOpenDisposition disposition, const gfx::Rect& initial_pos, | 73 WindowOpenDisposition disposition, const gfx::Rect& initial_pos, |
61 bool user_gesture) { | 74 bool user_gesture) { |
62 if (profile_) { | 75 StaticAddNewContents(profile_, source, new_contents, disposition, |
63 // Specify a NULL browser for navigation. This will cause Navigate() | 76 initial_pos, user_gesture); |
64 // to find a browser matching params.profile or create a new one. | 77 } |
65 Browser* browser = NULL; | |
66 | 78 |
67 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); | 79 // static |
68 browser::NavigateParams params(browser, wrapper); | 80 Browser* HtmlDialogTabContentsDelegate::StaticAddNewContents( |
69 params.profile = profile_; | 81 Profile* profile, |
70 // TODO(pinkerton): no way to get a wrapper for this. | 82 WebContents* source, |
71 // params.source_contents = source; | 83 WebContents* new_contents, |
72 params.disposition = disposition; | 84 WindowOpenDisposition disposition, |
73 params.window_bounds = initial_pos; | 85 const gfx::Rect& initial_pos, |
74 params.window_action = browser::NavigateParams::SHOW_WINDOW; | 86 bool user_gesture) { |
75 params.user_gesture = true; | 87 if (!profile) |
76 browser::Navigate(¶ms); | 88 return NULL; |
77 } | 89 |
90 // Specify a NULL browser for navigation. This will cause Navigate() | |
91 // to find a browser matching params.profile or create a new one. | |
92 Browser* browser = NULL; | |
93 | |
94 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); | |
95 browser::NavigateParams params(browser, wrapper); | |
96 params.profile = profile; | |
97 // TODO(pinkerton): no way to get a wrapper for this. | |
98 // params.source_contents = source; | |
99 params.disposition = disposition; | |
100 params.window_bounds = initial_pos; | |
101 params.window_action = browser::NavigateParams::SHOW_WINDOW; | |
102 params.user_gesture = true; | |
103 browser::Navigate(¶ms); | |
104 | |
105 return params.browser; | |
78 } | 106 } |
79 | 107 |
80 bool HtmlDialogTabContentsDelegate::IsPopupOrPanel( | 108 bool HtmlDialogTabContentsDelegate::IsPopupOrPanel( |
81 const WebContents* source) const { | 109 const WebContents* source) const { |
82 // This needs to return true so that we are allowed to be resized by our | 110 // This needs to return true so that we are allowed to be resized by our |
83 // contents. | 111 // contents. |
84 return true; | 112 return true; |
85 } | 113 } |
86 | 114 |
87 bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory( | 115 bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory( |
88 const history::HistoryAddPageArgs& add_page_args, | 116 const history::HistoryAddPageArgs& add_page_args, |
89 content::NavigationType navigation_type) { | 117 content::NavigationType navigation_type) { |
90 return false; | 118 return false; |
91 } | 119 } |
OLD | NEW |