| Index: chrome/browser/ui/views/web_dialog_view.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/web_dialog_view.cc (revision 133680)
|
| +++ chrome/browser/ui/views/web_dialog_view.cc (working copy)
|
| @@ -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 @@
|
| 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 @@
|
| 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 @@
|
| 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::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 @@
|
| // 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 @@
|
| #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 @@
|
| 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 @@
|
| 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));
|
|
|
|
|