diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 21:56:55 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 21:56:55 +0000 |
commit | 5835871a6f47c28ff022c9284e2aa1f0d1761ab3 (patch) | |
tree | 52eba6e7556400aa0b519216907844110bc8ce8a /chrome/browser/ui | |
parent | bc6d23dc0d55aeda0be5ae9d799046ff6a43db14 (diff) | |
download | chromium_src-5835871a6f47c28ff022c9284e2aa1f0d1761ab3.zip chromium_src-5835871a6f47c28ff022c9284e2aa1f0d1761ab3.tar.gz chromium_src-5835871a6f47c28ff022c9284e2aa1f0d1761ab3.tar.bz2 |
Web-ify a bunch of these names. I am going to move some of the framework code here down to ui/web_dialogs in a future cl, hence the namespaces.
HtmlDialogUI->WebDialogUI
HtmlDialogUIDelegate->WebDialogDelegate
HtmlDialogTabContentsDelegate->WebDialogWebContentsDelegate
HtmlDialogView->WebDialogView
HtmlDialogController->WebDialogController
HtmlDialogGtk -> WebDialogGtk
BUG=none
TEST=none
TBR=sky
Review URL: https://chromiumcodereview.appspot.com/10214001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
54 files changed, 909 insertions, 885 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 798c5b4..b7dce022 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -1460,18 +1460,18 @@ void Browser::CloseTabContents(WebContents* contents) { CloseContents(contents); } -gfx::NativeWindow Browser::BrowserShowHtmlDialog( - HtmlDialogUIDelegate* delegate, +gfx::NativeWindow Browser::BrowserShowWebDialog( + WebDialogDelegate* delegate, gfx::NativeWindow parent_window, DialogStyle style) { if (!parent_window) parent_window = window_->GetNativeHandle(); - return browser::ShowHtmlDialog(parent_window, - profile_, - this, - delegate, - style); + return browser::ShowWebDialog(parent_window, + profile_, + this, + delegate, + style); } void Browser::BrowserRenderWidgetShowing() { @@ -2108,7 +2108,7 @@ void Browser::OpenTaskManager(bool highlight_background_resources) { void Browser::OpenFeedbackDialog() { content::RecordAction(UserMetricsAction("Feedback")); - browser::ShowHtmlFeedbackView(this, std::string(), std::string()); + browser::ShowWebFeedbackView(this, std::string(), std::string()); } void Browser::ToggleBookmarkBar() { diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index ad5abf1..0eaa194 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -62,7 +62,6 @@ class Extension; class ExtensionWindowController; class FindBarController; class FullscreenController; -class HtmlDialogUIDelegate; class InstantController; class InstantUnloadHandler; class PrefService; @@ -72,6 +71,7 @@ class StatusBubble; class TabNavigation; class TabStripModel; struct WebApplicationInfo; +class WebDialogDelegate; namespace content { class NavigationController; @@ -495,9 +495,10 @@ class Browser : public TabHandlerDelegate, // only have STYLE_GENERIC now. // TODO(bshe): Implementing styles not related to window decoration in other // platforms for consistency if necessary. - gfx::NativeWindow BrowserShowHtmlDialog(HtmlDialogUIDelegate* delegate, - gfx::NativeWindow parent_window, - DialogStyle style); + gfx::NativeWindow BrowserShowWebDialog( + WebDialogDelegate* delegate, + gfx::NativeWindow parent_window, + DialogStyle style); // Called when a popup select is about to be displayed. void BrowserRenderWidgetShowing(); diff --git a/chrome/browser/ui/browser_dialogs.h b/chrome/browser/ui/browser_dialogs.h index 1f47e87..4ea6606 100644 --- a/chrome/browser/ui/browser_dialogs.h +++ b/chrome/browser/ui/browser_dialogs.h @@ -12,12 +12,12 @@ class Browser; class Extension; -class HtmlDialogUIDelegate; class Profile; class SkBitmap; class TabContentsWrapper; class TabModalConfirmDialogDelegate; class TemplateURL; +class WebDialogDelegate; namespace content { class WebContents; @@ -42,11 +42,11 @@ void ShowAboutIPCDialog(); // // Make sure to use the returned window only when you know it is safe // to do so, i.e. before OnDialogClosed() is called on the delegate. -gfx::NativeWindow ShowHtmlDialog(gfx::NativeWindow parent, - Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate, - DialogStyle style); +gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, + Profile* profile, + Browser* browser, + WebDialogDelegate* delegate, + DialogStyle style); // Closes the given dialog. void CloseHtmlDialog(gfx::NativeWindow window); diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm index 2e9ec16..7623fce 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm @@ -25,7 +25,7 @@ #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" -#import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" +#import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" #import "chrome/browser/ui/cocoa/info_bubble_view.h" #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" diff --git a/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm b/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm index cc20747..80300ca 100644 --- a/chrome/browser/ui/cocoa/constrained_html_delegate_mac.mm +++ b/chrome/browser/ui/cocoa/constrained_web_dialog_delegate_mac.mm @@ -2,40 +2,42 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" #import <Cocoa/Cocoa.h> #include "base/memory/scoped_nsobject.h" #include "chrome/browser/ui/cocoa/constrained_window_mac.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" #include "content/public/browser/web_contents.h" #include "ui/gfx/size.h" using content::WebContents; -class ConstrainedHtmlDelegateMac : +class ConstrainedWebDialogDelegateMac : public ConstrainedWindowMacDelegateCustomSheet, - public ConstrainedHtmlUIDelegate { + public ConstrainedWebDialogDelegate { public: - ConstrainedHtmlDelegateMac(Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate); - virtual ~ConstrainedHtmlDelegateMac() {} + ConstrainedWebDialogDelegateMac( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate); + virtual ~ConstrainedWebDialogDelegateMac() {} void set_window(ConstrainedWindow* window) { return impl_->set_window(window); } - // ConstrainedHtmlUIDelegate interface - virtual const HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() const OVERRIDE { - return impl_->GetHtmlDialogUIDelegate(); + // ConstrainedWebDialogDelegate interface + virtual const WebDialogDelegate* + GetWebDialogDelegate() const OVERRIDE { + return impl_->GetWebDialogDelegate(); } - virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() OVERRIDE { - return impl_->GetHtmlDialogUIDelegate(); + virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { + return impl_->GetWebDialogDelegate(); } virtual void OnDialogCloseFromWebUI() OVERRIDE { return impl_->OnDialogCloseFromWebUI(); @@ -57,34 +59,36 @@ class ConstrainedHtmlDelegateMac : if (is_sheet_open()) [NSApp endSheet:sheet()]; if (!impl_->closed_via_webui()) - GetHtmlDialogUIDelegate()->OnDialogClosed(""); + GetWebDialogDelegate()->OnDialogClosed(""); delete this; } private: - scoped_ptr<ConstrainedHtmlUIDelegateImpl> impl_; + scoped_ptr<ConstrainedWebDialogDelegateBase> impl_; - DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlDelegateMac); + DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateMac); }; // The delegate used to forward events from the sheet to the constrained // window delegate. This bridge needs to be passed into the customsheet -// to allow the HtmlDialog to know when the sheet closes. -@interface ConstrainedHtmlDialogSheetCocoa : NSObject { - ConstrainedHtmlDelegateMac* constrainedHtmlDelegate_; // weak +// to allow the WebDialog to know when the sheet closes. +@interface ConstrainedWebDialogSheetCocoa : NSObject { + ConstrainedWebDialogDelegateMac* constrainedWebDelegate_; // weak } -- (id)initWithConstrainedHtmlDelegateMac: - (ConstrainedHtmlDelegateMac*)ConstrainedHtmlDelegateMac; +- (id)initWithConstrainedWebDialogDelegateMac: + (ConstrainedWebDialogDelegateMac*)ConstrainedWebDialogDelegateMac; - (void)sheetDidEnd:(NSWindow*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo; @end -ConstrainedHtmlDelegateMac::ConstrainedHtmlDelegateMac( - Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate) - : impl_(new ConstrainedHtmlUIDelegateImpl(profile, delegate, tab_delegate)) { +ConstrainedWebDialogDelegateMac::ConstrainedWebDialogDelegateMac( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate) + : impl_(new ConstrainedWebDialogDelegateBase(profile, + delegate, + tab_delegate)) { // Create NSWindow to hold web_contents in the constrained sheet: gfx::Size size; delegate->GetDialogSize(&size); @@ -104,33 +108,35 @@ ConstrainedHtmlDelegateMac::ConstrainedHtmlDelegateMac( // Set the custom sheet to point to the new window. ConstrainedWindowMacDelegateCustomSheet::init( window.get(), - [[[ConstrainedHtmlDialogSheetCocoa alloc] - initWithConstrainedHtmlDelegateMac:this] autorelease], + [[[ConstrainedWebDialogSheetCocoa alloc] + initWithConstrainedWebDialogDelegateMac:this] autorelease], @selector(sheetDidEnd:returnCode:contextInfo:)); } // static -ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( - Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate, - TabContentsWrapper* wrapper) { - // Deleted when ConstrainedHtmlDelegateMac::DeleteDelegate() runs. - ConstrainedHtmlDelegateMac* constrained_delegate = - new ConstrainedHtmlDelegateMac(profile, delegate, tab_delegate); - // Deleted when ConstrainedHtmlDelegateMac::OnDialogCloseFromWebUI() runs. +ConstrainedWebDialogDelegate* + ConstrainedWebDialogUI::CreateConstrainedWebDialog( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate, + TabContentsWrapper* wrapper) { + // Deleted when ConstrainedWebDialogDelegateMac::DeleteDelegate() runs. + ConstrainedWebDialogDelegateMac* constrained_delegate = + new ConstrainedWebDialogDelegateMac(profile, delegate, tab_delegate); + // Deleted when ConstrainedWebDialogDelegateMac::OnDialogCloseFromWebUI() + // runs. ConstrainedWindow* constrained_window = new ConstrainedWindowMac(wrapper, constrained_delegate); constrained_delegate->set_window(constrained_window); return constrained_delegate; } -@implementation ConstrainedHtmlDialogSheetCocoa +@implementation ConstrainedWebDialogSheetCocoa -- (id)initWithConstrainedHtmlDelegateMac: - (ConstrainedHtmlDelegateMac*)ConstrainedHtmlDelegateMac { +- (id)initWithConstrainedWebDialogDelegateMac: + (ConstrainedWebDialogDelegateMac*)ConstrainedWebDialogDelegateMac { if ((self = [super init])) - constrainedHtmlDelegate_ = ConstrainedHtmlDelegateMac; + constrainedWebDelegate_ = ConstrainedWebDialogDelegateMac; return self; } diff --git a/chrome/browser/ui/cocoa/html_dialog_window_controller.h b/chrome/browser/ui/cocoa/web_dialog_window_controller.h index 93d0d83..92292c5 100644 --- a/chrome/browser/ui/cocoa/html_dialog_window_controller.h +++ b/chrome/browser/ui/cocoa/web_dialog_window_controller.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_COCOA_HTML_DIALOG_WINDOW_CONTROLLER_H_ -#define CHROME_BROWSER_UI_COCOA_HTML_DIALOG_WINDOW_CONTROLLER_H_ +#ifndef CHROME_BROWSER_UI_COCOA_WEB_DIALOG_WINDOW_CONTROLLER_H_ +#define CHROME_BROWSER_UI_COCOA_WEB_DIALOG_WINDOW_CONTROLLER_H_ #pragma once #import <Cocoa/Cocoa.h> @@ -11,41 +11,41 @@ #include "base/basictypes.h" #import "base/mac/cocoa_protocols.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" class Browser; -class HtmlDialogWindowDelegateBridge; +class WebDialogWindowDelegateBridge; class Profile; class TabContentsWrapper; // This controller manages a dialog box with properties and HTML content taken -// from a HTMLDialogUIDelegate object. -@interface HtmlDialogWindowController : NSWindowController<NSWindowDelegate> { +// from a WebDialogDelegate object. +@interface WebDialogWindowController : NSWindowController<NSWindowDelegate> { @private // Order here is important, as tab_contents_ may send messages to // delegate_ when it gets destroyed. - scoped_ptr<HtmlDialogWindowDelegateBridge> delegate_; + scoped_ptr<WebDialogWindowDelegateBridge> delegate_; scoped_ptr<TabContentsWrapper> contentsWrapper_; } -// Creates and shows an HtmlDialogWindowController with the given +// Creates and shows an WebDialogWindowController with the given // delegate and profile whose lifetime is controlled by the given // browser. The window is automatically destroyed when it, or its // controlling browser is closed. Returns the created window. // // Make sure to use the returned window only when you know it is safe // to do so, i.e. before OnDialogClosed() is called on the delegate. -+ (NSWindow*)showHtmlDialog:(HtmlDialogUIDelegate*)delegate - profile:(Profile*)profile - browser:(Browser*)browser; ++ (NSWindow*)showWebDialog:(WebDialogDelegate*)delegate + profile:(Profile*)profile + browser:(Browser*)browser; @end -@interface HtmlDialogWindowController (TestingAPI) +@interface WebDialogWindowController (TestingAPI) // This is the designated initializer. However, this is exposed only -// for testing; use showHtmlDialog instead. -- (id)initWithDelegate:(HtmlDialogUIDelegate*)delegate +// for testing; use showWebDialog instead. +- (id)initWithDelegate:(WebDialogDelegate*)delegate profile:(Profile*)profile browser:(Browser*)browser; @@ -56,5 +56,5 @@ class TabContentsWrapper; @end -#endif // CHROME_BROWSER_UI_COCOA_HTML_DIALOG_WINDOW_CONTROLLER_H_ +#endif // CHROME_BROWSER_UI_COCOA_WEB_DIALOG_WINDOW_CONTROLLER_H_ diff --git a/chrome/browser/ui/cocoa/html_dialog_window_controller.mm b/chrome/browser/ui/cocoa/web_dialog_window_controller.mm index a0b847b..0659ca9 100644 --- a/chrome/browser/ui/cocoa/html_dialog_window_controller.mm +++ b/chrome/browser/ui/cocoa/web_dialog_window_controller.mm @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" +#import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" #include "base/logging.h" #include "base/memory/scoped_nsobject.h" @@ -15,9 +15,9 @@ #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" #include "chrome/browser/ui/dialog_style.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/html_dialog_controller.h" -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_controller.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui_message_handler.h" @@ -28,23 +28,24 @@ using content::WebContents; using content::WebUIMessageHandler; // Thin bridge that routes notifications to -// HtmlDialogWindowController's member variables. -class HtmlDialogWindowDelegateBridge : public HtmlDialogUIDelegate, - public HtmlDialogTabContentsDelegate { +// WebDialogWindowController's member variables. +class WebDialogWindowDelegateBridge + : public WebDialogDelegate, + public WebDialogWebContentsDelegate { public: // All parameters must be non-NULL/non-nil. - HtmlDialogWindowDelegateBridge(HtmlDialogWindowController* controller, - Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate); + WebDialogWindowDelegateBridge(WebDialogWindowController* controller, + Profile* profile, + Browser* browser, + WebDialogDelegate* delegate); - virtual ~HtmlDialogWindowDelegateBridge(); + virtual ~WebDialogWindowDelegateBridge(); // Called when the window is directly closed, e.g. from the close // button or from an accelerator. void WindowControllerClosed(); - // HtmlDialogUIDelegate declarations. + // WebDialogDelegate declarations. virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -58,7 +59,7 @@ public: bool* out_close_dialog) OVERRIDE; virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; } - // HtmlDialogTabContentsDelegate declarations. + // WebDialogWebContentsDelegate declarations. virtual void MoveContents(WebContents* source, const gfx::Rect& pos); virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); virtual void CloseContents(WebContents* source) OVERRIDE; @@ -73,22 +74,21 @@ public: virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE; private: - HtmlDialogWindowController* controller_; // weak - HtmlDialogUIDelegate* delegate_; // weak, owned by controller_ - HtmlDialogController* dialog_controller_; - - // Calls delegate_'s OnDialogClosed() exactly once, nulling it out - // afterwards so that no other HtmlDialogUIDelegate calls are sent - // to it. Returns whether or not the OnDialogClosed() was actually - // called on the delegate. + WebDialogWindowController* controller_; // weak + WebDialogDelegate* delegate_; // weak, owned by controller_ + WebDialogController* dialog_controller_; + + // Calls delegate_'s OnDialogClosed() exactly once, nulling it out afterwards + // so that no other WebDialogDelegate calls are sent to it. Returns whether or + // not the OnDialogClosed() was actually called on the delegate. bool DelegateOnDialogClosed(const std::string& json_retval); - DISALLOW_COPY_AND_ASSIGN(HtmlDialogWindowDelegateBridge); + DISALLOW_COPY_AND_ASSIGN(WebDialogWindowDelegateBridge); }; // ChromeEventProcessingWindow expects its controller to implement the // BrowserCommandExecutor protocol. -@interface HtmlDialogWindowController (InternalAPI) <BrowserCommandExecutor> +@interface WebDialogWindowController (InternalAPI) <BrowserCommandExecutor> // BrowserCommandExecutor methods. - (void)executeCommand:(int)command; @@ -97,48 +97,48 @@ private: namespace browser { -gfx::NativeWindow ShowHtmlDialog(gfx::NativeWindow parent, - Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate, - DialogStyle style) { - return [HtmlDialogWindowController showHtmlDialog:delegate - profile:profile - browser:browser]; +gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, + Profile* profile, + Browser* browser, + WebDialogDelegate* delegate, + DialogStyle style) { + return [WebDialogWindowController showWebDialog:delegate + profile:profile + browser:browser]; } -void CloseHtmlDialog(gfx::NativeWindow window) { +void CloseWDialog(gfx::NativeWindow window) { [window performClose:nil]; } -} // namespace html_dialog_window_controller +} // namespace web_dialog_window_controller -HtmlDialogWindowDelegateBridge::HtmlDialogWindowDelegateBridge( - HtmlDialogWindowController* controller, +WebDialogWindowDelegateBridge::WebDialogWindowDelegateBridge( + WebDialogWindowController* controller, Profile* profile, Browser* browser, - HtmlDialogUIDelegate* delegate) - : HtmlDialogTabContentsDelegate(profile), + WebDialogDelegate* delegate) + : WebDialogWebContentsDelegate(profile), controller_(controller), delegate_(delegate), - dialog_controller_(new HtmlDialogController(this, profile, browser)) { + dialog_controller_(new WebDialogController(this, profile, browser)) { DCHECK(controller_); DCHECK(delegate_); } -HtmlDialogWindowDelegateBridge::~HtmlDialogWindowDelegateBridge() {} +WebDialogWindowDelegateBridge::~WebDialogWindowDelegateBridge() {} -void HtmlDialogWindowDelegateBridge::WindowControllerClosed() { +void WebDialogWindowDelegateBridge::WindowControllerClosed() { Detach(); delete dialog_controller_; controller_ = nil; DelegateOnDialogClosed(""); } -bool HtmlDialogWindowDelegateBridge::DelegateOnDialogClosed( +bool WebDialogWindowDelegateBridge::DelegateOnDialogClosed( const std::string& json_retval) { if (delegate_) { - HtmlDialogUIDelegate* real_delegate = delegate_; + WebDialogDelegate* real_delegate = delegate_; delegate_ = NULL; real_delegate->OnDialogClosed(json_retval); return true; @@ -146,28 +146,28 @@ bool HtmlDialogWindowDelegateBridge::DelegateOnDialogClosed( return false; } -// HtmlDialogUIDelegate definitions. +// WebDialogDelegate definitions. // All of these functions check for NULL first since delegate_ is set // to NULL when the window is closed. -ui::ModalType HtmlDialogWindowDelegateBridge::GetDialogModalType() const { +ui::ModalType WebDialogWindowDelegateBridge::GetDialogModalType() const { // TODO(akalin): Support modal dialog boxes. if (delegate_ && delegate_->GetDialogModalType() != ui::MODAL_TYPE_NONE) { - LOG(WARNING) << "Modal HTML dialogs are not supported yet"; + LOG(WARNING) << "Modal Web dialogs are not supported yet"; } return ui::MODAL_TYPE_NONE; } -string16 HtmlDialogWindowDelegateBridge::GetDialogTitle() const { +string16 WebDialogWindowDelegateBridge::GetDialogTitle() const { return delegate_ ? delegate_->GetDialogTitle() : string16(); } -GURL HtmlDialogWindowDelegateBridge::GetDialogContentURL() const { +GURL WebDialogWindowDelegateBridge::GetDialogContentURL() const { return delegate_ ? delegate_->GetDialogContentURL() : GURL(); } -void HtmlDialogWindowDelegateBridge::GetWebUIMessageHandlers( +void WebDialogWindowDelegateBridge::GetWebUIMessageHandlers( std::vector<WebUIMessageHandler*>* handlers) const { if (delegate_) { delegate_->GetWebUIMessageHandlers(handlers); @@ -179,14 +179,14 @@ void HtmlDialogWindowDelegateBridge::GetWebUIMessageHandlers( } } -void HtmlDialogWindowDelegateBridge::GetDialogSize(gfx::Size* size) const { +void WebDialogWindowDelegateBridge::GetDialogSize(gfx::Size* size) const { if (delegate_) delegate_->GetDialogSize(size); else *size = gfx::Size(); } -void HtmlDialogWindowDelegateBridge::GetMinimumDialogSize( +void WebDialogWindowDelegateBridge::GetMinimumDialogSize( gfx::Size* size) const { if (delegate_) delegate_->GetMinimumDialogSize(size); @@ -194,11 +194,11 @@ void HtmlDialogWindowDelegateBridge::GetMinimumDialogSize( *size = gfx::Size(); } -std::string HtmlDialogWindowDelegateBridge::GetDialogArgs() const { +std::string WebDialogWindowDelegateBridge::GetDialogArgs() const { return delegate_ ? delegate_->GetDialogArgs() : ""; } -void HtmlDialogWindowDelegateBridge::OnDialogClosed( +void WebDialogWindowDelegateBridge::OnDialogClosed( const std::string& json_retval) { Detach(); // [controller_ close] should be called at most once, too. @@ -208,20 +208,20 @@ void HtmlDialogWindowDelegateBridge::OnDialogClosed( controller_ = nil; } -void HtmlDialogWindowDelegateBridge::OnCloseContents(WebContents* source, - bool* out_close_dialog) { +void WebDialogWindowDelegateBridge::OnCloseContents(WebContents* source, + bool* out_close_dialog) { if (out_close_dialog) *out_close_dialog = true; } -void HtmlDialogWindowDelegateBridge::CloseContents(WebContents* source) { +void WebDialogWindowDelegateBridge::CloseContents(WebContents* source) { bool close_dialog = false; OnCloseContents(source, &close_dialog); if (close_dialog) OnDialogClosed(std::string()); } -content::WebContents* HtmlDialogWindowDelegateBridge::OpenURLFromTab( +content::WebContents* WebDialogWindowDelegateBridge::OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) { content::WebContents* new_contents = NULL; @@ -229,10 +229,10 @@ content::WebContents* HtmlDialogWindowDelegateBridge::OpenURLFromTab( delegate_->HandleOpenURLFromTab(source, params, &new_contents)) { return new_contents; } - return HtmlDialogTabContentsDelegate::OpenURLFromTab(source, params); + return WebDialogWebContentsDelegate::OpenURLFromTab(source, params); } -void HtmlDialogWindowDelegateBridge::AddNewContents( +void WebDialogWindowDelegateBridge::AddNewContents( content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, @@ -242,25 +242,25 @@ void HtmlDialogWindowDelegateBridge::AddNewContents( source, new_contents, disposition, initial_pos, user_gesture)) { return; } - HtmlDialogTabContentsDelegate::AddNewContents( + WebDialogWebContentsDelegate::AddNewContents( source, new_contents, disposition, initial_pos, user_gesture); } -void HtmlDialogWindowDelegateBridge::LoadingStateChanged( +void WebDialogWindowDelegateBridge::LoadingStateChanged( content::WebContents* source) { if (delegate_) delegate_->OnLoadingStateChanged(source); } -void HtmlDialogWindowDelegateBridge::MoveContents(WebContents* source, - const gfx::Rect& pos) { +void WebDialogWindowDelegateBridge::MoveContents(WebContents* source, + const gfx::Rect& pos) { // TODO(akalin): Actually set the window bounds. } // A simplified version of BrowserWindowCocoa::HandleKeyboardEvent(). // We don't handle global keyboard shortcuts here, but that's fine since // they're all browser-specific. (This may change in the future.) -void HtmlDialogWindowDelegateBridge::HandleKeyboardEvent( +void WebDialogWindowDelegateBridge::HandleKeyboardEvent( const NativeWebKeyboardEvent& event) { if (event.skip_in_browser || event.type == NativeWebKeyboardEvent::Char) return; @@ -290,32 +290,32 @@ void HtmlDialogWindowDelegateBridge::HandleKeyboardEvent( [event_window redispatchKeyEvent:event.os_event]; } -@implementation HtmlDialogWindowController (InternalAPI) +@implementation WebDialogWindowController (InternalAPI) // This gets called whenever a chrome-specific keyboard shortcut is performed -// in the HTML dialog window. We simply swallow all those events. +// in the Web dialog window. We simply swallow all those events. - (void)executeCommand:(int)command {} @end -@implementation HtmlDialogWindowController +@implementation WebDialogWindowController // NOTE(akalin): We'll probably have to add the parentWindow parameter back // in once we implement modal dialogs. -+ (NSWindow*)showHtmlDialog:(HtmlDialogUIDelegate*)delegate - profile:(Profile*)profile - browser:(Browser*)browser { - HtmlDialogWindowController* htmlDialogWindowController = - [[HtmlDialogWindowController alloc] initWithDelegate:delegate - profile:profile - browser:browser]; - [htmlDialogWindowController loadDialogContents]; - [htmlDialogWindowController showWindow:nil]; - return [htmlDialogWindowController window]; ++ (NSWindow*)showWebDialog:(WebDialogDelegate*)delegate + profile:(Profile*)profile + browser:(Browser*)browser { + WebDialogWindowController* webDialogWindowController = + [[WebDialogWindowController alloc] initWithDelegate:delegate + profile:profile + browser:browser]; + [webDialogWindowController loadDialogContents]; + [webDialogWindowController showWindow:nil]; + return [webDialogWindowController window]; } -- (id)initWithDelegate:(HtmlDialogUIDelegate*)delegate +- (id)initWithDelegate:(WebDialogDelegate*)delegate profile:(Profile*)profile browser:(Browser*)browser { DCHECK(delegate); @@ -345,7 +345,7 @@ void HtmlDialogWindowDelegateBridge::HandleKeyboardEvent( [window setMinSize:dialogRect.size]; [window center]; delegate_.reset( - new HtmlDialogWindowDelegateBridge(self, profile, browser, delegate)); + new WebDialogWindowDelegateBridge(self, profile, browser, delegate)); return self; } @@ -357,8 +357,8 @@ void HtmlDialogWindowDelegateBridge::HandleKeyboardEvent( contentsWrapper_->web_contents()->SetDelegate(delegate_.get()); // This must be done before loading the page; see the comments in - // HtmlDialogUI. - HtmlDialogUI::GetPropertyAccessor().SetProperty( + // WebDialogUI. + WebDialogUI::GetPropertyAccessor().SetProperty( contentsWrapper_->web_contents()->GetPropertyBag(), delegate_.get()); contentsWrapper_->web_contents()->GetController().LoadURL( diff --git a/chrome/browser/ui/cocoa/html_dialog_window_controller_unittest.mm b/chrome/browser/ui/cocoa/web_dialog_window_controller_unittest.mm index 80f3cdc..2e68567 100644 --- a/chrome/browser/ui/cocoa/html_dialog_window_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/web_dialog_window_controller_unittest.mm @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" +#import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" #include <string> #include <vector> @@ -14,7 +14,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/testing_profile.h" #include "content/public/browser/web_ui.h" @@ -29,7 +29,7 @@ using content::WebUIMessageHandler; namespace { -class MockDelegate : public HtmlDialogUIDelegate { +class MockDelegate : public WebDialogDelegate { public: MOCK_CONST_METHOD0(GetDialogModalType, ui::ModalType()); MOCK_CONST_METHOD0(GetDialogTitle, string16()); @@ -44,7 +44,7 @@ public: MOCK_CONST_METHOD0(ShouldShowDialogTitle, bool()); }; -class HtmlDialogWindowControllerTest : public BrowserWithTestWindowTest { +class WebDialogWindowControllerTest : public BrowserWithTestWindowTest { public: virtual void SetUp() { BrowserWithTestWindowTest::SetUp(); @@ -71,8 +71,8 @@ using ::testing::SetArgumentPointee; // In particular, GetWebUIMessageHandlers() and GetDialogArgs() are never // called. This should be fixed. -TEST_F(HtmlDialogWindowControllerTest, showDialog) { - // We want to make sure html_dialog_window_controller below gets +TEST_F(WebDialogWindowControllerTest, showDialog) { + // We want to make sure web_dialog_window_controller below gets // destroyed before delegate_, so we specify our own autorelease pool. // // TODO(dmaclach): Remove this once @@ -88,14 +88,14 @@ TEST_F(HtmlDialogWindowControllerTest, showDialog) { EXPECT_CALL(delegate_, OnDialogClosed(_)) .Times(1); - HtmlDialogWindowController* html_dialog_window_controller = - [[HtmlDialogWindowController alloc] initWithDelegate:&delegate_ - profile:profile() - browser:browser()]; + WebDialogWindowController* web_dialog_window_controller = + [[WebDialogWindowController alloc] initWithDelegate:&delegate_ + profile:profile() + browser:browser()]; - [html_dialog_window_controller loadDialogContents]; - [html_dialog_window_controller showWindow:nil]; - [html_dialog_window_controller close]; + [web_dialog_window_controller loadDialogContents]; + [web_dialog_window_controller showWindow:nil]; + [web_dialog_window_controller close]; } } // namespace diff --git a/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc b/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc index 2583630..5db681c 100644 --- a/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc +++ b/chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" #include "chrome/browser/ui/gtk/constrained_window_gtk.h" #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -16,25 +16,27 @@ using content::WebContents; -class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate, - public ConstrainedHtmlUIDelegate { +class ConstrainedWebDialogDelegateGtk : public ConstrainedWindowGtkDelegate, + public ConstrainedWebDialogDelegate { public: - ConstrainedHtmlDelegateGtk(Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate); + ConstrainedWebDialogDelegateGtk( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate); - virtual ~ConstrainedHtmlDelegateGtk() {} + virtual ~ConstrainedWebDialogDelegateGtk() {} void set_window(ConstrainedWindow* window) { return impl_->set_window(window); } - // ConstrainedHtmlUIDelegate interface - virtual const HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() const OVERRIDE { - return impl_->GetHtmlDialogUIDelegate(); + // ConstrainedWebDialogDelegate interface + virtual const WebDialogDelegate* + GetWebDialogDelegate() const OVERRIDE { + return impl_->GetWebDialogDelegate(); } - virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() OVERRIDE { - return impl_->GetHtmlDialogUIDelegate(); + virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { + return impl_->GetWebDialogDelegate(); } virtual void OnDialogCloseFromWebUI() OVERRIDE { return impl_->OnDialogCloseFromWebUI(); @@ -58,7 +60,7 @@ class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate, } virtual void DeleteDelegate() OVERRIDE { if (!impl_->closed_via_webui()) - GetHtmlDialogUIDelegate()->OnDialogClosed(""); + GetWebDialogDelegate()->OnDialogClosed(""); delete this; } virtual bool GetBackgroundColor(GdkColor* color) OVERRIDE { @@ -67,18 +69,18 @@ class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate, } private: - scoped_ptr<ConstrainedHtmlUIDelegateImpl> impl_; + scoped_ptr<ConstrainedWebDialogDelegateBase> impl_; TabContentsContainerGtk tab_contents_container_; - DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlDelegateGtk); + DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateGtk); }; -ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( +ConstrainedWebDialogDelegateGtk::ConstrainedWebDialogDelegateGtk( Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate) - : impl_(new ConstrainedHtmlUIDelegateImpl(profile, delegate, tab_delegate)), + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate) + : impl_(new ConstrainedWebDialogDelegateBase(profile, delegate, tab_delegate)), tab_contents_container_(NULL) { tab_contents_container_.SetTab(tab()); @@ -92,13 +94,14 @@ ConstrainedHtmlDelegateGtk::ConstrainedHtmlDelegateGtk( } // static -ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( - Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate, - TabContentsWrapper* overshadowed) { - ConstrainedHtmlDelegateGtk* constrained_delegate = - new ConstrainedHtmlDelegateGtk(profile, delegate, tab_delegate); +ConstrainedWebDialogDelegate* + ConstrainedWebDialogUI::CreateConstrainedWebDialog( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate, + TabContentsWrapper* overshadowed) { + ConstrainedWebDialogDelegateGtk* constrained_delegate = + new ConstrainedWebDialogDelegateGtk(profile, delegate, tab_delegate); ConstrainedWindow* constrained_window = new ConstrainedWindowGtk(overshadowed, constrained_delegate); constrained_delegate->set_window(constrained_window); diff --git a/chrome/browser/ui/gtk/html_dialog_gtk.cc b/chrome/browser/ui/gtk/web_dialog_gtk.cc index f9e3b61..c4e7feb 100644 --- a/chrome/browser/ui/gtk/html_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/web_dialog_gtk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/gtk/html_dialog_gtk.h" +#include "chrome/browser/ui/gtk/web_dialog_gtk.h" #include <gtk/gtk.h> @@ -15,8 +15,8 @@ #include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/html_dialog_controller.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_controller.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/native_web_keyboard_event.h" @@ -25,20 +25,20 @@ using content::WebUIMessageHandler; namespace browser { -gfx::NativeWindow ShowHtmlDialog(gfx::NativeWindow parent, - Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate, - DialogStyle style) { +gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, + Profile* profile, + Browser* browser, + WebDialogDelegate* delegate, + DialogStyle style) { // Ignore style for now. The style parameter only used in the implementation - // in html_dialog_view.cc file. - // TODO (bshe): Add style parameter to HtmlDialogGtk. - HtmlDialogGtk* html_dialog = - new HtmlDialogGtk(profile, browser, delegate, parent); - return html_dialog->InitDialog(); + // in web_dialog_view.cc file. + // TODO (bshe): Add style parameter to WebDialogGtk. + WebDialogGtk* web_dialog = + new WebDialogGtk(profile, browser, delegate, parent); + return web_dialog->InitDialog(); } -void CloseHtmlDialog(gfx::NativeWindow window) { +void CloseWebDialog(gfx::NativeWindow window) { gtk_dialog_response(GTK_DIALOG(window), GTK_RESPONSE_CLOSE); } @@ -65,41 +65,41 @@ void SetDialogStyle() { } // namespace //////////////////////////////////////////////////////////////////////////////// -// HtmlDialogGtk, public: +// WebDialogGtk, public: -HtmlDialogGtk::HtmlDialogGtk(Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate, - gfx::NativeWindow parent_window) - : HtmlDialogTabContentsDelegate(profile), +WebDialogGtk::WebDialogGtk(Profile* profile, + Browser* browser, + WebDialogDelegate* delegate, + gfx::NativeWindow parent_window) + : WebDialogWebContentsDelegate(profile), delegate_(delegate), parent_window_(parent_window), dialog_(NULL), - dialog_controller_(new HtmlDialogController(this, profile, browser)) { + dialog_controller_(new WebDialogController(this, profile, browser)) { } -HtmlDialogGtk::~HtmlDialogGtk() { +WebDialogGtk::~WebDialogGtk() { } //////////////////////////////////////////////////////////////////////////////// -// HtmlDialogUIDelegate implementation: +// WebDialogDelegate implementation: -ui::ModalType HtmlDialogGtk::GetDialogModalType() const { +ui::ModalType WebDialogGtk::GetDialogModalType() const { return delegate_ ? delegate_->GetDialogModalType() : ui::MODAL_TYPE_NONE; } -string16 HtmlDialogGtk::GetDialogTitle() const { +string16 WebDialogGtk::GetDialogTitle() const { return delegate_ ? delegate_->GetDialogTitle() : string16(); } -GURL HtmlDialogGtk::GetDialogContentURL() const { +GURL WebDialogGtk::GetDialogContentURL() const { if (delegate_) return delegate_->GetDialogContentURL(); else return GURL(); } -void HtmlDialogGtk::GetWebUIMessageHandlers( +void WebDialogGtk::GetWebUIMessageHandlers( std::vector<WebUIMessageHandler*>* handlers) const { if (delegate_) delegate_->GetWebUIMessageHandlers(handlers); @@ -107,33 +107,33 @@ void HtmlDialogGtk::GetWebUIMessageHandlers( handlers->clear(); } -void HtmlDialogGtk::GetDialogSize(gfx::Size* size) const { +void WebDialogGtk::GetDialogSize(gfx::Size* size) const { if (delegate_) delegate_->GetDialogSize(size); else *size = gfx::Size(); } -void HtmlDialogGtk::GetMinimumDialogSize(gfx::Size* size) const { +void WebDialogGtk::GetMinimumDialogSize(gfx::Size* size) const { if (delegate_) delegate_->GetMinimumDialogSize(size); else *size = gfx::Size(); } -std::string HtmlDialogGtk::GetDialogArgs() const { +std::string WebDialogGtk::GetDialogArgs() const { if (delegate_) return delegate_->GetDialogArgs(); else return std::string(); } -void HtmlDialogGtk::OnDialogClosed(const std::string& json_retval) { +void WebDialogGtk::OnDialogClosed(const std::string& json_retval) { DCHECK(dialog_); Detach(); if (delegate_) { - HtmlDialogUIDelegate* dialog_delegate = delegate_; + WebDialogDelegate* dialog_delegate = delegate_; delegate_ = NULL; // We will not communicate further with the delegate. // Store the dialog bounds. @@ -147,13 +147,13 @@ void HtmlDialogGtk::OnDialogClosed(const std::string& json_retval) { delete this; } -void HtmlDialogGtk::OnCloseContents(WebContents* source, - bool* out_close_dialog) { +void WebDialogGtk::OnCloseContents(WebContents* source, + bool* out_close_dialog) { if (delegate_) delegate_->OnCloseContents(source, out_close_dialog); } -void HtmlDialogGtk::CloseContents(WebContents* source) { +void WebDialogGtk::CloseContents(WebContents* source) { DCHECK(dialog_); bool close_dialog = false; @@ -162,7 +162,7 @@ void HtmlDialogGtk::CloseContents(WebContents* source) { OnDialogClosed(std::string()); } -content::WebContents* HtmlDialogGtk::OpenURLFromTab( +content::WebContents* WebDialogGtk::OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) { content::WebContents* new_contents = NULL; @@ -170,28 +170,28 @@ content::WebContents* HtmlDialogGtk::OpenURLFromTab( delegate_->HandleOpenURLFromTab(source, params, &new_contents)) { return new_contents; } - return HtmlDialogTabContentsDelegate::OpenURLFromTab(source, params); + return WebDialogWebContentsDelegate::OpenURLFromTab(source, params); } -void HtmlDialogGtk::AddNewContents(content::WebContents* source, - content::WebContents* new_contents, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) { +void WebDialogGtk::AddNewContents(content::WebContents* source, + content::WebContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) { if (delegate_ && delegate_->HandleAddNewContents( source, new_contents, disposition, initial_pos, user_gesture)) { return; } - HtmlDialogTabContentsDelegate::AddNewContents( + WebDialogWebContentsDelegate::AddNewContents( source, new_contents, disposition, initial_pos, user_gesture); } -void HtmlDialogGtk::LoadingStateChanged(content::WebContents* source) { +void WebDialogGtk::LoadingStateChanged(content::WebContents* source) { if (delegate_) delegate_->OnLoadingStateChanged(source); } -bool HtmlDialogGtk::ShouldShowDialogTitle() const { +bool WebDialogGtk::ShouldShowDialogTitle() const { return true; } @@ -201,7 +201,7 @@ bool HtmlDialogGtk::ShouldShowDialogTitle() const { // A simplified version of BrowserWindowGtk::HandleKeyboardEvent(). // We don't handle global keyboard shortcuts here, but that's fine since // they're all browser-specific. (This may change in the future.) -void HtmlDialogGtk::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { +void WebDialogGtk::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { GdkEventKey* os_event = &event.os_event->key; if (!os_event || event.type == WebKit::WebInputEvent::Char) return; @@ -212,16 +212,16 @@ void HtmlDialogGtk::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { } //////////////////////////////////////////////////////////////////////////////// -// HtmlDialogGtk: +// WebDialogGtk: -gfx::NativeWindow HtmlDialogGtk::InitDialog() { +gfx::NativeWindow WebDialogGtk::InitDialog() { tab_.reset(new TabContentsWrapper( WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL, NULL))); tab_->web_contents()->SetDelegate(this); // This must be done before loading the page; see the comments in - // HtmlDialogUI. - HtmlDialogUI::GetPropertyAccessor().SetProperty( + // WebDialogUI. + WebDialogUI::GetPropertyAccessor().SetProperty( tab_->web_contents()->GetPropertyBag(), this); tab_->web_contents()->GetController().LoadURL( @@ -270,6 +270,6 @@ gfx::NativeWindow HtmlDialogGtk::InitDialog() { return GTK_WINDOW(dialog_); } -void HtmlDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { +void WebDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { OnDialogClosed(std::string()); } diff --git a/chrome/browser/ui/gtk/html_dialog_gtk.h b/chrome/browser/ui/gtk/web_dialog_gtk.h index 892164a..ebc8326 100644 --- a/chrome/browser/ui/gtk/html_dialog_gtk.h +++ b/chrome/browser/ui/gtk/web_dialog_gtk.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_GTK_HTML_DIALOG_GTK_H_ -#define CHROME_BROWSER_UI_GTK_HTML_DIALOG_GTK_H_ +#ifndef CHROME_BROWSER_UI_GTK_WEB_DIALOG_GTK_H_ +#define CHROME_BROWSER_UI_GTK_WEB_DIALOG_GTK_H_ #pragma once #include <string> @@ -11,8 +11,8 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "ui/base/gtk/gtk_signal.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/size.h" @@ -20,24 +20,24 @@ typedef struct _GtkWidget GtkWidget; class Browser; -class HtmlDialogController; class Profile; class TabContentsContainerGtk; class TabContentsWrapper; +class WebDialogController; -class HtmlDialogGtk : public HtmlDialogTabContentsDelegate, - public HtmlDialogUIDelegate { +class WebDialogGtk : public WebDialogWebContentsDelegate, + public WebDialogDelegate { public: - HtmlDialogGtk(Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate, - gfx::NativeWindow parent_window); - virtual ~HtmlDialogGtk(); + WebDialogGtk(Profile* profile, + Browser* browser, + WebDialogDelegate* delegate, + gfx::NativeWindow parent_window); + virtual ~WebDialogGtk(); // Initializes the contents of the dialog (the DOMView and the callbacks). gfx::NativeWindow InitDialog(); - // Overridden from HtmlDialogUIDelegate: + // Overridden from WebDialogDelegate: virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -66,23 +66,23 @@ class HtmlDialogGtk : public HtmlDialogTabContentsDelegate, virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE; private: - CHROMEGTK_CALLBACK_1(HtmlDialogGtk, void, OnResponse, int); + CHROMEGTK_CALLBACK_1(WebDialogGtk, void, OnResponse, int); // This view is a delegate to the HTML content since it needs to get notified // about when the dialog is closing. For all other actions (besides dialog // closing) we delegate to the creator of this view, which we keep track of // using this variable. - HtmlDialogUIDelegate* delegate_; + WebDialogDelegate* delegate_; gfx::NativeWindow parent_window_; GtkWidget* dialog_; - scoped_ptr<HtmlDialogController> dialog_controller_; + scoped_ptr<WebDialogController> dialog_controller_; scoped_ptr<TabContentsWrapper> tab_; scoped_ptr<TabContentsContainerGtk> tab_contents_container_; - DISALLOW_COPY_AND_ASSIGN(HtmlDialogGtk); + DISALLOW_COPY_AND_ASSIGN(WebDialogGtk); }; -#endif // CHROME_BROWSER_UI_GTK_HTML_DIALOG_GTK_H_ +#endif // CHROME_BROWSER_UI_GTK_WEB_DIALOG_GTK_H_ diff --git a/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc b/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc index cb37c36..2a3c2d4 100644 --- a/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc +++ b/chrome/browser/ui/tab_modal_confirm_dialog_browsertest.cc @@ -66,11 +66,11 @@ void TabModalConfirmDialogTest::CloseDialog(bool accept) { dialog_->OnCancel(NULL); #elif defined(OS_CHROMEOS) && !defined(USE_AURA) // |dialog_| deletes itself in |OnDialogClosed()|, so we need to save its - // ConstrainedHTMLUIDelegate before that. - ConstrainedHtmlUIDelegate* constrained_html_ui_delegate = - dialog_->constrained_html_ui_delegate(); + // ConstrainedWebDialogDelegate before that. + ConstrainedWebDialogDelegate* constrained_delegate = + dialog_->constrained_delegate(); dialog_->OnDialogClosed(accept ? "true" : "false"); - constrained_html_ui_delegate->OnDialogCloseFromWebUI(); + constrained_delegate->OnDialogCloseFromWebUI(); #else if (accept) dialog_->GetDialogClientView()->AcceptWindow(); diff --git a/chrome/browser/ui/views/constrained_html_delegate_views.cc b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc index 73b1aed..f8209a4 100644 --- a/chrome/browser/ui/views/constrained_html_delegate_views.cc +++ b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" #include "base/utf_string_conversions.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/views/constrained_window_views.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/web_contents.h" #include "ui/gfx/size.h" #include "ui/views/controls/webview/webview.h" @@ -19,14 +19,14 @@ using content::WebContents; namespace { -class ConstrainedHtmlUIDelegateImplViews - : public ConstrainedHtmlUIDelegateImpl { +class ConstrainedWebDialogDelegateViews + : public ConstrainedWebDialogDelegateBase { public: - ConstrainedHtmlUIDelegateImplViews( + ConstrainedWebDialogDelegateViews( Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate) - : ConstrainedHtmlUIDelegateImpl(profile, delegate, tab_delegate) { + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate) + : ConstrainedWebDialogDelegateBase(profile, delegate, tab_delegate) { WebContents* web_contents = tab()->web_contents(); if (tab_delegate) { set_override_tab_delegate(tab_delegate); @@ -36,38 +36,41 @@ class ConstrainedHtmlUIDelegateImplViews } } - virtual ~ConstrainedHtmlUIDelegateImplViews() {} + virtual ~ConstrainedWebDialogDelegateViews() {} - // HtmlDialogTabContentsDelegate interface. + // WebDialogWebContentsDelegate interface. virtual void CloseContents(WebContents* source) OVERRIDE { window()->CloseConstrainedWindow(); } private: - DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUIDelegateImplViews); + DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViews); }; } // namespace -class ConstrainedHtmlDelegateViews : public views::WebView, - public ConstrainedHtmlUIDelegate, - public views::WidgetDelegate { +class ConstrainedWebDialogDelegateViewViews + : public views::WebView, + public ConstrainedWebDialogDelegate, + public views::WidgetDelegate { public: - ConstrainedHtmlDelegateViews(Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate); - virtual ~ConstrainedHtmlDelegateViews(); + ConstrainedWebDialogDelegateViewViews( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate); + virtual ~ConstrainedWebDialogDelegateViewViews(); void set_window(ConstrainedWindow* window) { return impl_->set_window(window); } - // ConstrainedHtmlUIDelegate interface - virtual const HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() const OVERRIDE { - return impl_->GetHtmlDialogUIDelegate(); + // ConstrainedWebDialogDelegate interface + virtual const WebDialogDelegate* + GetWebDialogDelegate() const OVERRIDE { + return impl_->GetWebDialogDelegate(); } - virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() OVERRIDE { - return impl_->GetHtmlDialogUIDelegate(); + virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { + return impl_->GetWebDialogDelegate(); } virtual void OnDialogCloseFromWebUI() OVERRIDE { return impl_->OnDialogCloseFromWebUI(); @@ -89,7 +92,7 @@ class ConstrainedHtmlDelegateViews : public views::WebView, virtual bool CanResize() const OVERRIDE { return true; } virtual void WindowClosing() OVERRIDE { if (!impl_->closed_via_webui()) - GetHtmlDialogUIDelegate()->OnDialogClosed(std::string()); + GetWebDialogDelegate()->OnDialogClosed(std::string()); } virtual views::Widget* GetWidget() OVERRIDE { return View::GetWidget(); @@ -98,7 +101,7 @@ class ConstrainedHtmlDelegateViews : public views::WebView, return View::GetWidget(); } virtual string16 GetWindowTitle() const OVERRIDE { - return GetHtmlDialogUIDelegate()->GetDialogTitle(); + return GetWebDialogDelegate()->GetDialogTitle(); } virtual views::View* GetContentsView() OVERRIDE { return this; @@ -107,38 +110,39 @@ class ConstrainedHtmlDelegateViews : public views::WebView, // views::WebView overrides. virtual gfx::Size GetPreferredSize() OVERRIDE { gfx::Size size; - GetHtmlDialogUIDelegate()->GetDialogSize(&size); + GetWebDialogDelegate()->GetDialogSize(&size); return size; } private: - scoped_ptr<ConstrainedHtmlUIDelegateImplViews> impl_; + scoped_ptr<ConstrainedWebDialogDelegateViews> impl_; - DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlDelegateViews); + DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViewViews); }; -ConstrainedHtmlDelegateViews::ConstrainedHtmlDelegateViews( +ConstrainedWebDialogDelegateViewViews::ConstrainedWebDialogDelegateViewViews( Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate) + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate) : views::WebView(profile), - impl_(new ConstrainedHtmlUIDelegateImplViews(profile, - delegate, - tab_delegate)) { + impl_(new ConstrainedWebDialogDelegateViews(profile, + delegate, + tab_delegate)) { SetWebContents(tab()->web_contents()); } -ConstrainedHtmlDelegateViews::~ConstrainedHtmlDelegateViews() { +ConstrainedWebDialogDelegateViewViews::~ConstrainedWebDialogDelegateViewViews() { } // static -ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( - Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate, - TabContentsWrapper* container) { - ConstrainedHtmlDelegateViews* constrained_delegate = - new ConstrainedHtmlDelegateViews(profile, delegate, tab_delegate); +ConstrainedWebDialogDelegate* + ConstrainedWebDialogUI::CreateConstrainedWebDialog( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate, + TabContentsWrapper* container) { + ConstrainedWebDialogDelegateViewViews* constrained_delegate = + new ConstrainedWebDialogDelegateViewViews(profile, delegate, tab_delegate); ConstrainedWindow* constrained_window = new ConstrainedWindowViews(container, constrained_delegate); constrained_delegate->set_window(constrained_window); diff --git a/chrome/browser/ui/views/keyboard_overlay_delegate.cc b/chrome/browser/ui/views/keyboard_overlay_delegate.cc index e2fac02..1931018 100644 --- a/chrome/browser/ui/views/keyboard_overlay_delegate.cc +++ b/chrome/browser/ui/views/keyboard_overlay_delegate.cc @@ -9,8 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/utf_string_conversions.h" #include "chrome/browser/chromeos/input_method/input_method_manager.h" -#include "chrome/browser/ui/views/html_dialog_view.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/views/web_dialog_view.h" #include "chrome/common/url_constants.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/ui/views/keyboard_overlay_delegate.h b/chrome/browser/ui/views/keyboard_overlay_delegate.h index 5793877..e4b1073 100644 --- a/chrome/browser/ui/views/keyboard_overlay_delegate.h +++ b/chrome/browser/ui/views/keyboard_overlay_delegate.h @@ -5,24 +5,24 @@ #ifndef CHROME_BROWSER_UI_VIEWS_KEYBOARD_OVERLAY_DELEGATE_H_ #define CHROME_BROWSER_UI_VIEWS_KEYBOARD_OVERLAY_DELEGATE_H_ -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" -class HtmlDialogView; +class WebDialogView; -class KeyboardOverlayDelegate : public HtmlDialogUIDelegate { +class KeyboardOverlayDelegate : public WebDialogDelegate { public: explicit KeyboardOverlayDelegate(const string16& title); - HtmlDialogView* view() { return view_; } - void set_view(HtmlDialogView* html_view) { view_ = html_view; } + WebDialogView* view() { return view_; } + void set_view(WebDialogView* view) { view_ = view; } - // Overridden from HtmlDialogUIDelegate: + // Overridden from WebDialogDelegate: virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; private: virtual ~KeyboardOverlayDelegate(); - // Overridden from HtmlDialogUIDelegate: + // Overridden from WebDialogDelegate: virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -41,7 +41,7 @@ class KeyboardOverlayDelegate : public HtmlDialogUIDelegate { // The view associated with this delegate. // This class does not own the pointer. - HtmlDialogView* view_; + WebDialogView* view_; DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayDelegate); }; diff --git a/chrome/browser/ui/views/keyboard_overlay_dialog_view.cc b/chrome/browser/ui/views/keyboard_overlay_dialog_view.cc index 1328fad..e9a3c66 100644 --- a/chrome/browser/ui/views/keyboard_overlay_dialog_view.cc +++ b/chrome/browser/ui/views/keyboard_overlay_dialog_view.cc @@ -35,9 +35,9 @@ struct Accelerator { KeyboardOverlayDialogView::KeyboardOverlayDialogView( Profile* profile, - HtmlDialogUIDelegate* delegate, + WebDialogDelegate* delegate, BrowserView* parent_view) - : HtmlDialogView(profile, parent_view->browser(), delegate), + : WebDialogView(profile, parent_view->browser(), delegate), parent_view_(parent_view) { RegisterDialogAccelerators(); } @@ -88,23 +88,23 @@ void KeyboardOverlayDialogView::ShowDialog( KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE)); - KeyboardOverlayDialogView* html_view = + KeyboardOverlayDialogView* view = new KeyboardOverlayDialogView(parent_view->browser()->profile(), delegate, parent_view); - delegate->set_view(html_view); - browser::CreateFramelessViewsWindow(owning_window, html_view); + delegate->set_view(view); + browser::CreateFramelessViewsWindow(owning_window, view); // Show the widget at the bottom of the work area. gfx::Size size; delegate->GetDialogSize(&size); gfx::Rect rect = gfx::Screen::GetMonitorNearestWindow( - html_view->GetWidget()->GetNativeView()).work_area(); + view->GetWidget()->GetNativeView()).work_area(); gfx::Rect bounds((rect.width() - size.width()) / 2, rect.height() - size.height(), size.width(), size.height()); - html_view->GetWidget()->SetBounds(bounds); - html_view->GetWidget()->Show(); + view->GetWidget()->SetBounds(bounds); + view->GetWidget()->Show(); } bool KeyboardOverlayDialogView::IsCloseAccelerator( diff --git a/chrome/browser/ui/views/keyboard_overlay_dialog_view.h b/chrome/browser/ui/views/keyboard_overlay_dialog_view.h index 9ee937f..0be0ae5 100644 --- a/chrome/browser/ui/views/keyboard_overlay_dialog_view.h +++ b/chrome/browser/ui/views/keyboard_overlay_dialog_view.h @@ -9,9 +9,9 @@ #include <set> #include "base/compiler_specific.h" -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" -#include "chrome/browser/ui/views/html_dialog_view.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" +#include "chrome/browser/ui/views/web_dialog_view.h" namespace ui { class Accelerator; @@ -20,10 +20,10 @@ class Accelerator; class BrowserView; // A customized dialog view for the keyboard overlay. -class KeyboardOverlayDialogView : public HtmlDialogView { +class KeyboardOverlayDialogView : public WebDialogView { public: KeyboardOverlayDialogView(Profile* profile, - HtmlDialogUIDelegate* delegate, + WebDialogDelegate* delegate, BrowserView* parent_view); virtual ~KeyboardOverlayDialogView(); diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc index ea8de2c..d64b2ac 100644 --- a/chrome/browser/ui/views/sad_tab_view.cc +++ b/chrome/browser/ui/views/sad_tab_view.cc @@ -101,7 +101,7 @@ void SadTabView::LinkClicked(views::Link* source, int event_flags) { content::PAGE_TRANSITION_LINK, false); web_contents_->OpenURL(params); } else if (source == feedback_link_) { - browser::ShowHtmlFeedbackView( + browser::ShowWebFeedbackView( Browser::GetBrowserForController(&web_contents_->GetController(), NULL), l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE), std::string(kCategoryTagCrash)); diff --git a/chrome/browser/ui/views/html_dialog_view.cc b/chrome/browser/ui/views/web_dialog_view.cc index d28edc6..bc48b7b 100644 --- a/chrome/browser/ui/views/html_dialog_view.cc +++ b/chrome/browser/ui/views/web_dialog_view.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/views/html_dialog_view.h" +#include "chrome/browser/ui/views/web_dialog_view.h" #include <vector> @@ -10,7 +10,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser_dialogs.h" -#include "chrome/browser/ui/webui/html_dialog_controller.h" +#include "chrome/browser/ui/webui/web_dialog_controller.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" @@ -34,34 +34,34 @@ using content::WebUIMessageHandler; namespace browser { // Declared in browser_dialogs.h so that others don't need to depend on our .h. -gfx::NativeWindow ShowHtmlDialog(gfx::NativeWindow parent, - Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate, - DialogStyle style) { +gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, + Profile* profile, + Browser* browser, + WebDialogDelegate* delegate, + DialogStyle style) { views::Widget* widget = views::Widget::CreateWindowWithParent( - new HtmlDialogView(profile, browser, delegate), + new WebDialogView(profile, browser, delegate), parent); widget->Show(); return widget->GetNativeWindow(); } -void CloseHtmlDialog(gfx::NativeWindow window) { +void CloseWebDialog(gfx::NativeWindow window) { views::Widget::GetWidgetForNativeWindow(window)->Close(); } } // namespace browser //////////////////////////////////////////////////////////////////////////////// -// HtmlDialogView, public: +// WebDialogView, public: -HtmlDialogView::HtmlDialogView(Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate) - : HtmlDialogTabContentsDelegate(profile), +WebDialogView::WebDialogView(Profile* profile, + Browser* browser, + WebDialogDelegate* delegate) + : WebDialogWebContentsDelegate(profile), initialized_(false), delegate_(delegate), - dialog_controller_(new HtmlDialogController(this, profile, browser)), + dialog_controller_(new WebDialogController(this, profile, browser)), web_view_(new views::WebView(profile)) { web_view_->set_allow_accelerators(true); AddChildView(web_view_); @@ -70,61 +70,61 @@ HtmlDialogView::HtmlDialogView(Profile* profile, AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, false, false, false)); } -HtmlDialogView::~HtmlDialogView() { +WebDialogView::~WebDialogView() { } -content::WebContents* HtmlDialogView::web_contents() { +content::WebContents* WebDialogView::web_contents() { return web_view_->web_contents(); } //////////////////////////////////////////////////////////////////////////////// -// HtmlDialogView, views::View implementation: +// WebDialogView, views::View implementation: -gfx::Size HtmlDialogView::GetPreferredSize() { +gfx::Size WebDialogView::GetPreferredSize() { gfx::Size out; if (delegate_) delegate_->GetMinimumDialogSize(&out); return out; } -bool HtmlDialogView::AcceleratorPressed(const ui::Accelerator& accelerator) { +bool WebDialogView::AcceleratorPressed(const ui::Accelerator& accelerator) { // Pressing ESC closes the dialog. DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code()); OnDialogClosed(std::string()); return true; } -void HtmlDialogView::ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child) { +void WebDialogView::ViewHierarchyChanged(bool is_add, + views::View* parent, + views::View* child) { if (is_add && GetWidget()) InitDialog(); } //////////////////////////////////////////////////////////////////////////////// -// HtmlDialogView, views::WidgetDelegate implementation: +// WebDialogView, views::WidgetDelegate implementation: -bool HtmlDialogView::CanResize() const { +bool WebDialogView::CanResize() const { return true; } -ui::ModalType HtmlDialogView::GetModalType() const { +ui::ModalType WebDialogView::GetModalType() const { return GetDialogModalType(); } -string16 HtmlDialogView::GetWindowTitle() const { +string16 WebDialogView::GetWindowTitle() const { if (delegate_) return delegate_->GetDialogTitle(); return string16(); } -std::string HtmlDialogView::GetWindowName() const { +std::string WebDialogView::GetWindowName() const { if (delegate_) return delegate_->GetDialogName(); return std::string(); } -void HtmlDialogView::WindowClosing() { +void WebDialogView::WindowClosing() { // If we still have a delegate that means we haven't notified it of the // dialog closing. This happens if the user clicks the Close button on the // dialog. @@ -132,69 +132,69 @@ void HtmlDialogView::WindowClosing() { OnDialogClosed(""); } -views::View* HtmlDialogView::GetContentsView() { +views::View* WebDialogView::GetContentsView() { return this; } -views::View* HtmlDialogView::GetInitiallyFocusedView() { +views::View* WebDialogView::GetInitiallyFocusedView() { return web_view_; } -bool HtmlDialogView::ShouldShowWindowTitle() const { +bool WebDialogView::ShouldShowWindowTitle() const { return ShouldShowDialogTitle(); } -views::Widget* HtmlDialogView::GetWidget() { +views::Widget* WebDialogView::GetWidget() { return View::GetWidget(); } -const views::Widget* HtmlDialogView::GetWidget() const { +const views::Widget* WebDialogView::GetWidget() const { return View::GetWidget(); } //////////////////////////////////////////////////////////////////////////////// -// HtmlDialogUIDelegate implementation: +// WebDialogDelegate implementation: -ui::ModalType HtmlDialogView::GetDialogModalType() const { +ui::ModalType WebDialogView::GetDialogModalType() const { if (delegate_) return delegate_->GetDialogModalType(); return ui::MODAL_TYPE_NONE; } -string16 HtmlDialogView::GetDialogTitle() const { +string16 WebDialogView::GetDialogTitle() const { return GetWindowTitle(); } -GURL HtmlDialogView::GetDialogContentURL() const { +GURL WebDialogView::GetDialogContentURL() const { if (delegate_) return delegate_->GetDialogContentURL(); return GURL(); } -void HtmlDialogView::GetWebUIMessageHandlers( +void WebDialogView::GetWebUIMessageHandlers( std::vector<WebUIMessageHandler*>* handlers) const { if (delegate_) delegate_->GetWebUIMessageHandlers(handlers); } -void HtmlDialogView::GetDialogSize(gfx::Size* size) const { +void WebDialogView::GetDialogSize(gfx::Size* size) const { if (delegate_) delegate_->GetDialogSize(size); } -void HtmlDialogView::GetMinimumDialogSize(gfx::Size* size) const { +void WebDialogView::GetMinimumDialogSize(gfx::Size* size) const { if (delegate_) delegate_->GetMinimumDialogSize(size); } -std::string HtmlDialogView::GetDialogArgs() const { +std::string WebDialogView::GetDialogArgs() const { if (delegate_) return delegate_->GetDialogArgs(); return std::string(); } -void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { - HtmlDialogTabContentsDelegate::Detach(); +void WebDialogView::OnDialogClosed(const std::string& json_retval) { + Detach(); if (delegate_) { // Store the dialog content area size. delegate_->StoreDialogSize(GetContentsBounds().size()); @@ -209,29 +209,29 @@ void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { } } -void HtmlDialogView::OnCloseContents(WebContents* source, - bool* out_close_dialog) { +void WebDialogView::OnCloseContents(WebContents* source, + bool* out_close_dialog) { if (delegate_) delegate_->OnCloseContents(source, out_close_dialog); } -bool HtmlDialogView::ShouldShowDialogTitle() const { +bool WebDialogView::ShouldShowDialogTitle() const { if (delegate_) return delegate_->ShouldShowDialogTitle(); return true; } -bool HtmlDialogView::HandleContextMenu( +bool WebDialogView::HandleContextMenu( const content::ContextMenuParams& params) { if (delegate_) return delegate_->HandleContextMenu(params); - return HtmlDialogTabContentsDelegate::HandleContextMenu(params); + return WebDialogWebContentsDelegate::HandleContextMenu(params); } //////////////////////////////////////////////////////////////////////////////// // content::WebContentsDelegate implementation: -void HtmlDialogView::MoveContents(WebContents* source, const gfx::Rect& pos) { +void WebDialogView::MoveContents(WebContents* source, const gfx::Rect& pos) { // The contained web page wishes to resize itself. We let it do this because // if it's a dialog we know about, we trust it not to be mean to the user. GetWidget()->SetBounds(pos); @@ -240,7 +240,7 @@ void HtmlDialogView::MoveContents(WebContents* source, const gfx::Rect& pos) { // A simplified version of BrowserView::HandleKeyboardEvent(). // We don't handle global keyboard shortcuts here, but that's fine since // they're all browser-specific. (This may change in the future.) -void HtmlDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { +void WebDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { #if defined(USE_AURA) aura::KeyEvent aura_event(event.os_event->native_event(), false); views::NativeWidgetAura* aura_widget = @@ -254,14 +254,14 @@ void HtmlDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { #endif } -void HtmlDialogView::CloseContents(WebContents* source) { +void WebDialogView::CloseContents(WebContents* source) { bool close_dialog = false; OnCloseContents(source, &close_dialog); if (close_dialog) OnDialogClosed(std::string()); } -content::WebContents* HtmlDialogView::OpenURLFromTab( +content::WebContents* WebDialogView::OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) { content::WebContents* new_contents = NULL; @@ -269,44 +269,44 @@ content::WebContents* HtmlDialogView::OpenURLFromTab( delegate_->HandleOpenURLFromTab(source, params, &new_contents)) { return new_contents; } - return HtmlDialogTabContentsDelegate::OpenURLFromTab(source, params); + return WebDialogWebContentsDelegate::OpenURLFromTab(source, params); } -void HtmlDialogView::AddNewContents(content::WebContents* source, - content::WebContents* new_contents, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) { +void WebDialogView::AddNewContents(content::WebContents* source, + content::WebContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) { if (delegate_ && delegate_->HandleAddNewContents( source, new_contents, disposition, initial_pos, user_gesture)) { return; } - HtmlDialogTabContentsDelegate::AddNewContents( + WebDialogWebContentsDelegate::AddNewContents( source, new_contents, disposition, initial_pos, user_gesture); } -void HtmlDialogView::LoadingStateChanged(content::WebContents* source) { +void WebDialogView::LoadingStateChanged(content::WebContents* source) { if (delegate_) delegate_->OnLoadingStateChanged(source); } //////////////////////////////////////////////////////////////////////////////// -// HtmlDialogView, TabRenderWatcher::Delegate implementation: +// WebDialogView, TabRenderWatcher::Delegate implementation: -void HtmlDialogView::OnRenderHostCreated(content::RenderViewHost* host) { +void WebDialogView::OnRenderHostCreated(content::RenderViewHost* host) { } -void HtmlDialogView::OnTabMainFrameLoaded() { +void WebDialogView::OnTabMainFrameLoaded() { } -void HtmlDialogView::OnTabMainFrameRender() { +void WebDialogView::OnTabMainFrameRender() { tab_watcher_.reset(); } //////////////////////////////////////////////////////////////////////////////// -// HtmlDialogView, private: +// WebDialogView, private: -void HtmlDialogView::InitDialog() { +void WebDialogView::InitDialog() { content::WebContents* web_contents = web_view_->GetWebContents(); if (web_contents->GetDelegate() == this) return; @@ -314,8 +314,8 @@ void HtmlDialogView::InitDialog() { web_contents->SetDelegate(this); // Set the delegate. This must be done before loading the page. See - // the comment above HtmlDialogUI in its header file for why. - HtmlDialogUI::GetPropertyAccessor().SetProperty( + // the comment above WebDialogUI in its header file for why. + WebDialogUI::GetPropertyAccessor().SetProperty( web_contents->GetPropertyBag(), this); tab_watcher_.reset(new TabRenderWatcher(web_contents, this)); diff --git a/chrome/browser/ui/views/html_dialog_view.h b/chrome/browser/ui/views/web_dialog_view.h index 44645b4..5ff20ad 100644 --- a/chrome/browser/ui/views/html_dialog_view.h +++ b/chrome/browser/ui/views/web_dialog_view.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_VIEWS_HTML_DIALOG_VIEW_H_ -#define CHROME_BROWSER_UI_VIEWS_HTML_DIALOG_VIEW_H_ +#ifndef CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_ +#define CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_ #pragma once #include <string> @@ -12,14 +12,14 @@ #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/tab_render_watcher.h" -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "ui/gfx/size.h" #include "ui/views/view.h" #include "ui/views/widget/widget_delegate.h" class Browser; -class HtmlDialogController; +class WebDialogController; class Profile; namespace views { @@ -28,30 +28,30 @@ class WebView; //////////////////////////////////////////////////////////////////////////////// // -// HtmlDialogView is a view used to display an HTML dialog to the user. The +// WebDialogView is a view used to display an web dialog to the user. The // content of the dialogs is determined by the delegate -// (HtmlDialogUIDelegate), but is basically a file URL along with a +// (WebDialogDelegate), but is basically a file URL along with a // JSON input string. The HTML is supposed to show a UI to the user and is // expected to send back a JSON file as a return value. // //////////////////////////////////////////////////////////////////////////////// // -// TODO(akalin): Make HtmlDialogView contain an HtmlDialogTabContentsDelegate +// TODO(akalin): Make WebDialogView contain an WebDialogWebContentsDelegate // instead of inheriting from it to avoid violating the "no multiple // inheritance" rule. // TODO(beng): This class should not depend on Browser or Profile, only // content::BrowserContext. -class HtmlDialogView +class WebDialogView : public views::View, - public HtmlDialogTabContentsDelegate, - public HtmlDialogUIDelegate, + public WebDialogWebContentsDelegate, + public WebDialogDelegate, public views::WidgetDelegate, public TabRenderWatcher::Delegate { public: - HtmlDialogView(Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate); - virtual ~HtmlDialogView(); + WebDialogView(Profile* profile, + Browser* browser, + WebDialogDelegate* delegate); + virtual ~WebDialogView(); // For testing. content::WebContents* web_contents(); @@ -76,7 +76,7 @@ class HtmlDialogView virtual views::Widget* GetWidget() OVERRIDE; virtual const views::Widget* GetWidget() const OVERRIDE; - // Overridden from HtmlDialogUIDelegate: + // Overridden from WebDialogDelegate: virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -115,7 +115,7 @@ class HtmlDialogView virtual void OnTabMainFrameRender() OVERRIDE; private: - FRIEND_TEST_ALL_PREFIXES(HtmlDialogBrowserTest, WebContentRendered); + FRIEND_TEST_ALL_PREFIXES(WebDialogBrowserTest, WebContentRendered); // Initializes the contents of the dialog. void InitDialog(); @@ -132,14 +132,14 @@ class HtmlDialogView // about when the dialog is closing. For all other actions (besides dialog // closing) we delegate to the creator of this view, which we keep track of // using this variable. - HtmlDialogUIDelegate* delegate_; + WebDialogDelegate* delegate_; // Controls lifetime of dialog. - scoped_ptr<HtmlDialogController> dialog_controller_; + scoped_ptr<WebDialogController> dialog_controller_; views::WebView* web_view_; - DISALLOW_COPY_AND_ASSIGN(HtmlDialogView); + DISALLOW_COPY_AND_ASSIGN(WebDialogView); }; -#endif // CHROME_BROWSER_UI_VIEWS_HTML_DIALOG_VIEW_H_ +#endif // CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_ diff --git a/chrome/browser/ui/views/html_dialog_view_browsertest.cc b/chrome/browser/ui/views/web_dialog_view_browsertest.cc index 307d900..198464d 100644 --- a/chrome/browser/ui/views/html_dialog_view_browsertest.cc +++ b/chrome/browser/ui/views/web_dialog_view_browsertest.cc @@ -9,8 +9,8 @@ #include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/views/html_dialog_view.h" -#include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h" +#include "chrome/browser/ui/views/web_dialog_view.h" +#include "chrome/browser/ui/webui/test_web_dialog_delegate.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -26,16 +26,16 @@ using testing::Eq; namespace { -// Initial size of HTMLDialog for SizeWindow test case. +// Initial size of WebDialog for SizeWindow test case. const int kInitialWidth = 40; const int kInitialHeight = 40; -class TestHtmlDialogView: public HtmlDialogView { +class TestWebDialogView : public WebDialogView { public: - TestHtmlDialogView(Profile* profile, - Browser* browser, - HtmlDialogUIDelegate* delegate) - : HtmlDialogView(profile, browser, delegate), + TestWebDialogView(Profile* profile, + Browser* browser, + WebDialogDelegate* delegate) + : WebDialogView(profile, browser, delegate), painted_(false), should_quit_on_size_change_(false) { delegate->GetDialogSize(&last_size_); @@ -66,11 +66,11 @@ class TestHtmlDialogView: public HtmlDialogView { virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { should_quit_on_size_change_ = false; // No quit when we are closing. - HtmlDialogView::OnDialogClosed(json_retval); + WebDialogView::OnDialogClosed(json_retval); } virtual void OnTabMainFrameRender() OVERRIDE { - HtmlDialogView::OnTabMainFrameRender(); + WebDialogView::OnTabMainFrameRender(); painted_ = true; MessageLoop::current()->Quit(); } @@ -82,14 +82,14 @@ class TestHtmlDialogView: public HtmlDialogView { bool should_quit_on_size_change_; gfx::Size last_size_; - DISALLOW_COPY_AND_ASSIGN(TestHtmlDialogView); + DISALLOW_COPY_AND_ASSIGN(TestWebDialogView); }; } // namespace -class HtmlDialogBrowserTest : public InProcessBrowserTest { +class WebDialogBrowserTest : public InProcessBrowserTest { public: - HtmlDialogBrowserTest() {} + WebDialogBrowserTest() {} }; #if defined(OS_LINUX) && !defined(OS_CHROMEOS) @@ -103,23 +103,24 @@ class HtmlDialogBrowserTest : public InProcessBrowserTest { #define MAYBE_SizeWindow DISABLED_SizeWindow #endif -IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) { - test::TestHtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate( - GURL(chrome::kChromeUIChromeURLsURL)); +IN_PROC_BROWSER_TEST_F(WebDialogBrowserTest, MAYBE_SizeWindow) { + test::TestWebDialogDelegate* delegate = + new test::TestWebDialogDelegate( + GURL(chrome::kChromeUIChromeURLsURL)); delegate->set_size(kInitialWidth, kInitialHeight); - TestHtmlDialogView* html_view = - new TestHtmlDialogView(browser()->profile(), browser(), delegate); + TestWebDialogView* view = + new TestWebDialogView(browser()->profile(), browser(), delegate); WebContents* web_contents = browser()->GetSelectedWebContents(); ASSERT_TRUE(web_contents != NULL); views::Widget::CreateWindowWithParent( - html_view, web_contents->GetView()->GetTopLevelNativeWindow()); - html_view->GetWidget()->Show(); + view, web_contents->GetView()->GetTopLevelNativeWindow()); + view->GetWidget()->Show(); - // TestHtmlDialogView should quit current message loop on size change. - html_view->set_should_quit_on_size_change(true); + // TestWebDialogView should quit current message loop on size change. + view->set_should_quit_on_size_change(true); - gfx::Rect bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); + gfx::Rect bounds = view->GetWidget()->GetClientAreaScreenBounds(); gfx::Rect set_bounds = bounds; gfx::Rect actual_bounds, rwhv_bounds; @@ -128,13 +129,13 @@ IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) { set_bounds.set_width(400); set_bounds.set_height(300); - html_view->MoveContents(web_contents, set_bounds); - ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit. - actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); + view->MoveContents(web_contents, set_bounds); + ui_test_utils::RunMessageLoop(); // TestWebDialogView will quit. + actual_bounds = view->GetWidget()->GetClientAreaScreenBounds(); EXPECT_EQ(set_bounds, actual_bounds); rwhv_bounds = - html_view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); + view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); EXPECT_LT(0, rwhv_bounds.width()); EXPECT_LT(0, rwhv_bounds.height()); EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); @@ -144,29 +145,29 @@ IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) { set_bounds.set_width(550); set_bounds.set_height(250); - html_view->MoveContents(web_contents, set_bounds); - ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit. - actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); + view->MoveContents(web_contents, set_bounds); + ui_test_utils::RunMessageLoop(); // TestWebDialogView will quit. + actual_bounds = view->GetWidget()->GetClientAreaScreenBounds(); EXPECT_EQ(set_bounds, actual_bounds); rwhv_bounds = - html_view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); + view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); EXPECT_LT(0, rwhv_bounds.width()); EXPECT_LT(0, rwhv_bounds.height()); EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); EXPECT_GE(set_bounds.height(), rwhv_bounds.height()); // Get very small. - gfx::Size min_size = html_view->GetWidget()->GetMinimumSize(); + gfx::Size min_size = view->GetWidget()->GetMinimumSize(); set_bounds.set_size(min_size); - html_view->MoveContents(web_contents, set_bounds); - ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit. - actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); + view->MoveContents(web_contents, set_bounds); + ui_test_utils::RunMessageLoop(); // TestWebDialogView will quit. + actual_bounds = view->GetWidget()->GetClientAreaScreenBounds(); EXPECT_EQ(set_bounds, actual_bounds); rwhv_bounds = - html_view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); + view->web_contents()->GetRenderWidgetHostView()->GetViewBounds(); EXPECT_LT(0, rwhv_bounds.width()); EXPECT_LT(0, rwhv_bounds.height()); EXPECT_GE(set_bounds.width(), rwhv_bounds.width()); @@ -176,33 +177,33 @@ IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) { set_bounds.set_width(0); set_bounds.set_height(0); - html_view->MoveContents(web_contents, set_bounds); - ui_test_utils::RunMessageLoop(); // TestHtmlDialogView will quit. - actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); + view->MoveContents(web_contents, set_bounds); + ui_test_utils::RunMessageLoop(); // TestWebDialogView will quit. + actual_bounds = view->GetWidget()->GetClientAreaScreenBounds(); EXPECT_LT(0, actual_bounds.width()); EXPECT_LT(0, actual_bounds.height()); } // This is timing out about 5~10% of runs. See crbug.com/86059. -IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, DISABLED_WebContentRendered) { - HtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate( +IN_PROC_BROWSER_TEST_F(WebDialogBrowserTest, DISABLED_WebContentRendered) { + WebDialogDelegate* delegate = new test::TestWebDialogDelegate( GURL(chrome::kChromeUIChromeURLsURL)); - TestHtmlDialogView* html_view = - new TestHtmlDialogView(browser()->profile(), browser(), delegate); + TestWebDialogView* view = + new TestWebDialogView(browser()->profile(), browser(), delegate); WebContents* web_contents = browser()->GetSelectedWebContents(); ASSERT_TRUE(web_contents != NULL); views::Widget::CreateWindowWithParent( - html_view, web_contents->GetView()->GetTopLevelNativeWindow()); - EXPECT_TRUE(html_view->initialized_); + view, web_contents->GetView()->GetTopLevelNativeWindow()); + EXPECT_TRUE(view->initialized_); - html_view->InitDialog(); - html_view->GetWidget()->Show(); + view->InitDialog(); + view->GetWidget()->Show(); - // TestHtmlDialogView::OnTabMainFrameRender() will Quit(). + // TestWebDialogView::OnTabMainFrameRender() will Quit(). MessageLoopForUI::current()->Run(); - EXPECT_TRUE(html_view->painted()); + EXPECT_TRUE(view->painted()); - html_view->GetWidget()->Close(); + view->GetWidget()->Close(); } diff --git a/chrome/browser/ui/webui/certificate_viewer_ui.cc b/chrome/browser/ui/webui/certificate_viewer_ui.cc index cd16522..9a08af0 100644 --- a/chrome/browser/ui/webui/certificate_viewer_ui.cc +++ b/chrome/browser/ui/webui/certificate_viewer_ui.cc @@ -15,7 +15,7 @@ #include "grit/generated_resources.h" CertificateViewerUI::CertificateViewerUI(content::WebUI* web_ui) - : ConstrainedHtmlUI(web_ui) { + : ConstrainedWebDialogUI(web_ui) { // Set up the chrome://view-cert source. ChromeWebUIDataSource* html_source = new ChromeWebUIDataSource(chrome::kChromeUICertificateViewerHost); diff --git a/chrome/browser/ui/webui/certificate_viewer_ui.h b/chrome/browser/ui/webui/certificate_viewer_ui.h index 1a895fc..c263840 100644 --- a/chrome/browser/ui/webui/certificate_viewer_ui.h +++ b/chrome/browser/ui/webui/certificate_viewer_ui.h @@ -6,10 +6,10 @@ #define CHROME_BROWSER_UI_WEBUI_CERTIFICATE_VIEWER_UI_H_ #pragma once -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" // The WebUI for chrome://view-cert -class CertificateViewerUI : public ConstrainedHtmlUI { +class CertificateViewerUI : public ConstrainedWebDialogUI { public: explicit CertificateViewerUI(content::WebUI* web_ui); virtual ~CertificateViewerUI(); diff --git a/chrome/browser/ui/webui/certificate_viewer_webui.cc b/chrome/browser/ui/webui/certificate_viewer_webui.cc index af09b6f..e9d94cd 100644 --- a/chrome/browser/ui/webui/certificate_viewer_webui.cc +++ b/chrome/browser/ui/webui/certificate_viewer_webui.cc @@ -19,7 +19,7 @@ #include "chrome/browser/ui/certificate_dialogs.h" #include "chrome/browser/ui/dialog_style.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" #include "chrome/common/net/x509_certificate_model.h" #include "chrome/common/url_constants.h" #include "content/public/browser/web_contents.h" @@ -72,8 +72,8 @@ void CertificateViewerDialog::Show(gfx::NativeWindow parent) { TabContentsWrapper* current_wrapper = browser->GetSelectedTabContentsWrapper(); // TODO(bshe): UI tweaks needed for AURA html Dialog, such as add padding on - // title for AURA ConstrainedHtmlDialog. - window_ = ConstrainedHtmlUI::CreateConstrainedHtmlDialog( + // title for AURA ConstrainedWebDialogUI. + window_ = ConstrainedWebDialogUI::CreateConstrainedWebDialog( current_wrapper->profile(), this, NULL, diff --git a/chrome/browser/ui/webui/certificate_viewer_webui.h b/chrome/browser/ui/webui/certificate_viewer_webui.h index f6f6e4e..0eeed20 100644 --- a/chrome/browser/ui/webui/certificate_viewer_webui.h +++ b/chrome/browser/ui/webui/certificate_viewer_webui.h @@ -11,7 +11,7 @@ #include "base/compiler_specific.h" #include "base/values.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/web_ui_message_handler.h" #include "net/base/x509_certificate.h" #include "ui/gfx/native_widget_types.h" @@ -25,7 +25,7 @@ void ShowCertificateViewer(gfx::NativeWindow parent, // and chromeos builds to display detailed information in a floating dialog when // the user clicks on "Certificate Information" from the lock icon of a web site // or "View" from the Certificate Manager. -class CertificateViewerDialog : private HtmlDialogUIDelegate { +class CertificateViewerDialog : private WebDialogDelegate { public: // Shows the certificate viewer dialog for the passed in certificate. static void ShowDialog(gfx::NativeWindow parent, @@ -41,7 +41,7 @@ class CertificateViewerDialog : private HtmlDialogUIDelegate { // Show the dialog using the given parent window. void Show(gfx::NativeWindow parent); - // Overridden from HtmlDialogUI::Delegate: + // Overridden from WebDialogDelegate: virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 31eacba..cf4e6fb 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -17,7 +17,7 @@ #include "chrome/browser/ui/webui/help/help_ui.h" #include "chrome/browser/ui/webui/about_ui.h" #include "chrome/browser/ui/webui/bookmarks_ui.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" #include "chrome/browser/ui/webui/crashes_ui.h" #include "chrome/browser/ui/webui/devtools_ui.h" #include "chrome/browser/ui/webui/downloads_ui.h" @@ -30,7 +30,7 @@ #include "chrome/browser/ui/webui/generic_handler.h" #include "chrome/browser/ui/webui/gpu_internals_ui.h" #include "chrome/browser/ui/webui/history_ui.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/browser/ui/webui/inspect_ui.h" #include "chrome/browser/ui/webui/media/media_internals_ui.h" #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" @@ -167,17 +167,17 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, // dialog as backup. It's just that on Chrome OS, it's the only // print dialog. if (url.host() == chrome::kChromeUICloudPrintResourcesHost) - return &NewWebUI<ExternalHtmlDialogUI>; + return &NewWebUI<ExternalWebDialogUI>; if (url.host() == chrome::kChromeUICloudPrintSetupHost) - return &NewWebUI<HtmlDialogUI>; + return &NewWebUI<WebDialogUI>; if (url.spec() == chrome::kChromeUIConstrainedHTMLTestURL) - return &NewWebUI<ConstrainedHtmlUI>; + return &NewWebUI<ConstrainedWebDialogUI>; if (url.host() == chrome::kChromeUICrashesHost) return &NewWebUI<CrashesUI>; if (url.host() == chrome::kChromeUIDevToolsHost) return &NewWebUI<DevToolsUI>; if (url.host() == chrome::kChromeUIDialogHost) - return &NewWebUI<ConstrainedHtmlUI>; + return &NewWebUI<ConstrainedWebDialogUI>; if (url.host() == chrome::kChromeUIExtensionsFrameHost) return &NewWebUI<ExtensionsUI>; if (url.host() == chrome::kChromeUIFlashHost) @@ -203,7 +203,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, if (url.host() == chrome::kChromeUISyncInternalsHost) return &NewWebUI<SyncInternalsUI>; if (url.host() == chrome::kChromeUISyncResourcesHost) - return &NewWebUI<HtmlDialogUI>; + return &NewWebUI<WebDialogUI>; if (url.host() == chrome::kChromeUITracingHost) return &NewWebUI<TracingUI>; if (url.host() == chrome::kChromeUIUberFrameHost) @@ -291,7 +291,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, if (url.host() == chrome::kChromeUICollectedCookiesHost || url.host() == chrome::kChromeUIHttpAuthHost || url.host() == chrome::kChromeUITabModalConfirmDialogHost) { - return &NewWebUI<ConstrainedHtmlUI>; + return &NewWebUI<ConstrainedWebDialogUI>; } #endif diff --git a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc index f8f93dc..0fe8484 100644 --- a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc +++ b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc @@ -310,7 +310,7 @@ void KeyboardOverlayHandler::OpenLearnMorePage(const ListValue* args) { //////////////////////////////////////////////////////////////////////////////// KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) - : HtmlDialogUI(web_ui) { + : WebDialogUI(web_ui) { Profile* profile = Profile::FromWebUI(web_ui); KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); web_ui->AddMessageHandler(handler); diff --git a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h index 48fe717..094ad7f 100644 --- a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h +++ b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h @@ -6,9 +6,9 @@ #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_KEYBOARD_OVERLAY_UI_H_ #pragma once -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" -class KeyboardOverlayUI : public HtmlDialogUI { +class KeyboardOverlayUI : public WebDialogUI { public: explicit KeyboardOverlayUI(content::WebUI* web_ui); diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc b/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc index 57b6f65..e771a28 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc @@ -12,7 +12,7 @@ #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/dialog_style.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/common/url_constants.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -21,7 +21,7 @@ using content::BrowserThread; using content::WebContents; using content::WebUIMessageHandler; -class MobileSetupDialogDelegate : public HtmlDialogUIDelegate { +class MobileSetupDialogDelegate : public WebDialogDelegate { public: static MobileSetupDialogDelegate* GetInstance(); void ShowDialog(); @@ -34,7 +34,7 @@ class MobileSetupDialogDelegate : public HtmlDialogUIDelegate { void OnCloseDialog(); - // HtmlDialogUIDelegate overrides. + // WebDialogDelegate overrides. virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -76,7 +76,7 @@ void MobileSetupDialogDelegate::ShowDialog() { Browser* browser = BrowserList::GetLastActive(); if (!browser) return; - browser->BrowserShowHtmlDialog(this, NULL, STYLE_GENERIC); + browser->BrowserShowWebDialog(this, NULL, STYLE_GENERIC); } ui::ModalType MobileSetupDialogDelegate::GetDialogModalType() const { diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h b/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h index 172d291..f51e11d 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h @@ -9,7 +9,7 @@ #include <vector> #include "base/memory/singleton.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" class MobileSetupDialog { public: diff --git a/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h b/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h deleted file mode 100644 index 5e072b28..0000000 --- a/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_DELEGATE_IMPL_H_ -#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_DELEGATE_IMPL_H_ -#pragma once - -#include "base/memory/scoped_ptr.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" - -// Platform-agnostic base implementation of ConstrainedHtmlUIDelegate. -class ConstrainedHtmlUIDelegateImpl : public ConstrainedHtmlUIDelegate, - public HtmlDialogTabContentsDelegate { - public: - ConstrainedHtmlUIDelegateImpl(Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate); - virtual ~ConstrainedHtmlUIDelegateImpl(); - - void set_window(ConstrainedWindow* window); - bool closed_via_webui() const; - - // ConstrainedHtmlUIDelegate interface. - virtual const HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() const OVERRIDE; - virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() OVERRIDE; - virtual void OnDialogCloseFromWebUI() OVERRIDE; - virtual void ReleaseTabContentsOnDialogClose() OVERRIDE; - virtual ConstrainedWindow* window() OVERRIDE; - virtual TabContentsWrapper* tab() OVERRIDE; - - // HtmlDialogTabContentsDelegate interface. - virtual void HandleKeyboardEvent( - const NativeWebKeyboardEvent& event) OVERRIDE; - - protected: - void set_override_tab_delegate( - HtmlDialogTabContentsDelegate* override_tab_delegate); - - private: - HtmlDialogUIDelegate* html_delegate_; - - // The constrained window that owns |this|. Saved so we can close it later. - ConstrainedWindow* window_; - - // Holds the HTML to display in the constrained dialog. - scoped_ptr<TabContentsWrapper> tab_; - - // Was the dialog closed from WebUI (in which case |html_delegate_|'s - // OnDialogClosed() method has already been called)? - bool closed_via_webui_; - - // If true, release |tab_| on close instead of destroying it. - bool release_tab_on_close_; - - scoped_ptr<HtmlDialogTabContentsDelegate> override_tab_delegate_; - - DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUIDelegateImpl); -}; - -#endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_DELEGATE_IMPL_H_ diff --git a/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.cc b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc index a68dc76..ada3058 100644 --- a/chrome/browser/ui/webui/constrained_html_ui_delegate_impl.cc +++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/constrained_html_ui_delegate_impl.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" #include <string> @@ -10,18 +10,18 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/constrained_window.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/web_contents.h" using content::WebContents; -ConstrainedHtmlUIDelegateImpl::ConstrainedHtmlUIDelegateImpl( +ConstrainedWebDialogDelegateBase::ConstrainedWebDialogDelegateBase( Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate) - : HtmlDialogTabContentsDelegate(profile), - html_delegate_(delegate), + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate) + : WebDialogWebContentsDelegate(profile), + web_dialog_delegate_(delegate), window_(NULL), closed_via_webui_(false), release_tab_on_close_(false) { @@ -35,8 +35,8 @@ ConstrainedHtmlUIDelegateImpl::ConstrainedHtmlUIDelegateImpl( } else { web_contents->SetDelegate(this); } - // Set |this| as a property so the ConstrainedHtmlUI can retrieve it. - ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( + // Set |this| as a property so the ConstrainedWebDialogUI can retrieve it. + ConstrainedWebDialogUI::GetPropertyAccessor().SetProperty( web_contents->GetPropertyBag(), this); web_contents->GetController().LoadURL(delegate->GetDialogContentURL(), @@ -45,51 +45,51 @@ ConstrainedHtmlUIDelegateImpl::ConstrainedHtmlUIDelegateImpl( std::string()); } -ConstrainedHtmlUIDelegateImpl::~ConstrainedHtmlUIDelegateImpl() { +ConstrainedWebDialogDelegateBase::~ConstrainedWebDialogDelegateBase() { if (release_tab_on_close_) ignore_result(tab_.release()); } -const HtmlDialogUIDelegate* -ConstrainedHtmlUIDelegateImpl::GetHtmlDialogUIDelegate() const { - return html_delegate_; +const WebDialogDelegate* + ConstrainedWebDialogDelegateBase::GetWebDialogDelegate() const { + return web_dialog_delegate_; } -HtmlDialogUIDelegate* -ConstrainedHtmlUIDelegateImpl::GetHtmlDialogUIDelegate() { - return html_delegate_; +WebDialogDelegate* + ConstrainedWebDialogDelegateBase::GetWebDialogDelegate() { + return web_dialog_delegate_; } -void ConstrainedHtmlUIDelegateImpl::OnDialogCloseFromWebUI() { +void ConstrainedWebDialogDelegateBase::OnDialogCloseFromWebUI() { closed_via_webui_ = true; window_->CloseConstrainedWindow(); } -void ConstrainedHtmlUIDelegateImpl::set_window(ConstrainedWindow* window) { +void ConstrainedWebDialogDelegateBase::set_window(ConstrainedWindow* window) { window_ = window; } -void ConstrainedHtmlUIDelegateImpl::set_override_tab_delegate( - HtmlDialogTabContentsDelegate* override_tab_delegate) { +void ConstrainedWebDialogDelegateBase::set_override_tab_delegate( + WebDialogWebContentsDelegate* override_tab_delegate) { override_tab_delegate_.reset(override_tab_delegate); } -bool ConstrainedHtmlUIDelegateImpl::closed_via_webui() const { +bool ConstrainedWebDialogDelegateBase::closed_via_webui() const { return closed_via_webui_; } -void ConstrainedHtmlUIDelegateImpl::ReleaseTabContentsOnDialogClose() { +void ConstrainedWebDialogDelegateBase::ReleaseTabContentsOnDialogClose() { release_tab_on_close_ = true; } -ConstrainedWindow* ConstrainedHtmlUIDelegateImpl::window() { +ConstrainedWindow* ConstrainedWebDialogDelegateBase::window() { return window_; } -TabContentsWrapper* ConstrainedHtmlUIDelegateImpl::tab() { +TabContentsWrapper* ConstrainedWebDialogDelegateBase::tab() { return tab_.get(); } -void ConstrainedHtmlUIDelegateImpl::HandleKeyboardEvent( +void ConstrainedWebDialogDelegateBase::HandleKeyboardEvent( const NativeWebKeyboardEvent& event) { } diff --git a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h new file mode 100644 index 0000000..7855bbc --- /dev/null +++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h @@ -0,0 +1,67 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ +#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ +#pragma once + +#include "base/memory/scoped_ptr.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" + +// Platform-agnostic base implementation of ConstrainedWebDialogDelegate. +class ConstrainedWebDialogDelegateBase + : public ConstrainedWebDialogDelegate, + public WebDialogWebContentsDelegate { + public: + ConstrainedWebDialogDelegateBase( + Profile* profile, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate); + virtual ~ConstrainedWebDialogDelegateBase(); + + void set_window(ConstrainedWindow* window); + bool closed_via_webui() const; + + // ConstrainedWebDialogDelegate interface. + virtual const WebDialogDelegate* + GetWebDialogDelegate() const OVERRIDE; + virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE; + virtual void OnDialogCloseFromWebUI() OVERRIDE; + virtual void ReleaseTabContentsOnDialogClose() OVERRIDE; + virtual ConstrainedWindow* window() OVERRIDE; + virtual TabContentsWrapper* tab() OVERRIDE; + + // WebDialogWebContentsDelegate interface. + virtual void HandleKeyboardEvent( + const NativeWebKeyboardEvent& event) OVERRIDE; + + protected: + void set_override_tab_delegate( + WebDialogWebContentsDelegate* override_tab_delegate); + + private: + WebDialogDelegate* web_dialog_delegate_; + + // The constrained window that owns |this|. Saved so we can close it later. + ConstrainedWindow* window_; + + // Holds the HTML to display in the constrained dialog. + scoped_ptr<TabContentsWrapper> tab_; + + // Was the dialog closed from WebUI (in which case |web_dialog_delegate_|'s + // OnDialogClosed() method has already been called)? + bool closed_via_webui_; + + // If true, release |tab_| on close instead of destroying it. + bool release_tab_on_close_; + + scoped_ptr<WebDialogWebContentsDelegate> override_tab_delegate_; + + DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateBase); +}; + +#endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ diff --git a/chrome/browser/ui/webui/constrained_html_ui.cc b/chrome/browser/ui/webui/constrained_web_dialog_ui.cc index c862123..2a4c5c5 100644 --- a/chrome/browser/ui/webui/constrained_html_ui.cc +++ b/chrome/browser/ui/webui/constrained_web_dialog_ui.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" #include <string> #include <vector> @@ -12,7 +12,7 @@ #include "base/lazy_instance.h" #include "base/property_bag.h" #include "base/values.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_view_host.h" @@ -23,22 +23,23 @@ using content::RenderViewHost; using content::WebContents; using content::WebUIMessageHandler; -static base::LazyInstance<base::PropertyAccessor<ConstrainedHtmlUIDelegate*> > - g_constrained_html_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<base::PropertyAccessor<ConstrainedWebDialogDelegate*> > + g_constrained_web_dialog_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; -ConstrainedHtmlUI::ConstrainedHtmlUI(content::WebUI* web_ui) +ConstrainedWebDialogUI::ConstrainedWebDialogUI(content::WebUI* web_ui) : WebUIController(web_ui) { } -ConstrainedHtmlUI::~ConstrainedHtmlUI() { +ConstrainedWebDialogUI::~ConstrainedWebDialogUI() { } -void ConstrainedHtmlUI::RenderViewCreated(RenderViewHost* render_view_host) { - ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); +void ConstrainedWebDialogUI::RenderViewCreated( + RenderViewHost* render_view_host) { + ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); if (!delegate) return; - HtmlDialogUIDelegate* dialog_delegate = delegate->GetHtmlDialogUIDelegate(); + WebDialogDelegate* dialog_delegate = delegate->GetWebDialogDelegate(); std::vector<WebUIMessageHandler*> handlers; dialog_delegate->GetWebUIMessageHandlers(&handlers); render_view_host->SetWebUIProperty("dialogArguments", @@ -50,7 +51,7 @@ void ConstrainedHtmlUI::RenderViewCreated(RenderViewHost* render_view_host) { // Add a "DialogClose" callback which matches HTMLDialogUI behavior. web_ui()->RegisterMessageCallback("DialogClose", - base::Bind(&ConstrainedHtmlUI::OnDialogCloseMessage, + base::Bind(&ConstrainedWebDialogUI::OnDialogCloseMessage, base::Unretained(this))); content::NotificationService::current()->Notify( @@ -59,26 +60,26 @@ void ConstrainedHtmlUI::RenderViewCreated(RenderViewHost* render_view_host) { content::Details<RenderViewHost>(render_view_host)); } -void ConstrainedHtmlUI::OnDialogCloseMessage(const ListValue* args) { - ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); +void ConstrainedWebDialogUI::OnDialogCloseMessage(const ListValue* args) { + ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); if (!delegate) return; std::string json_retval; if (!args->empty() && !args->GetString(0, &json_retval)) NOTREACHED() << "Could not read JSON argument"; - delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); + delegate->GetWebDialogDelegate()->OnDialogClosed(json_retval); delegate->OnDialogCloseFromWebUI(); } -ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { - ConstrainedHtmlUIDelegate** property = GetPropertyAccessor().GetProperty( +ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { + ConstrainedWebDialogDelegate** property = GetPropertyAccessor().GetProperty( web_ui()->GetWebContents()->GetPropertyBag()); return property ? *property : NULL; } // static -base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& - ConstrainedHtmlUI::GetPropertyAccessor() { - return g_constrained_html_ui_property_accessor.Get(); +base::PropertyAccessor<ConstrainedWebDialogDelegate*>& + ConstrainedWebDialogUI::GetPropertyAccessor() { + return g_constrained_web_dialog_ui_property_accessor.Get(); } diff --git a/chrome/browser/ui/webui/constrained_html_ui.h b/chrome/browser/ui/webui/constrained_web_dialog_ui.h index dc1efd2..96b68af 100644 --- a/chrome/browser/ui/webui/constrained_html_ui.h +++ b/chrome/browser/ui/webui/constrained_web_dialog_ui.h @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ #pragma once #include "base/compiler_specific.h" #include "content/public/browser/web_ui_controller.h" class ConstrainedWindow; -class HtmlDialogTabContentsDelegate; -class HtmlDialogUIDelegate; class Profile; class TabContentsWrapper; +class WebDialogDelegate; +class WebDialogWebContentsDelegate; namespace base { template<class T> class PropertyAccessor; @@ -23,10 +23,10 @@ namespace content { class RenderViewHost; } -class ConstrainedHtmlUIDelegate { +class ConstrainedWebDialogDelegate { public: - virtual const HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() const = 0; - virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0; + virtual const WebDialogDelegate* GetWebDialogDelegate() const = 0; + virtual WebDialogDelegate* GetWebDialogDelegate() = 0; // Called when the dialog is being closed in response to a "DialogClose" // message from WebUI. @@ -44,57 +44,57 @@ class ConstrainedHtmlUIDelegate { virtual TabContentsWrapper* tab() = 0; protected: - virtual ~ConstrainedHtmlUIDelegate() {} + virtual ~ConstrainedWebDialogDelegate() {} }; -// ConstrainedHtmlUI is a facility to show HTML WebUI content +// ConstrainedWebDialogUI is a facility to show HTML WebUI content // in a tab-modal constrained dialog. It is implemented as an adapter -// between an HtmlDialogUI object and a ConstrainedWindow object. +// between an WebDialogUI object and a ConstrainedWindow object. // // Since ConstrainedWindow requires platform-specific delegate // implementations, this class is just a factory stub. // TODO(thestig) Refactor the platform-independent code out of the // platform-specific implementations. -class ConstrainedHtmlUI : public content::WebUIController { +class ConstrainedWebDialogUI : public content::WebUIController { public: - explicit ConstrainedHtmlUI(content::WebUI* web_ui); - virtual ~ConstrainedHtmlUI(); + explicit ConstrainedWebDialogUI(content::WebUI* web_ui); + virtual ~ConstrainedWebDialogUI(); // WebUIController implementation: virtual void RenderViewCreated( content::RenderViewHost* render_view_host) OVERRIDE; // Create a constrained HTML dialog. The actual object that gets created - // is a ConstrainedHtmlUIDelegate, which later triggers construction of a - // ConstrainedHtmlUI object. + // is a ConstrainedWebDialogDelegate, which later triggers construction of a + // ConstrainedWebDialogUI object. // |profile| is used to construct the constrained HTML dialog's WebContents. // |delegate| controls the behavior of the dialog. // |tab_delegate| is optional, pass one in to use a custom - // HtmlDialogTabContentsDelegate with the dialog, or NULL to + // WebDialogWebContentsDelegate with the dialog, or NULL to // use the default one. The dialog takes ownership of // |tab_delegate|. // |overshadowed| is the tab being overshadowed by the dialog. - static ConstrainedHtmlUIDelegate* CreateConstrainedHtmlDialog( + static ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( Profile* profile, - HtmlDialogUIDelegate* delegate, - HtmlDialogTabContentsDelegate* tab_delegate, + WebDialogDelegate* delegate, + WebDialogWebContentsDelegate* tab_delegate, TabContentsWrapper* overshadowed); // Returns a property accessor that can be used to set the - // ConstrainedHtmlUIDelegate property on a WebContents. - static base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& + // ConstrainedWebDialogDelegate property on a WebContents. + static base::PropertyAccessor<ConstrainedWebDialogDelegate*>& GetPropertyAccessor(); protected: - // Returns the WebContents' PropertyBag's ConstrainedHtmlUIDelegate. + // Returns the WebContents' PropertyBag's ConstrainedWebDialogDelegate. // Returns NULL if that property is not set. - ConstrainedHtmlUIDelegate* GetConstrainedDelegate(); + ConstrainedWebDialogDelegate* GetConstrainedDelegate(); private: // JS Message Handler void OnDialogCloseMessage(const base::ListValue* args); - DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI); + DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogUI); }; -#endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ diff --git a/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc index 32594e1..c5d3648 100644 --- a/chrome/browser/ui/webui/constrained_html_ui_browsertest.cc +++ b/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc @@ -8,8 +8,8 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/constrained_window_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" -#include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" +#include "chrome/browser/ui/webui/test_web_dialog_delegate.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -20,14 +20,14 @@ using content::WebContents; namespace { -class ConstrainedHtmlDialogBrowserTestObserver +class ConstrainedWebDialogBrowserTestObserver : public content::WebContentsObserver { public: - explicit ConstrainedHtmlDialogBrowserTestObserver(WebContents* contents) + explicit ConstrainedWebDialogBrowserTestObserver(WebContents* contents) : content::WebContentsObserver(contents), tab_destroyed_(false) { } - virtual ~ConstrainedHtmlDialogBrowserTestObserver() {} + virtual ~ConstrainedWebDialogBrowserTestObserver() {} bool tab_destroyed() { return tab_destroyed_; } @@ -41,9 +41,9 @@ class ConstrainedHtmlDialogBrowserTestObserver } // namespace -class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest { +class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest { public: - ConstrainedHtmlDialogBrowserTest() {} + ConstrainedWebDialogBrowserTest() {} protected: size_t GetConstrainedWindowCount(TabContentsWrapper* wrapper) const { @@ -52,45 +52,45 @@ class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest { }; // Tests that opening/closing the constrained window won't crash it. -IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) { +IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { // The delegate deletes itself. - HtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate( + WebDialogDelegate* delegate = new test::TestWebDialogDelegate( GURL(chrome::kChromeUIConstrainedHTMLTestURL)); TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(wrapper); - ConstrainedHtmlUIDelegate* html_ui_delegate = - ConstrainedHtmlUI::CreateConstrainedHtmlDialog(browser()->profile(), - delegate, - NULL, - wrapper); - ASSERT_TRUE(html_ui_delegate); - EXPECT_TRUE(html_ui_delegate->window()); + ConstrainedWebDialogDelegate* dialog_delegate = + ConstrainedWebDialogUI::CreateConstrainedWebDialog(browser()->profile(), + delegate, + NULL, + wrapper); + ASSERT_TRUE(dialog_delegate); + EXPECT_TRUE(dialog_delegate->window()); EXPECT_EQ(1U, GetConstrainedWindowCount(wrapper)); } // Tests that ReleaseTabContentsOnDialogClose() works. -IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, +IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, ReleaseTabContentsOnDialogClose) { // The delegate deletes itself. - HtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate( + WebDialogDelegate* delegate = new test::TestWebDialogDelegate( GURL(chrome::kChromeUIConstrainedHTMLTestURL)); TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(wrapper); - ConstrainedHtmlUIDelegate* html_ui_delegate = - ConstrainedHtmlUI::CreateConstrainedHtmlDialog(browser()->profile(), - delegate, - NULL, - wrapper); - ASSERT_TRUE(html_ui_delegate); - scoped_ptr<TabContentsWrapper> new_tab(html_ui_delegate->tab()); + ConstrainedWebDialogDelegate* dialog_delegate = + ConstrainedWebDialogUI::CreateConstrainedWebDialog(browser()->profile(), + delegate, + NULL, + wrapper); + ASSERT_TRUE(dialog_delegate); + scoped_ptr<TabContentsWrapper> new_tab(dialog_delegate->tab()); ASSERT_TRUE(new_tab.get()); ASSERT_EQ(1U, GetConstrainedWindowCount(wrapper)); - ConstrainedHtmlDialogBrowserTestObserver observer(new_tab->web_contents()); - html_ui_delegate->ReleaseTabContentsOnDialogClose(); - html_ui_delegate->OnDialogCloseFromWebUI(); + ConstrainedWebDialogBrowserTestObserver observer(new_tab->web_contents()); + dialog_delegate->ReleaseTabContentsOnDialogClose(); + dialog_delegate->OnDialogCloseFromWebUI(); ASSERT_FALSE(observer.tab_destroyed()); EXPECT_EQ(0U, GetConstrainedWindowCount(wrapper)); diff --git a/chrome/browser/ui/webui/feedback_ui.cc b/chrome/browser/ui/webui/feedback_ui.cc index a939c0f..9843ec1 100644 --- a/chrome/browser/ui/webui/feedback_ui.cc +++ b/chrome/browser/ui/webui/feedback_ui.cc @@ -134,9 +134,9 @@ int GetIndexOfFeedbackTab(Browser* browser) { namespace browser { -void ShowHtmlFeedbackView(Browser* browser, - const std::string& description_template, - const std::string& category_tag) { +void ShowWebFeedbackView(Browser* browser, + const std::string& description_template, + const std::string& category_tag) { #if defined(OS_CHROMEOS) // Grab the timestamp before we do anything else - this is crucial to help // diagnose some hardware issues. @@ -577,7 +577,8 @@ void FeedbackHandler::CloseFeedbackTab() { // FeedbackUI // //////////////////////////////////////////////////////////////////////////////// -FeedbackUI::FeedbackUI(content::WebUI* web_ui) : HtmlDialogUI(web_ui) { +FeedbackUI::FeedbackUI(content::WebUI* web_ui) + : WebDialogUI(web_ui) { FeedbackHandler* handler = new FeedbackHandler(web_ui->GetWebContents()); web_ui->AddMessageHandler(handler); diff --git a/chrome/browser/ui/webui/feedback_ui.h b/chrome/browser/ui/webui/feedback_ui.h index 9caab27..37bdbf7 100644 --- a/chrome/browser/ui/webui/feedback_ui.h +++ b/chrome/browser/ui/webui/feedback_ui.h @@ -7,17 +7,17 @@ #include <string> -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" class Browser; namespace browser { -void ShowHtmlFeedbackView(Browser* browser, - const std::string& description_template, - const std::string& category_tag); +void ShowWebFeedbackView(Browser* browser, + const std::string& description_template, + const std::string& category_tag); } // namespace browser -class FeedbackUI : public HtmlDialogUI { +class FeedbackUI : public WebDialogUI { public: explicit FeedbackUI(content::WebUI* web_ui); diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc index 9173aa4..6c51012 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc @@ -19,7 +19,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/browser/ui/webui/print_preview/print_preview_data_source.h" #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" #include "chrome/common/print_messages.h" @@ -76,7 +76,7 @@ base::LazyInstance<PrintPreviewRequestIdMapWithLock> } // namespace PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) - : ConstrainedHtmlUI(web_ui), + : ConstrainedWebDialogUI(web_ui), initial_preview_start_time_(base::TimeTicks::Now()), handler_(NULL), source_is_modifiable_(true), @@ -308,7 +308,7 @@ void PrintPreviewUI::OnHidePreviewTab() { if (background_printing_manager->HasPrintPreviewTab(preview_tab)) return; - ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); + ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); if (!delegate) return; delegate->ReleaseTabContentsOnDialogClose(); @@ -320,10 +320,10 @@ void PrintPreviewUI::OnClosePrintPreviewTab() { if (tab_closed_) return; tab_closed_ = true; - ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); + ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); if (!delegate) return; - delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(""); + delegate->GetWebDialogDelegate()->OnDialogClosed(""); delegate->OnDialogCloseFromWebUI(); } diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.h b/chrome/browser/ui/webui/print_preview/print_preview_ui.h index 1f5b071..bc113a8 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui.h +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.h @@ -12,7 +12,7 @@ #include "base/memory/ref_counted.h" #include "base/time.h" #include "chrome/browser/printing/print_preview_data_service.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" class PrintPreviewDataService; class PrintPreviewHandler; @@ -30,7 +30,7 @@ namespace printing { struct PageSizeMargins; } -class PrintPreviewUI : public ConstrainedHtmlUI { +class PrintPreviewUI : public ConstrainedWebDialogUI { public: explicit PrintPreviewUI(content::WebUI* web_ui); virtual ~PrintPreviewUI(); diff --git a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc index fe2b56c..ddb0762 100644 --- a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc +++ b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc @@ -20,7 +20,7 @@ #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" -#include "chrome/browser/ui/webui/constrained_html_ui.h" +#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/url_constants.h" #include "grit/browser_resources.h" @@ -55,12 +55,12 @@ TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI( data_source->set_default_resource(IDR_TAB_MODAL_CONFIRM_DIALOG_HTML); ChromeURLDataManager::AddDataSource(profile, data_source); - constrained_html_ui_delegate_ = - ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile, - this, - NULL, - wrapper); - delegate_->set_window(constrained_html_ui_delegate_->window()); + constrained_web_dialog_delegate_ = + ConstrainedWebDialogUI::CreateConstrainedWebDialog(profile, + this, + NULL, + wrapper); + delegate_->set_window(constrained_web_dialog_delegate_->window()); } TabModalConfirmDialogWebUI::~TabModalConfirmDialogWebUI() {} diff --git a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h index d21f09b..6f18a46 100644 --- a/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h +++ b/chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h @@ -12,9 +12,9 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" -class ConstrainedHtmlUIDelegate; +class ConstrainedWebDialogDelegate; class TabContentsWrapper; class TabModalConfirmDialogDelegate; @@ -23,13 +23,13 @@ class TabModalConfirmDialogDelegate; // To display the dialog, allocate this object on the heap. It will open the // dialog from its constructor and then delete itself when the user dismisses // the dialog. -class TabModalConfirmDialogWebUI : public HtmlDialogUIDelegate { +class TabModalConfirmDialogWebUI : public WebDialogDelegate { public: TabModalConfirmDialogWebUI( TabModalConfirmDialogDelegate* dialog_delegate, TabContentsWrapper* wrapper); - // HtmlDialogUIDelegate implementation. + // WebDialogDelegate implementation. virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -42,8 +42,8 @@ class TabModalConfirmDialogWebUI : public HtmlDialogUIDelegate { bool* out_close_dialog) OVERRIDE; virtual bool ShouldShowDialogTitle() const OVERRIDE; - ConstrainedHtmlUIDelegate* constrained_html_ui_delegate() { - return constrained_html_ui_delegate_; + ConstrainedWebDialogDelegate* constrained_web_dialog_delegate() { + return constrained_web_dialog_delegate_; } private: @@ -52,7 +52,7 @@ class TabModalConfirmDialogWebUI : public HtmlDialogUIDelegate { scoped_ptr<TabModalConfirmDialogDelegate> delegate_; // Deletes itself. - ConstrainedHtmlUIDelegate* constrained_html_ui_delegate_; + ConstrainedWebDialogDelegate* constrained_web_dialog_delegate_; DISALLOW_COPY_AND_ASSIGN(TabModalConfirmDialogWebUI); }; diff --git a/chrome/browser/ui/webui/task_manager/task_manager_dialog.cc b/chrome/browser/ui/webui/task_manager/task_manager_dialog.cc index 2a085f9..60a44c94 100644 --- a/chrome/browser/ui/webui/task_manager/task_manager_dialog.cc +++ b/chrome/browser/ui/webui/task_manager/task_manager_dialog.cc @@ -22,7 +22,7 @@ #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/dialog_style.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -45,7 +45,7 @@ using content::BrowserThread; using content::WebContents; using content::WebUIMessageHandler; -class TaskManagerDialogImpl : public HtmlDialogUIDelegate { +class TaskManagerDialogImpl : public WebDialogDelegate { public: TaskManagerDialogImpl(); @@ -58,7 +58,7 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate { void OnCloseDialog(); - // Overridden from HtmlDialogUIDelegate: + // Overridden from WebDialogDelegate: virtual ui::ModalType GetDialogModalType() const OVERRIDE { return ui::MODAL_TYPE_NONE; } @@ -136,7 +136,7 @@ class TaskManagerDialogImpl : public HtmlDialogUIDelegate { private: void ShowDialog(bool is_background_page_mode); - void OpenHtmlDialog(); + void OpenWebDialog(); int show_count_; @@ -183,7 +183,7 @@ void TaskManagerDialogImpl::ShowDialog(bool is_background_page_mode) { #endif } is_background_page_mode_ = is_background_page_mode; - OpenHtmlDialog(); + OpenWebDialog(); ++show_count_; } @@ -192,14 +192,14 @@ void TaskManagerDialogImpl::OnCloseDialog() { --show_count_; } -void TaskManagerDialogImpl::OpenHtmlDialog() { +void TaskManagerDialogImpl::OpenWebDialog() { Browser* browser = BrowserList::GetLastActive(); DCHECK(browser); - window_ = browser::ShowHtmlDialog(NULL, - browser->profile()->GetOriginalProfile(), - NULL, - this, - STYLE_GENERIC); + window_ = browser::ShowWebDialog(NULL, + browser->profile()->GetOriginalProfile(), + NULL, + this, + STYLE_GENERIC); } // **************************************************** diff --git a/chrome/browser/ui/webui/test_html_dialog_ui_delegate.cc b/chrome/browser/ui/webui/test_html_dialog_ui_delegate.cc deleted file mode 100644 index a933585..0000000 --- a/chrome/browser/ui/webui/test_html_dialog_ui_delegate.cc +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h" - -#include "base/utf_string_conversions.h" - -using content::WebContents; -using content::WebUIMessageHandler; - -namespace test { - -TestHtmlDialogUIDelegate::TestHtmlDialogUIDelegate(const GURL& url) - : url_(url), - size_(400, 400) { -} - -TestHtmlDialogUIDelegate::~TestHtmlDialogUIDelegate() { -} - -ui::ModalType TestHtmlDialogUIDelegate::GetDialogModalType() const { - return ui::MODAL_TYPE_WINDOW; -} - -string16 TestHtmlDialogUIDelegate::GetDialogTitle() const { - return UTF8ToUTF16("Test"); -} - -GURL TestHtmlDialogUIDelegate::GetDialogContentURL() const { - return url_; -} - -void TestHtmlDialogUIDelegate::GetWebUIMessageHandlers( - std::vector<WebUIMessageHandler*>* handlers) const { -} - -void TestHtmlDialogUIDelegate::GetDialogSize(gfx::Size* size) const { - *size = size_; -} - -std::string TestHtmlDialogUIDelegate::GetDialogArgs() const { - return std::string(); -} - -void TestHtmlDialogUIDelegate::OnDialogClosed(const std::string& json_retval) { -} - -void TestHtmlDialogUIDelegate::OnCloseContents(WebContents* source, - bool* out_close_dialog) { - if (out_close_dialog) - *out_close_dialog = true; -} - -bool TestHtmlDialogUIDelegate::ShouldShowDialogTitle() const { - return true; -} - -} // namespace test diff --git a/chrome/browser/ui/webui/test_web_dialog_delegate.cc b/chrome/browser/ui/webui/test_web_dialog_delegate.cc new file mode 100644 index 0000000..1a07b3b --- /dev/null +++ b/chrome/browser/ui/webui/test_web_dialog_delegate.cc @@ -0,0 +1,59 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/test_web_dialog_delegate.h" + +#include "base/utf_string_conversions.h" + +using content::WebContents; +using content::WebUIMessageHandler; + +namespace test { + +TestWebDialogDelegate::TestWebDialogDelegate(const GURL& url) + : url_(url), + size_(400, 400) { +} + +TestWebDialogDelegate::~TestWebDialogDelegate() { +} + +ui::ModalType TestWebDialogDelegate::GetDialogModalType() const { + return ui::MODAL_TYPE_WINDOW; +} + +string16 TestWebDialogDelegate::GetDialogTitle() const { + return UTF8ToUTF16("Test"); +} + +GURL TestWebDialogDelegate::GetDialogContentURL() const { + return url_; +} + +void TestWebDialogDelegate::GetWebUIMessageHandlers( + std::vector<WebUIMessageHandler*>* handlers) const { +} + +void TestWebDialogDelegate::GetDialogSize(gfx::Size* size) const { + *size = size_; +} + +std::string TestWebDialogDelegate::GetDialogArgs() const { + return std::string(); +} + +void TestWebDialogDelegate::OnDialogClosed(const std::string& json_retval) { +} + +void TestWebDialogDelegate::OnCloseContents(WebContents* source, + bool* out_close_dialog) { + if (out_close_dialog) + *out_close_dialog = true; +} + +bool TestWebDialogDelegate::ShouldShowDialogTitle() const { + return true; +} + +} // namespace test diff --git a/chrome/browser/ui/webui/test_html_dialog_ui_delegate.h b/chrome/browser/ui/webui/test_web_dialog_delegate.h index 4a55900..4e92b03 100644 --- a/chrome/browser/ui/webui/test_html_dialog_ui_delegate.h +++ b/chrome/browser/ui/webui/test_web_dialog_delegate.h @@ -2,28 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_TEST_HTML_DIALOG_UI_DELEGATE_H_ -#define CHROME_BROWSER_UI_WEBUI_TEST_HTML_DIALOG_UI_DELEGATE_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_TEST_WEB_DIALOG_DELEGATE_H_ +#define CHROME_BROWSER_UI_WEBUI_TEST_WEB_DIALOG_DELEGATE_H_ #pragma once #include <string> #include "base/compiler_specific.h" -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "ui/gfx/size.h" namespace test { -class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { +class TestWebDialogDelegate : public WebDialogDelegate { public: - explicit TestHtmlDialogUIDelegate(const GURL& url); - virtual ~TestHtmlDialogUIDelegate(); + explicit TestWebDialogDelegate(const GURL& url); + virtual ~TestWebDialogDelegate(); void set_size(int width, int height) { size_.SetSize(width, height); } - // HTMLDialogUIDelegate implementation: + // WebDialogDelegate implementation: virtual ui::ModalType GetDialogModalType() const OVERRIDE; virtual string16 GetDialogTitle() const OVERRIDE; virtual GURL GetDialogContentURL() const OVERRIDE; @@ -40,9 +40,9 @@ class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { const GURL url_; gfx::Size size_; - DISALLOW_COPY_AND_ASSIGN(TestHtmlDialogUIDelegate); + DISALLOW_COPY_AND_ASSIGN(TestWebDialogDelegate); }; } // namespace test -#endif // CHROME_BROWSER_UI_WEBUI_TEST_HTML_DIALOG_UI_DELEGATE_H_ +#endif // CHROME_BROWSER_UI_WEBUI_TEST_WEB_DIALOG_DELEGATE_H_ diff --git a/chrome/browser/ui/webui/html_dialog_controller.cc b/chrome/browser/ui/webui/web_dialog_controller.cc index c31f2c7..51ba4d7 100644 --- a/chrome/browser/ui/webui/html_dialog_controller.cc +++ b/chrome/browser/ui/webui/web_dialog_controller.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/html_dialog_controller.h" +#include "chrome/browser/ui/webui/web_dialog_controller.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -10,9 +10,10 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" -HtmlDialogController::HtmlDialogController(HtmlDialogUIDelegate* delegate, - Profile* profile, - Browser* browser) +WebDialogController::WebDialogController( + WebDialogDelegate* delegate, + Profile* profile, + Browser* browser) : dialog_delegate_(delegate) { // It's only safe to show an off the record profile under one of two // circumstances: @@ -32,7 +33,7 @@ HtmlDialogController::HtmlDialogController(HtmlDialogUIDelegate* delegate, } // content::NotificationObserver implementation: -void HtmlDialogController::Observe( +void WebDialogController::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { diff --git a/chrome/browser/ui/webui/html_dialog_controller.h b/chrome/browser/ui/webui/web_dialog_controller.h index 6786475..ef36111 100644 --- a/chrome/browser/ui/webui/html_dialog_controller.h +++ b/chrome/browser/ui/webui/web_dialog_controller.h @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_CONTROLLER_H_ -#define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_CONTROLLER_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_CONTROLLER_H_ +#define CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_CONTROLLER_H_ #pragma once -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" class Browser; class Profile; -// This provides the common functionality for HtmlDialogs of notifying the +// This provides the common functionality for WebDialogs of notifying the // dialog that it should close when the browser that created it has closed to // avoid using an old Profile object. -class HtmlDialogController : public content::NotificationObserver { +class WebDialogController : public content::NotificationObserver { public: - HtmlDialogController(HtmlDialogUIDelegate* delegate, + WebDialogController(WebDialogDelegate* delegate, Profile* profile, Browser* browser); @@ -30,12 +30,12 @@ class HtmlDialogController : public content::NotificationObserver { private: // The delegate controlled by this instance. This class is owned by the // delegate. - HtmlDialogUIDelegate* dialog_delegate_; + WebDialogDelegate* dialog_delegate_; // Used for notification of parent browser closing. content::NotificationRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(HtmlDialogController); + DISALLOW_COPY_AND_ASSIGN(WebDialogController); }; -#endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_CONTROLLER_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_CONTROLLER_H_ diff --git a/chrome/browser/ui/webui/html_dialog_controller_browsertest.cc b/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc index 1fadb62..aa68d87 100644 --- a/chrome/browser/ui/webui/html_dialog_controller_browsertest.cc +++ b/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc @@ -4,7 +4,7 @@ #include "base/memory/scoped_ptr.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h" +#include "chrome/browser/ui/webui/test_web_dialog_delegate.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -13,47 +13,46 @@ namespace { -class TestDialogClosedDelegate : public test::TestHtmlDialogUIDelegate { +class TestDialogClosedDelegate : public test::TestWebDialogDelegate { public: TestDialogClosedDelegate() - : test::TestHtmlDialogUIDelegate(GURL(chrome::kChromeUIChromeURLsURL)), + : test::TestWebDialogDelegate( + GURL(chrome::kChromeUIChromeURLsURL)), dialog_closed_(false) { } - // Overridden from HtmlDialogUIDelegate: + bool dialog_closed() const { return dialog_closed_; } + + // Overridden from WebDialogDelegate: virtual ui::ModalType GetDialogModalType() const OVERRIDE { return ui::MODAL_TYPE_NONE; } - - // Overridden from HtmlDialogUIDelegate: virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { dialog_closed_ = true; } - bool dialog_closed() { - return dialog_closed_; - } - private: bool dialog_closed_; + + DISALLOW_COPY_AND_ASSIGN(TestDialogClosedDelegate); }; } // namespace -class HtmlDialogControllerBrowserTest : public InProcessBrowserTest { +class WebDialogControllerBrowserTest : public InProcessBrowserTest { public: - HtmlDialogControllerBrowserTest() {} + WebDialogControllerBrowserTest() {} }; -// Tests that an HtmlDialog can be shown for an incognito browser and that when +// Tests that a WebDialog can be shown for an incognito browser and that when // that browser is closed the dialog created by that browser is closed. -IN_PROC_BROWSER_TEST_F(HtmlDialogControllerBrowserTest, IncognitoBrowser) { +IN_PROC_BROWSER_TEST_F(WebDialogControllerBrowserTest, IncognitoBrowser) { Browser* browser = CreateIncognitoBrowser(); scoped_ptr<TestDialogClosedDelegate> delegate(new TestDialogClosedDelegate()); // Create the dialog and make sure the initial "closed" state is what we // expect. - browser->BrowserShowHtmlDialog(delegate.get(), NULL, STYLE_GENERIC); + browser->BrowserShowWebDialog(delegate.get(), NULL, STYLE_GENERIC); ui_test_utils::RunAllPendingInMessageLoop(); ASSERT_FALSE(delegate->dialog_closed()); diff --git a/chrome/browser/ui/webui/html_dialog_ui.cc b/chrome/browser/ui/webui/web_dialog_ui.cc index 1b0dcf6..39e819a 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.cc +++ b/chrome/browser/ui/webui/web_dialog_ui.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/html_dialog_ui.h" +#include "chrome/browser/ui/webui/web_dialog_ui.h" #include "base/bind.h" #include "base/bind_helpers.h" @@ -20,14 +20,14 @@ using content::RenderViewHost; using content::WebUIMessageHandler; -static base::LazyInstance<base::PropertyAccessor<HtmlDialogUIDelegate*> > - g_html_dialog_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; +static base::LazyInstance<base::PropertyAccessor<WebDialogDelegate*> > + g_web_dialog_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; -HtmlDialogUI::HtmlDialogUI(content::WebUI* web_ui) +WebDialogUI::WebDialogUI(content::WebUI* web_ui) : WebUIController(web_ui) { } -HtmlDialogUI::~HtmlDialogUI() { +WebDialogUI::~WebDialogUI() { // Don't unregister our property. During the teardown of the WebContents, // this will be deleted, but the WebContents will already be destroyed. // @@ -38,29 +38,28 @@ HtmlDialogUI::~HtmlDialogUI() { // and the HTML dialogs won't swap WebUIs anyway since they don't navigate. } -void HtmlDialogUI::CloseDialog(const base::ListValue* args) { +void WebDialogUI::CloseDialog(const base::ListValue* args) { OnDialogClosed(args); } // static -base::PropertyAccessor<HtmlDialogUIDelegate*>& - HtmlDialogUI::GetPropertyAccessor() { - return g_html_dialog_ui_property_accessor.Get(); +base::PropertyAccessor<WebDialogDelegate*>& WebDialogUI::GetPropertyAccessor() { + return g_web_dialog_ui_property_accessor.Get(); } //////////////////////////////////////////////////////////////////////////////// // Private: -void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { +void WebDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { // Hook up the javascript function calls, also known as chrome.send("foo") // calls in the HTML, to the actual C++ functions. web_ui()->RegisterMessageCallback("DialogClose", - base::Bind(&HtmlDialogUI::OnDialogClosed, base::Unretained(this))); + base::Bind(&WebDialogUI::OnDialogClosed, base::Unretained(this))); // Pass the arguments to the renderer supplied by the delegate. std::string dialog_args; std::vector<WebUIMessageHandler*> handlers; - HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( + WebDialogDelegate** delegate = GetPropertyAccessor().GetProperty( web_ui()->GetWebContents()->GetPropertyBag()); if (delegate) { dialog_args = (*delegate)->GetDialogArgs(); @@ -80,8 +79,8 @@ void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) { content::Details<RenderViewHost>(render_view_host)); } -void HtmlDialogUI::OnDialogClosed(const ListValue* args) { - HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty( +void WebDialogUI::OnDialogClosed(const ListValue* args) { + WebDialogDelegate** delegate = GetPropertyAccessor().GetProperty( web_ui()->GetWebContents()->GetPropertyBag()); if (delegate) { std::string json_retval; @@ -92,8 +91,8 @@ void HtmlDialogUI::OnDialogClosed(const ListValue* args) { } } -ExternalHtmlDialogUI::ExternalHtmlDialogUI(content::WebUI* web_ui) - : HtmlDialogUI(web_ui) { +ExternalWebDialogUI::ExternalWebDialogUI(content::WebUI* web_ui) + : WebDialogUI(web_ui) { // Non-file based UI needs to not have access to the Web UI bindings // for security reasons. The code hosting the dialog should provide // dialog specific functionality through other bindings and methods @@ -101,30 +100,30 @@ ExternalHtmlDialogUI::ExternalHtmlDialogUI(content::WebUI* web_ui) web_ui->SetBindings(web_ui->GetBindings() & ~content::BINDINGS_POLICY_WEB_UI); } -ExternalHtmlDialogUI::~ExternalHtmlDialogUI() { +ExternalWebDialogUI::~ExternalWebDialogUI() { } -std::string HtmlDialogUIDelegate::GetDialogName() const { +std::string WebDialogDelegate::GetDialogName() const { return std::string(); } -void HtmlDialogUIDelegate::GetMinimumDialogSize(gfx::Size* size) const { +void WebDialogDelegate::GetMinimumDialogSize(gfx::Size* size) const { GetDialogSize(size); } -bool HtmlDialogUIDelegate::HandleContextMenu( +bool WebDialogDelegate::HandleContextMenu( const content::ContextMenuParams& params) { return false; } -bool HtmlDialogUIDelegate::HandleOpenURLFromTab( +bool WebDialogDelegate::HandleOpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params, content::WebContents** out_new_contents) { return false; } -bool HtmlDialogUIDelegate::HandleAddNewContents( +bool WebDialogDelegate::HandleAddNewContents( content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/ui/webui/html_dialog_ui.h b/chrome/browser/ui/webui/web_dialog_ui.h index 21dc9ab..43f1e5b 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.h +++ b/chrome/browser/ui/webui/web_dialog_ui.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_ #pragma once #include <string> @@ -33,7 +33,7 @@ class Size; } // Implement this class to receive notifications. -class HtmlDialogUIDelegate { +class WebDialogDelegate { public: // Returns true if the contents needs to be run in a modal dialog. virtual ui::ModalType GetDialogModalType() const = 0; @@ -113,10 +113,10 @@ class HtmlDialogUIDelegate { virtual void StoreDialogSize(const gfx::Size& dialog_size) {} protected: - virtual ~HtmlDialogUIDelegate() {} + virtual ~WebDialogDelegate() {} }; -// Displays file URL contents inside a modal HTML dialog. +// Displays file URL contents inside a modal web dialog. // // This application really should not use WebContents + WebUI. It should instead // just embed a RenderView in a dialog and be done with it. @@ -126,9 +126,9 @@ class HtmlDialogUIDelegate { // there and call it back. This is a bit of a hack to allow the dialog to pass // its delegate to the Web UI without having nasty accessors on the WebContents. // The correct design using RVH directly would avoid all of this. -class HtmlDialogUI : public content::WebUIController { +class WebDialogUI : public content::WebUIController { public: - struct HtmlDialogParams { + struct WebDialogParams { // The URL for the content that will be loaded in the dialog. GURL url; // Width of the dialog. @@ -140,15 +140,15 @@ class HtmlDialogUI : public content::WebUIController { }; // When created, the property should already be set on the WebContents. - explicit HtmlDialogUI(content::WebUI* web_ui); - virtual ~HtmlDialogUI(); + explicit WebDialogUI(content::WebUI* web_ui); + virtual ~WebDialogUI(); // Close the dialog, passing the specified arguments to the close handler. void CloseDialog(const base::ListValue* args); // Returns the PropertyBag accessor object used to write the delegate pointer // into the WebContents (see class-level comment above). - static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); + static base::PropertyAccessor<WebDialogDelegate*>& GetPropertyAccessor(); private: // WebUIController @@ -158,18 +158,18 @@ class HtmlDialogUI : public content::WebUIController { // JS message handler. void OnDialogClosed(const base::ListValue* args); - DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); + DISALLOW_COPY_AND_ASSIGN(WebDialogUI); }; -// Displays external URL contents inside a modal HTML dialog. +// Displays external URL contents inside a modal web dialog. // // Intended to be the place to collect the settings and lockdowns // necessary for running external UI components securely (e.g., the // cloud print dialog). -class ExternalHtmlDialogUI : public HtmlDialogUI { +class ExternalWebDialogUI : public WebDialogUI { public: - explicit ExternalHtmlDialogUI(content::WebUI* web_ui); - virtual ~ExternalHtmlDialogUI(); + explicit ExternalWebDialogUI(content::WebUI* web_ui); + virtual ~ExternalWebDialogUI(); }; -#endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_ diff --git a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.cc index b75942c..21ffe08 100644 --- a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.cc +++ b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tabs/tab_strip_model.h" @@ -20,18 +20,20 @@ using content::WebContents; // TODO(akalin): Should we make it so that we have a default incognito // profile that's long-lived? Of course, we'd still have to clear it out // when all incognito browsers close. -HtmlDialogTabContentsDelegate::HtmlDialogTabContentsDelegate(Profile* profile) - : profile_(profile) {} +WebDialogWebContentsDelegate::WebDialogWebContentsDelegate(Profile* profile) + : profile_(profile) { +} -HtmlDialogTabContentsDelegate::~HtmlDialogTabContentsDelegate() {} +WebDialogWebContentsDelegate::~WebDialogWebContentsDelegate() { +} -Profile* HtmlDialogTabContentsDelegate::profile() const { return profile_; } +Profile* WebDialogWebContentsDelegate::profile() const { return profile_; } -void HtmlDialogTabContentsDelegate::Detach() { +void WebDialogWebContentsDelegate::Detach() { profile_ = NULL; } -WebContents* HtmlDialogTabContentsDelegate::OpenURLFromTab( +WebContents* WebDialogWebContentsDelegate::OpenURLFromTab( WebContents* source, const OpenURLParams& params) { WebContents* new_contents = NULL; StaticOpenURLFromTab(profile_, source, params, &new_contents); @@ -39,7 +41,7 @@ WebContents* HtmlDialogTabContentsDelegate::OpenURLFromTab( } // static -Browser* HtmlDialogTabContentsDelegate::StaticOpenURLFromTab( +Browser* WebDialogWebContentsDelegate::StaticOpenURLFromTab( Profile* profile, WebContents* source, const OpenURLParams& params, WebContents** out_new_contents) { if (!profile) @@ -66,7 +68,7 @@ Browser* HtmlDialogTabContentsDelegate::StaticOpenURLFromTab( return nav_params.browser; } -void HtmlDialogTabContentsDelegate::AddNewContents( +void WebDialogWebContentsDelegate::AddNewContents( WebContents* source, WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture) { @@ -75,7 +77,7 @@ void HtmlDialogTabContentsDelegate::AddNewContents( } // static -Browser* HtmlDialogTabContentsDelegate::StaticAddNewContents( +Browser* WebDialogWebContentsDelegate::StaticAddNewContents( Profile* profile, WebContents* source, WebContents* new_contents, @@ -103,14 +105,14 @@ Browser* HtmlDialogTabContentsDelegate::StaticAddNewContents( return params.browser; } -bool HtmlDialogTabContentsDelegate::IsPopupOrPanel( +bool WebDialogWebContentsDelegate::IsPopupOrPanel( const WebContents* source) const { // This needs to return true so that we are allowed to be resized by our // contents. return true; } -bool HtmlDialogTabContentsDelegate::ShouldAddNavigationToHistory( +bool WebDialogWebContentsDelegate::ShouldAddNavigationToHistory( const history::HistoryAddPageArgs& add_page_args, content::NavigationType navigation_type) { return false; diff --git a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.h index e0cd210..eea5268 100644 --- a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h +++ b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_TAB_CONTENTS_DELEGATE_H_ -#define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_TAB_CONTENTS_DELEGATE_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ +#define CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ #pragma once #include "base/compiler_specific.h" @@ -13,11 +13,11 @@ class Browser; class Profile; // This class implements (and mostly ignores) most of -// content::WebContentsDelegate for use in an HTML dialog. Subclasses need only +// content::WebContentsDelegate for use in a Web dialog. Subclasses need only // override a few methods instead of the everything from // content::WebContentsDelegate; this way, implementations on all platforms // behave consistently. -class HtmlDialogTabContentsDelegate : public content::WebContentsDelegate { +class WebDialogWebContentsDelegate : public content::WebContentsDelegate { public: // Opens a new URL inside |source| (if source is NULL open in the current // front-most tab). |profile| is the profile that the browser should be owened @@ -43,9 +43,9 @@ class HtmlDialogTabContentsDelegate : public content::WebContentsDelegate { bool user_gesture); // Profile must be non-NULL. - explicit HtmlDialogTabContentsDelegate(Profile* profile); + explicit WebDialogWebContentsDelegate(Profile* profile); - virtual ~HtmlDialogTabContentsDelegate(); + virtual ~WebDialogWebContentsDelegate(); // The returned profile is guaranteed to be original if non-NULL. Profile* profile() const; @@ -73,6 +73,8 @@ class HtmlDialogTabContentsDelegate : public content::WebContentsDelegate { private: Profile* profile_; // Weak pointer. Always an original profile. + + DISALLOW_COPY_AND_ASSIGN(WebDialogWebContentsDelegate); }; -#endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_TAB_CONTENTS_DELEGATE_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_ diff --git a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc b/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc index cc07b5c..45d13f4 100644 --- a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc +++ b/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" +#include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" #include <vector> @@ -29,55 +29,55 @@ using content::WebContentsTester; namespace { -class TestTabContentsDelegate : public HtmlDialogTabContentsDelegate { +class TestWebContentsDelegate : public WebDialogWebContentsDelegate { public: - explicit TestTabContentsDelegate(Profile* profile) - : HtmlDialogTabContentsDelegate(profile) {} - - virtual ~TestTabContentsDelegate() { + explicit TestWebContentsDelegate(Profile* profile) + : WebDialogWebContentsDelegate(profile) { + } + virtual ~TestWebContentsDelegate() { } private: - DISALLOW_COPY_AND_ASSIGN(TestTabContentsDelegate); + DISALLOW_COPY_AND_ASSIGN(TestWebContentsDelegate); }; -class HtmlDialogTabContentsDelegateTest : public BrowserWithTestWindowTest { +class WebDialogWebContentsDelegateTest : public BrowserWithTestWindowTest { public: virtual void SetUp() { BrowserWithTestWindowTest::SetUp(); - test_tab_contents_delegate_.reset(new TestTabContentsDelegate(profile())); + test_web_contents_delegate_.reset(new TestWebContentsDelegate(profile())); } virtual void TearDown() { - test_tab_contents_delegate_.reset(NULL); + test_web_contents_delegate_.reset(NULL); BrowserWithTestWindowTest::TearDown(); } protected: - scoped_ptr<TestTabContentsDelegate> test_tab_contents_delegate_; + scoped_ptr<TestWebContentsDelegate> test_web_contents_delegate_; }; -TEST_F(HtmlDialogTabContentsDelegateTest, DoNothingMethodsTest) { +TEST_F(WebDialogWebContentsDelegateTest, DoNothingMethodsTest) { // None of the following calls should do anything. - EXPECT_TRUE(test_tab_contents_delegate_->IsPopupOrPanel(NULL)); + EXPECT_TRUE(test_web_contents_delegate_->IsPopupOrPanel(NULL)); scoped_refptr<history::HistoryAddPageArgs> should_add_args( new history::HistoryAddPageArgs( GURL(), base::Time::Now(), 0, 0, GURL(), history::RedirectList(), content::PAGE_TRANSITION_TYPED, history::SOURCE_SYNCED, false)); - EXPECT_FALSE(test_tab_contents_delegate_->ShouldAddNavigationToHistory( + EXPECT_FALSE(test_web_contents_delegate_->ShouldAddNavigationToHistory( *should_add_args, content::NAVIGATION_TYPE_NEW_PAGE)); - test_tab_contents_delegate_->NavigationStateChanged(NULL, 0); - test_tab_contents_delegate_->ActivateContents(NULL); - test_tab_contents_delegate_->LoadingStateChanged(NULL); - test_tab_contents_delegate_->CloseContents(NULL); - test_tab_contents_delegate_->UpdateTargetURL(NULL, 0, GURL()); - test_tab_contents_delegate_->MoveContents(NULL, gfx::Rect()); + test_web_contents_delegate_->NavigationStateChanged(NULL, 0); + test_web_contents_delegate_->ActivateContents(NULL); + test_web_contents_delegate_->LoadingStateChanged(NULL); + test_web_contents_delegate_->CloseContents(NULL); + test_web_contents_delegate_->UpdateTargetURL(NULL, 0, GURL()); + test_web_contents_delegate_->MoveContents(NULL, gfx::Rect()); EXPECT_EQ(0, browser()->tab_count()); EXPECT_EQ(1U, BrowserList::size()); } -TEST_F(HtmlDialogTabContentsDelegateTest, OpenURLFromTabTest) { - test_tab_contents_delegate_->OpenURLFromTab( +TEST_F(WebDialogWebContentsDelegateTest, OpenURLFromTabTest) { + test_web_contents_delegate_->OpenURLFromTab( NULL, OpenURLParams(GURL(chrome::kAboutBlankURL), Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); // This should create a new foreground tab in the existing browser. @@ -85,25 +85,25 @@ TEST_F(HtmlDialogTabContentsDelegateTest, OpenURLFromTabTest) { EXPECT_EQ(1U, BrowserList::size()); } -TEST_F(HtmlDialogTabContentsDelegateTest, AddNewContentsForegroundTabTest) { +TEST_F(WebDialogWebContentsDelegateTest, AddNewContentsForegroundTabTest) { WebContents* contents = WebContentsTester::CreateTestWebContents(profile(), NULL); - test_tab_contents_delegate_->AddNewContents( + test_web_contents_delegate_->AddNewContents( NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), false); // This should create a new foreground tab in the existing browser. EXPECT_EQ(1, browser()->tab_count()); EXPECT_EQ(1U, BrowserList::size()); } -TEST_F(HtmlDialogTabContentsDelegateTest, DetachTest) { - EXPECT_EQ(profile(), test_tab_contents_delegate_->profile()); - test_tab_contents_delegate_->Detach(); - EXPECT_EQ(NULL, test_tab_contents_delegate_->profile()); +TEST_F(WebDialogWebContentsDelegateTest, DetachTest) { + EXPECT_EQ(profile(), test_web_contents_delegate_->profile()); + test_web_contents_delegate_->Detach(); + EXPECT_EQ(NULL, test_web_contents_delegate_->profile()); // Now, none of the following calls should do anything. - test_tab_contents_delegate_->OpenURLFromTab( + test_web_contents_delegate_->OpenURLFromTab( NULL, OpenURLParams(GURL(chrome::kAboutBlankURL), Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); - test_tab_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB, + test_web_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB, gfx::Rect(), false); EXPECT_EQ(0, browser()->tab_count()); EXPECT_EQ(1U, BrowserList::size()); |