| 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> |
| 8 #include <vector> |
| 9 |
| 7 #include "base/bind.h" | 10 #include "base/bind.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 12 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
| 16 #include "chrome/browser/ui/webui/print_preview_ui.h" |
| 13 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 17 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 14 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 16 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" |
| 17 #include "content/browser/tab_contents/navigation_controller.h" | 21 #include "content/browser/tab_contents/navigation_controller.h" |
| 18 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "content/browser/tab_contents/tab_contents_view.h" | 23 #include "content/browser/tab_contents/tab_contents_view.h" |
| 20 #include "content/common/content_notification_types.h" | 24 #include "content/common/content_notification_types.h" |
| 21 #include "content/common/notification_registrar.h" | 25 #include "content/common/notification_registrar.h" |
| 22 #include "content/common/notification_source.h" | 26 #include "content/common/notification_source.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 const NotificationDetails& details) { | 73 const NotificationDetails& details) { |
| 70 if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { | 74 if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { |
| 71 GURL url = web_ui_->tab_contents()->GetURL(); | 75 GURL url = web_ui_->tab_contents()->GetURL(); |
| 72 GURL dialog_url = CloudPrintURL( | 76 GURL dialog_url = CloudPrintURL( |
| 73 Profile::FromWebUI(web_ui_)).GetCloudPrintServiceURL(); | 77 Profile::FromWebUI(web_ui_)).GetCloudPrintServiceURL(); |
| 74 if (url.host() == dialog_url.host() && | 78 if (url.host() == dialog_url.host() && |
| 75 url.path() == dialog_url.path() && | 79 url.path() == dialog_url.path() && |
| 76 url.scheme() == dialog_url.scheme()) { | 80 url.scheme() == dialog_url.scheme()) { |
| 77 StoreDialogSize(); | 81 StoreDialogSize(); |
| 78 web_ui_->tab_contents()->render_view_host()->ClosePage(); | 82 web_ui_->tab_contents()->render_view_host()->ClosePage(); |
| 79 parent_tab_->controller().Reload(false); | 83 static_cast<PrintPreviewUI*>( |
| 84 parent_tab_->web_ui())->OnReloadCloudPrintersList(); |
| 80 } | 85 } |
| 81 } | 86 } |
| 82 } | 87 } |
| 83 | 88 |
| 84 void CloudPrintSigninFlowHandler::StoreDialogSize() { | 89 void CloudPrintSigninFlowHandler::StoreDialogSize() { |
| 85 if (web_ui_ && web_ui_->tab_contents() && web_ui_->tab_contents()->view()) { | 90 if (web_ui_ && web_ui_->tab_contents() && web_ui_->tab_contents()->view()) { |
| 86 gfx::Size size = web_ui_->tab_contents()->view()->GetContainerSize(); | 91 gfx::Size size = web_ui_->tab_contents()->view()->GetContainerSize(); |
| 87 Profile* profile = Profile::FromWebUI(web_ui_); | 92 Profile* profile = Profile::FromWebUI(web_ui_); |
| 88 profile->GetPrefs()->SetInteger(prefs::kCloudPrintSigninDialogWidth, | 93 profile->GetPrefs()->SetInteger(prefs::kCloudPrintSigninDialogWidth, |
| 89 size.width()); | 94 size.width()); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 182 } |
| 178 | 183 |
| 179 void CreateCloudPrintSigninDialog(TabContents* parent_tab) { | 184 void CreateCloudPrintSigninDialog(TabContents* parent_tab) { |
| 180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 181 | 186 |
| 182 BrowserThread::PostTask( | 187 BrowserThread::PostTask( |
| 183 BrowserThread::UI, FROM_HERE, | 188 BrowserThread::UI, FROM_HERE, |
| 184 base::Bind(&CreateCloudPrintSigninDialogImpl, parent_tab)); | 189 base::Bind(&CreateCloudPrintSigninDialogImpl, parent_tab)); |
| 185 } | 190 } |
| 186 } // namespace cloud_print_signin_dialog | 191 } // namespace cloud_print_signin_dialog |
| 187 | |
| OLD | NEW |