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

Side by Side Diff: chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc

Issue 9225053: Add a blocking version of the sync promo dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 10 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
OLDNEW
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
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,
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)
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 } 54 nav_params.profile = profile;
55 return NULL; 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;
62 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW;
63 nav_params.user_gesture = true;
64 browser::Navigate(&nav_params);
65 *out_new_contents = nav_params.target_contents ?
66 nav_params.target_contents->web_contents() : NULL;
67 return nav_params.browser;
56 } 68 }
57 69
58 void HtmlDialogTabContentsDelegate::AddNewContents( 70 void HtmlDialogTabContentsDelegate::AddNewContents(
59 WebContents* source, WebContents* new_contents, 71 WebContents* source, WebContents* new_contents,
60 WindowOpenDisposition disposition, const gfx::Rect& initial_pos, 72 WindowOpenDisposition disposition, const gfx::Rect& initial_pos,
61 bool user_gesture) { 73 bool user_gesture) {
62 if (profile_) { 74 StaticAddNewContents(profile_, source, new_contents, disposition,
63 // Specify a NULL browser for navigation. This will cause Navigate() 75 initial_pos, user_gesture);
64 // to find a browser matching params.profile or create a new one. 76 }
65 Browser* browser = NULL;
66 77
67 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); 78 // static
68 browser::NavigateParams params(browser, wrapper); 79 Browser* HtmlDialogTabContentsDelegate::StaticAddNewContents(
69 params.profile = profile_; 80 Profile* profile,
70 // TODO(pinkerton): no way to get a wrapper for this. 81 WebContents* source,
71 // params.source_contents = source; 82 WebContents* new_contents,
72 params.disposition = disposition; 83 WindowOpenDisposition disposition,
73 params.window_bounds = initial_pos; 84 const gfx::Rect& initial_pos,
74 params.window_action = browser::NavigateParams::SHOW_WINDOW; 85 bool user_gesture) {
75 params.user_gesture = true; 86 if (!profile)
76 browser::Navigate(&params); 87 return NULL;
77 } 88
89 // Specify a NULL browser for navigation. This will cause Navigate()
90 // to find a browser matching params.profile or create a new one.
91 Browser* browser = NULL;
92
93 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents);
94 browser::NavigateParams params(browser, wrapper);
95 params.profile = profile;
96 // TODO(pinkerton): no way to get a wrapper for this.
97 // params.source_contents = source;
98 params.disposition = disposition;
99 params.window_bounds = initial_pos;
100 params.window_action = browser::NavigateParams::SHOW_WINDOW;
101 params.user_gesture = true;
102 browser::Navigate(&params);
103
104 return params.browser;
78 } 105 }
79 106
80 bool HtmlDialogTabContentsDelegate::IsPopupOrPanel( 107 bool HtmlDialogTabContentsDelegate::IsPopupOrPanel(
81 const WebContents* source) const { 108 const WebContents* source) const {
82 // This needs to return true so that we are allowed to be resized by our 109 // This needs to return true so that we are allowed to be resized by our
83 // contents. 110 // contents.
84 return true; 111 return true;
85 } 112 }
86 113
87 bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory( 114 bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory(
88 const history::HistoryAddPageArgs& add_page_args, 115 const history::HistoryAddPageArgs& add_page_args,
89 content::NavigationType navigation_type) { 116 content::NavigationType navigation_type) {
90 return false; 117 return false;
91 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698