OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_dialog.h" | |
6 | |
7 #include "base/message_loop.h" | |
8 #include "chrome/browser/ui/browser_dialogs.h" | |
9 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" | |
10 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | |
11 #include "content/public/browser/page_navigator.h" | |
12 #include "grit/chromium_strings.h" | |
13 #include "grit/generated_resources.h" | |
14 #include "ui/base/l10n/l10n_util.h" | |
15 #include "ui/gfx/size.h" | |
16 | |
17 SyncPromoDialog::SyncPromoDialog(Profile* profile, GURL url) | |
18 : profile_(profile), | |
19 spawned_browser_(NULL), | |
20 sync_promo_was_closed_(false), | |
21 url_(url), | |
22 window_(NULL) { | |
23 } | |
24 | |
25 SyncPromoDialog::~SyncPromoDialog() { | |
26 } | |
27 | |
28 void SyncPromoDialog::ShowDialog() { | |
29 window_ = browser::ShowHtmlDialog(NULL, profile_, NULL, this, STYLE_GENERIC); | |
30 | |
31 // Wait for the dialog to close. | |
32 MessageLoop::current()->Run(); | |
33 } | |
34 | |
35 ui::ModalType SyncPromoDialog::GetDialogModalType() const { | |
36 return ui::MODAL_TYPE_SYSTEM; | |
37 } | |
38 | |
39 string16 SyncPromoDialog::GetDialogTitle() const { | |
40 return l10n_util::GetStringFUTF16( | |
41 IDS_SYNC_PROMO_TITLE, | |
42 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | |
43 } | |
44 | |
45 GURL SyncPromoDialog::GetDialogContentURL() const { | |
46 return url_; | |
47 } | |
48 | |
49 void SyncPromoDialog::GetWebUIMessageHandlers( | |
50 std::vector<content::WebUIMessageHandler*>* handlers) const { | |
51 } | |
52 | |
53 void SyncPromoDialog::GetDialogSize(gfx::Size* size) const { | |
Dan Beam
2012/01/30 18:10:05
I'm assuming this is handled somewhere, but what h
sail
2012/01/30 21:52:36
there's only one size variable, there's nothing to
| |
54 *size = gfx::Size(500, 540); | |
55 } | |
56 | |
57 std::string SyncPromoDialog::GetDialogArgs() const { | |
58 return std::string(); | |
59 } | |
60 | |
61 void SyncPromoDialog::OnDialogClosed(const std::string& json_retval) { | |
62 MessageLoop::current()->Quit(); | |
63 } | |
64 | |
65 void SyncPromoDialog::OnCloseContents(content::WebContents* source, | |
66 bool* out_close_dialog) { | |
67 } | |
68 | |
69 bool SyncPromoDialog::ShouldShowDialogTitle() const { | |
70 return true; | |
71 } | |
72 | |
73 bool SyncPromoDialog::HandleContextMenu(const ContextMenuParams& params) { | |
74 return true; | |
75 } | |
76 | |
77 bool SyncPromoDialog::HandleOpenURLFromTab( | |
78 content::WebContents* source, | |
79 const content::OpenURLParams& params, | |
80 content::WebContents** out_new_contents) { | |
81 spawned_browser_ = HtmlDialogTabContentsDelegate::StaticOpenURLFromTab( | |
82 profile_, source, params, out_new_contents); | |
83 sync_promo_was_closed_ = params.disposition == CURRENT_TAB; | |
Dan Beam
2012/01/30 18:10:05
what is this doing?
sail
2012/01/30 21:52:36
if open URL request is for the current tab then th
| |
84 browser::CloseHtmlDialog(window_); | |
85 return true; | |
86 } | |
87 | |
88 bool SyncPromoDialog::HandleAddNewContents( | |
89 content::WebContents* source, | |
90 content::WebContents* new_contents, | |
91 WindowOpenDisposition disposition, | |
92 const gfx::Rect& initial_pos, | |
93 bool user_gesture) { | |
94 spawned_browser_ = HtmlDialogTabContentsDelegate::StaticAddNewContents( | |
95 profile_, source, new_contents, disposition, initial_pos, user_gesture); | |
96 browser::CloseHtmlDialog(window_); | |
97 return true; | |
98 } | |
OLD | NEW |