Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/cloud_print_signin_dialog.h" | 5 #include "chrome/browser/ui/webui/cloud_print_signin_dialog.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
| 12 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 12 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/tab_contents/tab_util.h" | 14 #include "chrome/browser/tab_contents/tab_util.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
| 17 #if defined(USE_AURA) | |
| 18 #include "chrome/browser/ui/browser_window.h" | |
| 19 #endif | |
| 17 #include "chrome/browser/ui/dialog_style.h" | 20 #include "chrome/browser/ui/dialog_style.h" |
| 21 #if defined(USE_AURA) | |
| 22 #include "chrome/browser/ui/views/html_dialog_view.h" | |
| 23 #endif | |
| 18 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 24 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 19 #include "chrome/browser/ui/webui/print_preview_ui.h" | 25 #include "chrome/browser/ui/webui/print_preview_ui.h" |
| 20 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 22 #include "content/browser/renderer_host/render_view_host.h" | 28 #include "content/browser/renderer_host/render_view_host.h" |
| 23 #include "content/browser/tab_contents/tab_contents_view.h" | 29 #include "content/browser/tab_contents/tab_contents_view.h" |
| 24 #include "content/public/browser/navigation_controller.h" | 30 #include "content/public/browser/navigation_controller.h" |
| 25 #include "content/public/browser/navigation_entry.h" | 31 #include "content/public/browser/navigation_entry.h" |
| 26 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
| 27 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
| 28 #include "content/public/browser/notification_types.h" | 34 #include "content/public/browser/notification_types.h" |
| 29 #include "content/public/browser/render_process_host.h" | 35 #include "content/public/browser/render_process_host.h" |
| 30 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 31 #include "content/public/browser/web_ui_message_handler.h" | 37 #include "content/public/browser/web_ui_message_handler.h" |
| 32 | 38 #if defined(USE_AURA) |
| 39 #include "ui/views/widget/widget.h" | |
| 40 #endif | |
| 33 using content::BrowserThread; | 41 using content::BrowserThread; |
| 34 using content::NavigationController; | 42 using content::NavigationController; |
| 35 using content::NavigationEntry; | 43 using content::NavigationEntry; |
| 36 using content::WebContents; | 44 using content::WebContents; |
| 37 using content::WebUIMessageHandler; | 45 using content::WebUIMessageHandler; |
| 38 | 46 |
| 39 // This module implements a sign in dialog for cloud print. | 47 // This module implements a sign in dialog for cloud print. |
| 40 // it is based heavily off "chrome/browser/printing/print_dialog_cloud.cc". | 48 // it is based heavily off "chrome/browser/printing/print_dialog_cloud.cc". |
| 41 // See the comments in that file for a discussion about how this works. | 49 // See the comments in that file for a discussion about how this works. |
| 42 | 50 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 void CloudPrintSigninDelegate::GetWebUIMessageHandlers( | 157 void CloudPrintSigninDelegate::GetWebUIMessageHandlers( |
| 150 std::vector<WebUIMessageHandler*>* handlers) const { | 158 std::vector<WebUIMessageHandler*>* handlers) const { |
| 151 handlers->push_back(new CloudPrintSigninFlowHandler(parent_tab_)); | 159 handlers->push_back(new CloudPrintSigninFlowHandler(parent_tab_)); |
| 152 } | 160 } |
| 153 | 161 |
| 154 void CloudPrintSigninDelegate::GetDialogSize(gfx::Size* size) const { | 162 void CloudPrintSigninDelegate::GetDialogSize(gfx::Size* size) const { |
| 155 PrefService* pref_service = | 163 PrefService* pref_service = |
| 156 BrowserList::GetLastActive()->GetProfile()->GetPrefs(); | 164 BrowserList::GetLastActive()->GetProfile()->GetPrefs(); |
| 157 if (!pref_service->FindPreference(prefs::kCloudPrintSigninDialogWidth)) { | 165 if (!pref_service->FindPreference(prefs::kCloudPrintSigninDialogWidth)) { |
| 158 pref_service->RegisterIntegerPref(prefs::kCloudPrintSigninDialogWidth, | 166 pref_service->RegisterIntegerPref(prefs::kCloudPrintSigninDialogWidth, |
| 159 800, | 167 912, |
|
James Hawkins
2012/01/11 17:25:54
Move these into constants, but more likely refacto
| |
| 160 PrefService::UNSYNCABLE_PREF); | 168 PrefService::UNSYNCABLE_PREF); |
| 161 } | 169 } |
| 162 if (!pref_service->FindPreference(prefs::kCloudPrintSigninDialogHeight)) { | 170 if (!pref_service->FindPreference(prefs::kCloudPrintSigninDialogHeight)) { |
| 163 pref_service->RegisterIntegerPref(prefs::kCloudPrintSigninDialogHeight, | 171 pref_service->RegisterIntegerPref(prefs::kCloudPrintSigninDialogHeight, |
| 164 600, | 172 633, |
| 165 PrefService::UNSYNCABLE_PREF); | 173 PrefService::UNSYNCABLE_PREF); |
| 166 } | 174 } |
| 167 | 175 |
| 168 size->set_width( | 176 size->set_width( |
| 169 pref_service->GetInteger(prefs::kCloudPrintSigninDialogWidth)); | 177 pref_service->GetInteger(prefs::kCloudPrintSigninDialogWidth)); |
| 170 size->set_height( | 178 size->set_height( |
| 171 pref_service->GetInteger(prefs::kCloudPrintSigninDialogHeight)); | 179 pref_service->GetInteger(prefs::kCloudPrintSigninDialogHeight)); |
| 172 } | 180 } |
| 173 | 181 |
| 174 std::string CloudPrintSigninDelegate::GetDialogArgs() const { | 182 std::string CloudPrintSigninDelegate::GetDialogArgs() const { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 191 void CreateCloudPrintSigninDialogImpl(int render_process_id, | 199 void CreateCloudPrintSigninDialogImpl(int render_process_id, |
| 192 int render_view_id) { | 200 int render_view_id) { |
| 193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 194 | 202 |
| 195 WebContents* parent_tab = | 203 WebContents* parent_tab = |
| 196 tab_util::GetWebContentsByID(render_process_id, render_view_id); | 204 tab_util::GetWebContentsByID(render_process_id, render_view_id); |
| 197 if (!parent_tab) | 205 if (!parent_tab) |
| 198 return; | 206 return; |
| 199 HtmlDialogUIDelegate* dialog_delegate = | 207 HtmlDialogUIDelegate* dialog_delegate = |
| 200 new CloudPrintSigninDelegate(parent_tab); | 208 new CloudPrintSigninDelegate(parent_tab); |
| 201 BrowserList::GetLastActive()->BrowserShowHtmlDialog(dialog_delegate, | 209 Browser* browser = BrowserList::GetLastActive(); |
| 202 NULL, | 210 #if defined(USE_AURA) |
| 203 STYLE_GENERIC); | 211 HtmlDialogView* html_view = |
|
James Hawkins
2012/01/11 17:25:54
This is the same code as the last file, no? Needs
| |
| 212 new HtmlDialogView(browser->GetProfile(), dialog_delegate); | |
| 213 views::Widget::CreateWindowWithParent(html_view, | |
| 214 browser->window()->GetNativeHandle()); | |
| 215 html_view->InitDialog(); | |
| 216 html_view->GetWidget()->Show(); | |
| 217 #else | |
| 218 browser->BrowserShowHtmlDialog(dialog_delegate, NULL, STYLE_GENERIC); | |
| 219 #endif | |
| 204 } | 220 } |
| 205 | 221 |
| 206 void CreateCloudPrintSigninDialog(WebContents* parent_tab) { | 222 void CreateCloudPrintSigninDialog(WebContents* parent_tab) { |
| 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 208 | 224 |
| 209 BrowserThread::PostTask( | 225 BrowserThread::PostTask( |
| 210 BrowserThread::UI, FROM_HERE, | 226 BrowserThread::UI, FROM_HERE, |
| 211 base::Bind(&CreateCloudPrintSigninDialogImpl, | 227 base::Bind(&CreateCloudPrintSigninDialogImpl, |
| 212 parent_tab->GetRenderProcessHost()->GetID(), | 228 parent_tab->GetRenderProcessHost()->GetID(), |
| 213 parent_tab->GetRenderViewHost()->routing_id())); | 229 parent_tab->GetRenderViewHost()->routing_id())); |
| 214 } | 230 } |
| 215 } // namespace cloud_print_signin_dialog | 231 } // namespace cloud_print_signin_dialog |
| OLD | NEW |