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

Side by Side Diff: chrome/browser/ui/webui/sync_promo/sync_promo_dialog.cc

Issue 9730021: Remove experimental sync promo layouts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 8 years, 9 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
(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/bind.h"
8 #include "base/message_loop.h"
9 #include "chrome/browser/ui/browser_dialogs.h"
10 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h"
11 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
12 #include "content/public/browser/page_navigator.h"
13 #include "grit/chromium_strings.h"
14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/gfx/size.h"
17
18 SyncPromoDialog::SyncPromoDialog(Profile* profile, GURL url)
19 : profile_(profile),
20 spawned_browser_(NULL),
21 sync_promo_was_closed_(false),
22 url_(url),
23 window_(NULL) {
24 }
25
26 SyncPromoDialog::~SyncPromoDialog() {
27 }
28
29 void SyncPromoDialog::ShowDialog() {
30 window_ = browser::ShowHtmlDialog(NULL, profile_, NULL, this, STYLE_GENERIC);
31
32 // Wait for the dialog to close.
33 MessageLoop::current()->Run();
34 }
35
36 ui::ModalType SyncPromoDialog::GetDialogModalType() const {
37 return ui::MODAL_TYPE_SYSTEM;
38 }
39
40 string16 SyncPromoDialog::GetDialogTitle() const {
41 return l10n_util::GetStringFUTF16(
42 IDS_SYNC_PROMO_TITLE,
43 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
44 }
45
46 GURL SyncPromoDialog::GetDialogContentURL() const {
47 return url_;
48 }
49
50 void SyncPromoDialog::GetWebUIMessageHandlers(
51 std::vector<content::WebUIMessageHandler*>* handlers) const {
52 }
53
54 void SyncPromoDialog::GetDialogSize(gfx::Size* size) const {
55 DCHECK(size);
56 const int kDialogWidth = 530;
57 const int kDialogHeight = 540;
58 *size = gfx::Size(kDialogWidth, kDialogHeight);
59 }
60
61 std::string SyncPromoDialog::GetDialogArgs() const {
62 return std::string();
63 }
64
65 void SyncPromoDialog::OnDialogClosed(const std::string& json_retval) {
66 MessageLoop::current()->Quit();
67 }
68
69 void SyncPromoDialog::OnCloseContents(content::WebContents* source,
70 bool* out_close_dialog) {
71 }
72
73 bool SyncPromoDialog::ShouldShowDialogTitle() const {
74 return true;
75 }
76
77 bool SyncPromoDialog::HandleContextMenu(
78 const content::ContextMenuParams& params) {
79 return true;
80 }
81
82 bool SyncPromoDialog::HandleOpenURLFromTab(
83 content::WebContents* source,
84 const content::OpenURLParams& params,
85 content::WebContents** out_new_contents) {
86 spawned_browser_ = HtmlDialogTabContentsDelegate::StaticOpenURLFromTab(
87 profile_, source, params, out_new_contents);
88 // If the open URL request is for the current tab then that means the sync
89 // promo page will be closed.
90 sync_promo_was_closed_ = params.disposition == CURRENT_TAB;
91 CloseDialog();
92 return true;
93 }
94
95 bool SyncPromoDialog::HandleAddNewContents(
96 content::WebContents* source,
97 content::WebContents* new_contents,
98 WindowOpenDisposition disposition,
99 const gfx::Rect& initial_pos,
100 bool user_gesture) {
101 spawned_browser_ = HtmlDialogTabContentsDelegate::StaticAddNewContents(
102 profile_, source, new_contents, disposition, initial_pos, user_gesture);
103 CloseDialog();
104 return true;
105 }
106
107 void SyncPromoDialog::CloseDialog() {
108 // Only close the window once.
109 if (!window_)
110 return;
111
112 // Close the dialog asynchronously since closing it will cause this and other
113 // WebUI handlers to be deleted.
114 MessageLoop::current()->PostTask(
115 FROM_HERE, base::Bind(browser::CloseHtmlDialog, window_));
116 window_ = NULL;
117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698