Chromium Code Reviews| 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 { | |
| 54 DCHECK(size); | |
| 55 *size = gfx::Size(500, 540); | |
|
James Hawkins
2012/01/31 00:23:22
Use static const vars.
sail
2012/01/31 01:03:46
Done.
| |
| 56 } | |
| 57 | |
| 58 std::string SyncPromoDialog::GetDialogArgs() const { | |
| 59 return std::string(); | |
| 60 } | |
| 61 | |
| 62 void SyncPromoDialog::OnDialogClosed(const std::string& json_retval) { | |
| 63 MessageLoop::current()->Quit(); | |
| 64 } | |
| 65 | |
| 66 void SyncPromoDialog::OnCloseContents(content::WebContents* source, | |
|
James Hawkins
2012/01/31 00:23:22
Must we override all of these methods we're not sp
sail
2012/01/31 01:03:46
They're all abstract functions so we have to overr
| |
| 67 bool* out_close_dialog) { | |
| 68 } | |
| 69 | |
| 70 bool SyncPromoDialog::ShouldShowDialogTitle() const { | |
| 71 return true; | |
| 72 } | |
| 73 | |
| 74 bool SyncPromoDialog::HandleContextMenu(const ContextMenuParams& params) { | |
| 75 return true; | |
| 76 } | |
| 77 | |
| 78 bool SyncPromoDialog::HandleOpenURLFromTab( | |
| 79 content::WebContents* source, | |
| 80 const content::OpenURLParams& params, | |
| 81 content::WebContents** out_new_contents) { | |
| 82 spawned_browser_ = HtmlDialogTabContentsDelegate::StaticOpenURLFromTab( | |
| 83 profile_, source, params, out_new_contents); | |
| 84 // If the open URL request is for the current tab then that means the sync | |
| 85 // promo page will be closed. | |
| 86 sync_promo_was_closed_ = params.disposition == CURRENT_TAB; | |
| 87 browser::CloseHtmlDialog(window_); | |
| 88 return true; | |
| 89 } | |
| 90 | |
| 91 bool SyncPromoDialog::HandleAddNewContents( | |
| 92 content::WebContents* source, | |
| 93 content::WebContents* new_contents, | |
| 94 WindowOpenDisposition disposition, | |
| 95 const gfx::Rect& initial_pos, | |
| 96 bool user_gesture) { | |
| 97 spawned_browser_ = HtmlDialogTabContentsDelegate::StaticAddNewContents( | |
| 98 profile_, source, new_contents, disposition, initial_pos, user_gesture); | |
| 99 browser::CloseHtmlDialog(window_); | |
| 100 return true; | |
| 101 } | |
| OLD | NEW |