diff options
23 files changed, 109 insertions, 29 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index b9765de..5078f0b 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5260,11 +5260,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Something went wrong when trying to print. Please check your printer and try again. </message> - <!-- Cloud Print dialog messages --> - <message name="IDS_CLOUD_PRINT_TITLE" desc="Title for the print dialog"> - Print - </message> - <!-- Cloud Print proxy strings --> <message name="IDS_CLOUD_PRINT_SETUP_DIALOG_TITLE" desc="Title of the cloud print setup dialog."> Set up <ph name="CLOUD_PRINT_NAME">Google Cloud Print</ph> diff --git a/chrome/browser/browser_signin.cc b/chrome/browser/browser_signin.cc index 3b78e9b..0c5dc69 100644 --- a/chrome/browser/browser_signin.cc +++ b/chrome/browser/browser_signin.cc @@ -110,6 +110,7 @@ class BrowserSigninHtml : public HtmlDialogUIDelegate, } virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { } + virtual bool ShouldShowDialogTitle() const { return true; } // DOMMessageHandler implementation. virtual void RegisterMessages(); diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc index 76d4756..a044306 100644 --- a/chrome/browser/chrome_plugin_host.cc +++ b/chrome/browser/chrome_plugin_host.cc @@ -327,6 +327,7 @@ class ModelessHtmlDialogDelegate : public HtmlDialogUIDelegate { this, &ModelessHtmlDialogDelegate::ReportResults, json_retval)); } virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { } + virtual bool ShouldShowDialogTitle() const { return true; } private: // Actually shows the dialog on the UI thread. diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.cc b/chrome/browser/chromeos/frame/bubble_frame_view.cc index e8caded..becfb78 100644 --- a/chrome/browser/chromeos/frame/bubble_frame_view.cc +++ b/chrome/browser/chromeos/frame/bubble_frame_view.cc @@ -38,10 +38,12 @@ BubbleFrameView::BubbleFrameView(views::Window* frame, close_button_(NULL) { set_border(new BubbleBorder(BubbleBorder::NONE)); - title_ = new views::Label(frame_->GetDelegate()->GetWindowTitle()); - title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - title_->SetFont(title_->font().DeriveFont(1, gfx::Font::BOLD)); - AddChildView(title_); + if (frame_->GetDelegate()->ShouldShowWindowTitle()) { + title_ = new views::Label(frame_->GetDelegate()->GetWindowTitle()); + title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); + title_->SetFont(title_->font().DeriveFont(1, gfx::Font::BOLD)); + AddChildView(title_); + } if (style_ & BubbleWindow::STYLE_XBAR) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -66,16 +68,20 @@ gfx::Rect BubbleFrameView::GetBoundsForClientView() const { gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { gfx::Insets insets = GetInsets(); - gfx::Size title_size = title_->GetPreferredSize(); + gfx::Size title_size; + if (title_) { + title_size = title_->GetPreferredSize(); + } gfx::Size close_button_size = gfx::Size(); if (close_button_) { close_button_size = close_button_->GetPreferredSize(); } - int top_height = insets.top() + - std::max(title_size.height(), close_button_size.height()) + - kTitleContentPadding; + int top_height = insets.top(); + if (title_size.height() > 0 || close_button_size.height() > 0) + top_height += std::max(title_size.height(), close_button_size.height()) + + kTitleContentPadding; return gfx::Rect(std::max(0, client_bounds.x() - insets.left()), std::max(0, client_bounds.y() - top_height), client_bounds.width() + insets.width(), @@ -118,27 +124,33 @@ gfx::Size BubbleFrameView::GetPreferredSize() { void BubbleFrameView::Layout() { gfx::Insets insets = GetInsets(); - gfx::Size title_size = title_->GetPreferredSize(); + gfx::Size title_size; + if (title_) { + title_size = title_->GetPreferredSize(); + } gfx::Size close_button_size = gfx::Size(); if (close_button_) { close_button_size = close_button_->GetPreferredSize(); } - title_->SetBounds( - insets.left(), insets.top(), - std::max(0, width() - insets.width() - close_button_size.width()), - title_size.height()); + if (title_) { + title_->SetBounds( + insets.left(), insets.top(), + std::max(0, width() - insets.width() - close_button_size.width()), + title_size.height()); + } if (close_button_) { close_button_->SetBounds( - width() - insets.right() - close_button_size.width(), insets.top(), + width() - insets.right() - close_button_size.width(), insets.top(), close_button_size.width(), close_button_size.height()); } - int top_height = insets.top() + - std::max(title_size.height(), close_button_size.height()) + - kTitleContentPadding; + int top_height = insets.top(); + if (title_size.height() > 0 || close_button_size.height() > 0) + top_height += std::max(title_size.height(), close_button_size.height()) + + kTitleContentPadding; client_view_bounds_.SetRect(insets.left(), top_height, std::max(0, width() - insets.width()), std::max(0, height() - top_height - insets.bottom())); diff --git a/chrome/browser/chromeos/login/login_html_dialog.h b/chrome/browser/chromeos/login/login_html_dialog.h index 9bb4ee6..45f4d88 100644 --- a/chrome/browser/chromeos/login/login_html_dialog.h +++ b/chrome/browser/chromeos/login/login_html_dialog.h @@ -57,6 +57,7 @@ class LoginHtmlDialog : public HtmlDialogUIDelegate { virtual std::string GetDialogArgs() const { return std::string(); } virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); + virtual bool ShouldShowDialogTitle() const { return true; } private: // Notifications receiver. diff --git a/chrome/browser/cocoa/html_dialog_window_controller.mm b/chrome/browser/cocoa/html_dialog_window_controller.mm index b959798..aed0d83 100644 --- a/chrome/browser/cocoa/html_dialog_window_controller.mm +++ b/chrome/browser/cocoa/html_dialog_window_controller.mm @@ -44,6 +44,7 @@ public: virtual std::string GetDialogArgs() const; virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { } + virtual bool ShouldShowDialogTitle() const { return true; } // HtmlDialogTabContentsDelegate declarations. virtual void MoveContents(TabContents* source, const gfx::Rect& pos); diff --git a/chrome/browser/cocoa/html_dialog_window_controller_unittest.mm b/chrome/browser/cocoa/html_dialog_window_controller_unittest.mm index b6eae68..c8cdfb7 100644 --- a/chrome/browser/cocoa/html_dialog_window_controller_unittest.mm +++ b/chrome/browser/cocoa/html_dialog_window_controller_unittest.mm @@ -35,6 +35,7 @@ public: MOCK_METHOD1(OnDialogClosed, void(const std::string& json_retval)); MOCK_METHOD2(OnCloseContents, void(TabContents* source, bool* out_close_dialog)); + MOCK_CONST_METHOD0(ShouldShowDialogTitle, bool()); }; class HtmlDialogWindowControllerTest : public BrowserWithTestWindowTest { diff --git a/chrome/browser/dom_ui/constrained_html_ui_browsertest.cc b/chrome/browser/dom_ui/constrained_html_ui_browsertest.cc index cc21bfa..a1cd300 100644 --- a/chrome/browser/dom_ui/constrained_html_ui_browsertest.cc +++ b/chrome/browser/dom_ui/constrained_html_ui_browsertest.cc @@ -50,6 +50,7 @@ class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { if (out_close_dialog) *out_close_dialog = true; } + virtual bool ShouldShowDialogTitle() const { return true; } }; } // namespace diff --git a/chrome/browser/dom_ui/html_dialog_ui.h b/chrome/browser/dom_ui/html_dialog_ui.h index 38673c4..d1cc849 100644 --- a/chrome/browser/dom_ui/html_dialog_ui.h +++ b/chrome/browser/dom_ui/html_dialog_ui.h @@ -51,6 +51,10 @@ class HtmlDialogUIDelegate { // is set to true, then the dialog is closed. The default is false. virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) = 0; + // A callback to allow the delegate to dictate that the window should not + // have a title bar. This is useful when presenting branded interfaces. + virtual bool ShouldShowDialogTitle() const = 0; + protected: virtual ~HtmlDialogUIDelegate() {} }; diff --git a/chrome/browser/gtk/html_dialog_gtk.h b/chrome/browser/gtk/html_dialog_gtk.h index c004624..aba28f2 100644 --- a/chrome/browser/gtk/html_dialog_gtk.h +++ b/chrome/browser/gtk/html_dialog_gtk.h @@ -46,6 +46,7 @@ class HtmlDialogGtk : public HtmlDialogTabContentsDelegate, virtual std::string GetDialogArgs() const; virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { } + virtual bool ShouldShowDialogTitle() const { return true; } // Overridden from TabContentsDelegate: virtual void MoveContents(TabContents* source, const gfx::Rect& pos); diff --git a/chrome/browser/modal_html_dialog_delegate.h b/chrome/browser/modal_html_dialog_delegate.h index 54809ba..23bb0f7 100644 --- a/chrome/browser/modal_html_dialog_delegate.h +++ b/chrome/browser/modal_html_dialog_delegate.h @@ -47,6 +47,7 @@ class ModalHtmlDialogDelegate virtual std::string GetDialogArgs() const; virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { } + virtual bool ShouldShowDialogTitle() const { return true; } private: NotificationRegistrar registrar_; diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.h b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.h index d79e578..c6f71ea 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.h +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.h @@ -70,6 +70,7 @@ class CloudPrintSetupFlow : public HtmlDialogUIDelegate, virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); virtual std::wstring GetDialogTitle() const; virtual bool IsDialogModal() const; + virtual bool ShouldShowDialogTitle() const { return true; } // GaiaAuthConsumer implementation. virtual void OnClientLoginFailure( diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index 89b750c..1af016e 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -15,14 +15,17 @@ #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/dom_ui/dom_ui.h" #include "chrome/browser/dom_ui/dom_ui_util.h" -#include "chrome/browser/dom_ui/html_dialog_ui.h" +#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/printing/cloud_print/cloud_print_url.h" +#include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_source.h" #include "chrome/common/notification_type.h" +#include "chrome/common/pref_names.h" #include "chrome/common/render_messages_params.h" #include "chrome/common/url_constants.h" #include "webkit/glue/webpreferences.h" @@ -92,7 +95,6 @@ // high-level flow (where the PDF data is generated before even // bringing up the dialog) isn't what we want. - namespace internal_cloud_print_helpers { bool GetRealOrInt(const DictionaryValue& dictionary, @@ -245,7 +247,6 @@ void CloudPrintFlowHandler::CancelAnyRunningTask() { } } - void CloudPrintFlowHandler::RegisterMessages() { if (!dom_ui_) return; @@ -378,6 +379,16 @@ void CloudPrintFlowHandler::HandleSetPageParameters(const ListValue* args) { // that point. } +void CloudPrintFlowHandler::StoreDialogClientSize() const { + if (dom_ui_ && dom_ui_->tab_contents() && dom_ui_->tab_contents()->view()) { + gfx::Size size = dom_ui_->tab_contents()->view()->GetContainerSize(); + dom_ui_->GetProfile()->GetPrefs()->SetInteger( + prefs::kCloudPrintDialogWidth, size.width()); + dom_ui_->GetProfile()->GetPrefs()->SetInteger( + prefs::kCloudPrintDialogHeight, size.height()); + } +} + CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate( const FilePath& path_to_pdf, int width, int height, @@ -452,6 +463,8 @@ std::string CloudPrintHtmlDialogDelegate::GetDialogArgs() const { void CloudPrintHtmlDialogDelegate::OnDialogClosed( const std::string& json_retval) { + // Get the final dialog size and store it. + flow_handler_->StoreDialogClientSize(); delete this; } @@ -461,6 +474,10 @@ void CloudPrintHtmlDialogDelegate::OnCloseContents(TabContents* source, *out_close_dialog = true; } +bool CloudPrintHtmlDialogDelegate::ShouldShowDialogTitle() const { + return false; +} + } // end of namespace internal_cloud_print_helpers // static, called on the IO thread. This is the main entry point into @@ -493,11 +510,25 @@ PrintDialogCloud::PrintDialogCloud(const FilePath& path_to_pdf) if (browser_ && browser_->GetSelectedTabContents()) print_job_title = browser_->GetSelectedTabContents()->GetTitle(); - // TODO(scottbyer): Get the dialog width, height from the dialog - // contents, and take the screen size into account. + const int kDefaultWidth = 497; + const int kDefaultHeight = 332; + + PrefService* pref_service = browser_->GetProfile()->GetPrefs(); + DCHECK(pref_service); + if (!pref_service->FindPreference(prefs::kCloudPrintDialogWidth)) { + pref_service->RegisterIntegerPref(prefs::kCloudPrintDialogWidth, + kDefaultWidth); + } + if (!pref_service->FindPreference(prefs::kCloudPrintDialogHeight)) { + pref_service->RegisterIntegerPref(prefs::kCloudPrintDialogHeight, + kDefaultHeight); + } + + int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth); + int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight); HtmlDialogUIDelegate* dialog_delegate = new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate( - path_to_pdf, 497, 354, std::string(), print_job_title); + path_to_pdf, width, height, std::string(), print_job_title); browser_->BrowserShowHtmlDialog(dialog_delegate, NULL); } diff --git a/chrome/browser/printing/print_dialog_cloud_internal.h b/chrome/browser/printing/print_dialog_cloud_internal.h index 4148623..9c83154 100644 --- a/chrome/browser/printing/print_dialog_cloud_internal.h +++ b/chrome/browser/printing/print_dialog_cloud_internal.h @@ -114,6 +114,7 @@ class CloudPrintFlowHandler : public DOMMessageHandler, virtual void SetDialogDelegate(CloudPrintHtmlDialogDelegate *delegate); void CancelAnyRunningTask(); + void StoreDialogClientSize() const; private: // For unit testing. @@ -150,6 +151,7 @@ class CloudPrintHtmlDialogDelegate : public HtmlDialogUIDelegate { virtual std::string GetDialogArgs() const; virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); + virtual bool ShouldShowDialogTitle() const; private: friend class ::CloudPrintHtmlDialogDelegateTest; diff --git a/chrome/browser/remoting/remoting_setup_flow.cc b/chrome/browser/remoting/remoting_setup_flow.cc index f5b59379..fc50e8d 100644 --- a/chrome/browser/remoting/remoting_setup_flow.cc +++ b/chrome/browser/remoting/remoting_setup_flow.cc @@ -172,6 +172,10 @@ bool RemotingSetupFlow::IsDialogModal() const { return true; } +bool RemotingSetupFlow::ShouldShowDialogTitle() const { + return true; +} + /////////////////////////////////////////////////////////////////////////////// // GaiaAuthConsumer implementation. void RemotingSetupFlow::OnClientLoginFailure( diff --git a/chrome/browser/remoting/remoting_setup_flow.h b/chrome/browser/remoting/remoting_setup_flow.h index 05ec5da..c2e88f8 100644 --- a/chrome/browser/remoting/remoting_setup_flow.h +++ b/chrome/browser/remoting/remoting_setup_flow.h @@ -62,6 +62,7 @@ class RemotingSetupFlow : public HtmlDialogUIDelegate, virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); virtual std::wstring GetDialogTitle() const; virtual bool IsDialogModal() const; + virtual bool ShouldShowDialogTitle() const; // GaiaAuthConsumer implementation. virtual void OnClientLoginFailure( diff --git a/chrome/browser/sync/sync_setup_flow.h b/chrome/browser/sync/sync_setup_flow.h index 2879146..4b4b034 100644 --- a/chrome/browser/sync/sync_setup_flow.h +++ b/chrome/browser/sync/sync_setup_flow.h @@ -106,6 +106,7 @@ class SyncSetupFlow : public HtmlDialogUIDelegate { virtual bool IsDialogModal() const { return false; } + virtual bool ShouldShowDialogTitle() const { return true; } void OnUserSubmittedAuth(const std::string& username, const std::string& password, diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc index 7d12d78..f28e609 100644 --- a/chrome/browser/views/html_dialog_view.cc +++ b/chrome/browser/views/html_dialog_view.cc @@ -98,6 +98,10 @@ views::View* HtmlDialogView::GetInitiallyFocusedView() { return this; } +bool HtmlDialogView::ShouldShowWindowTitle() const { + return ShouldShowDialogTitle(); +} + //////////////////////////////////////////////////////////////////////////////// // HtmlDialogUIDelegate implementation: @@ -150,6 +154,13 @@ void HtmlDialogView::OnCloseContents(TabContents* source, delegate_->OnCloseContents(source, out_close_dialog); } +bool HtmlDialogView::ShouldShowDialogTitle() const { + if (delegate_) + return delegate_->ShouldShowDialogTitle(); + else + return true; +} + //////////////////////////////////////////////////////////////////////////////// // TabContentsDelegate implementation: diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h index 9c05291..1d42b6f 100644 --- a/chrome/browser/views/html_dialog_view.h +++ b/chrome/browser/views/html_dialog_view.h @@ -55,6 +55,7 @@ class HtmlDialogView virtual void WindowClosing(); virtual views::View* GetContentsView(); virtual views::View* GetInitiallyFocusedView(); + virtual bool ShouldShowWindowTitle() const; // Overridden from HtmlDialogUIDelegate: virtual bool IsDialogModal() const; @@ -66,6 +67,7 @@ class HtmlDialogView virtual std::string GetDialogArgs() const; virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); + virtual bool ShouldShowDialogTitle() const; // Overridden from TabContentsDelegate: virtual void MoveContents(TabContents* source, const gfx::Rect& pos); diff --git a/chrome/browser/views/html_dialog_view_browsertest.cc b/chrome/browser/views/html_dialog_view_browsertest.cc index bbcc6a0..a2bcd35 100644 --- a/chrome/browser/views/html_dialog_view_browsertest.cc +++ b/chrome/browser/views/html_dialog_view_browsertest.cc @@ -58,6 +58,7 @@ class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { if (out_close_dialog) *out_close_dialog = true; } + virtual bool ShouldShowDialogTitle() const { return true; } }; } // namespace diff --git a/chrome/browser/views/select_file_dialog.cc b/chrome/browser/views/select_file_dialog.cc index 9b9c2ef..da8427c 100644 --- a/chrome/browser/views/select_file_dialog.cc +++ b/chrome/browser/views/select_file_dialog.cc @@ -115,6 +115,7 @@ class SelectFileDialogImpl : public SelectFileDialog { virtual void OnDialogClosed(const std::string& json_retval); virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { } + virtual bool ShouldShowDialogTitle() const { return true; } DISALLOW_COPY_AND_ASSIGN(FileBrowseDelegate); }; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index c29e137..8e34a8f 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1018,6 +1018,10 @@ const char kLoginDatabaseMigrated[] = "login_database.migrated"; // The root URL of the cloud print service. const char kCloudPrintServiceURL[] = "cloud_print.service_url"; +// The last requested size of the dialog as it was closed. +const char kCloudPrintDialogWidth[] = "cloud_print.dialog_size.width"; +const char kCloudPrintDialogHeight[] = "cloud_print.dialog_size.height"; + const char kRemotingHasSetupCompleted[] = "remoting.has_setup_completed"; // The list of BackgroundContents that should be loaded when the browser diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index bc82008..5799ec0 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -376,8 +376,10 @@ extern const char kGeolocationContentSettings[]; extern const char kLoginDatabaseMigrated[]; -extern const char kCloudPrintProxyEnabled[]; extern const char kCloudPrintServiceURL[]; +extern const char kCloudPrintDialogWidth[]; +extern const char kCloudPrintDialogHeight[]; +extern const char kCloudPrintProxyEnabled[]; extern const char kCloudPrintProxyId[]; extern const char kCloudPrintAuthToken[]; extern const char kCloudPrintXMPPAuthToken[]; |