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

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: address review comments 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, WebContents* source, const OpenURLParams& params,
44 params.disposition == CURRENT_TAB && 44 WebContents** out_new_contents) {
45 params.transition == content::PAGE_TRANSITION_LINK) 45 if (!profile)
46 nav_params.disposition = NEW_FOREGROUND_TAB; 46 return NULL;
47 else 47
48 nav_params.disposition = params.disposition; 48 // Specify a NULL browser for navigation. This will cause Navigate()
49 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW; 49 // to find a browser matching params.profile or create a new one.
50 nav_params.user_gesture = true; 50 Browser* browser = NULL;
51 browser::Navigate(&nav_params); 51 browser::NavigateParams nav_params(browser, params.url, params.transition);
52 return nav_params.target_contents ? 52 nav_params.profile = profile;
53 nav_params.target_contents->web_contents() : NULL; 53 nav_params.referrer = params.referrer;
54 if (source && source->IsCrashed() &&
55 params.disposition == CURRENT_TAB &&
56 params.transition == content::PAGE_TRANSITION_LINK) {
57 nav_params.disposition = NEW_FOREGROUND_TAB;
58 } else {
59 nav_params.disposition = params.disposition;
54 } 60 }
55 return NULL; 61 nav_params.window_action = browser::NavigateParams::SHOW_WINDOW;
62 nav_params.user_gesture = true;
63 browser::Navigate(&nav_params);
64 *out_new_contents = nav_params.target_contents ?
65 nav_params.target_contents->web_contents() : NULL;
66 return nav_params.browser;
56 } 67 }
57 68
58 void HtmlDialogTabContentsDelegate::AddNewContents( 69 void HtmlDialogTabContentsDelegate::AddNewContents(
59 WebContents* source, WebContents* new_contents, 70 WebContents* source, WebContents* new_contents,
60 WindowOpenDisposition disposition, const gfx::Rect& initial_pos, 71 WindowOpenDisposition disposition, const gfx::Rect& initial_pos,
61 bool user_gesture) { 72 bool user_gesture) {
62 if (profile_) { 73 StaticAddNewContents(profile_, source, new_contents, disposition,
63 // Specify a NULL browser for navigation. This will cause Navigate() 74 initial_pos, user_gesture);
64 // to find a browser matching params.profile or create a new one. 75 }
65 Browser* browser = NULL;
66 76
67 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); 77 // static
68 browser::NavigateParams params(browser, wrapper); 78 Browser* HtmlDialogTabContentsDelegate::StaticAddNewContents(
69 params.profile = profile_; 79 Profile* profile,
70 // TODO(pinkerton): no way to get a wrapper for this. 80 WebContents* source,
71 // params.source_contents = source; 81 WebContents* new_contents,
72 params.disposition = disposition; 82 WindowOpenDisposition disposition,
73 params.window_bounds = initial_pos; 83 const gfx::Rect& initial_pos,
74 params.window_action = browser::NavigateParams::SHOW_WINDOW; 84 bool user_gesture) {
75 params.user_gesture = true; 85 if (!profile)
76 browser::Navigate(&params); 86 return NULL;
77 } 87
88 // Specify a NULL browser for navigation. This will cause Navigate()
89 // to find a browser matching params.profile or create a new one.
90 Browser* browser = NULL;
91
92 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents);
93 browser::NavigateParams params(browser, wrapper);
94 params.profile = profile;
95 // TODO(pinkerton): no way to get a wrapper for this.
96 // params.source_contents = source;
97 params.disposition = disposition;
98 params.window_bounds = initial_pos;
99 params.window_action = browser::NavigateParams::SHOW_WINDOW;
100 params.user_gesture = true;
101 browser::Navigate(&params);
102
103 return params.browser;
78 } 104 }
79 105
80 bool HtmlDialogTabContentsDelegate::IsPopupOrPanel( 106 bool HtmlDialogTabContentsDelegate::IsPopupOrPanel(
81 const WebContents* source) const { 107 const WebContents* source) const {
82 // This needs to return true so that we are allowed to be resized by our 108 // This needs to return true so that we are allowed to be resized by our
83 // contents. 109 // contents.
84 return true; 110 return true;
85 } 111 }
86 112
87 bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory( 113 bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory(
88 const history::HistoryAddPageArgs& add_page_args, 114 const history::HistoryAddPageArgs& add_page_args,
89 content::NavigationType navigation_type) { 115 content::NavigationType navigation_type) {
90 return false; 116 return false;
91 } 117 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h ('k') | chrome/browser/ui/webui/html_dialog_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698