diff options
author | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 19:48:20 +0000 |
---|---|---|
committer | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 19:48:20 +0000 |
commit | 6ae4f14712fe01adc01a54efe15a6c27758cd910 (patch) | |
tree | 50bd84d615103ced69c1999ae134eabcbe25e394 | |
parent | 5ff5d539c420dd888d75c3e3c662f66ac24786e6 (diff) | |
download | chromium_src-6ae4f14712fe01adc01a54efe15a6c27758cd910.zip chromium_src-6ae4f14712fe01adc01a54efe15a6c27758cd910.tar.gz chromium_src-6ae4f14712fe01adc01a54efe15a6c27758cd910.tar.bz2 |
Remove the usage of Profile in WebDialogView.
BUG=124222
TEST=try
Review URL: https://chromiumcodereview.appspot.com/10496009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141942 0039d316-1c4b-4281-b951-d872f2087c98
14 files changed, 65 insertions, 48 deletions
diff --git a/chrome/browser/ui/browser_dialogs.h b/chrome/browser/ui/browser_dialogs.h index 7d7ca56..1fc1508 100644 --- a/chrome/browser/ui/browser_dialogs.h +++ b/chrome/browser/ui/browser_dialogs.h @@ -17,6 +17,7 @@ class TabModalConfirmDialogDelegate; class TemplateURL; namespace content { +class BrowserContext; class WebContents; } @@ -48,7 +49,7 @@ 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 ShowWebDialog(gfx::NativeWindow parent, - Profile* profile, + content::BrowserContext* context, ui::WebDialogDelegate* delegate); // Shows the collected cookies dialog box. diff --git a/chrome/browser/ui/cocoa/web_dialog_window_controller.h b/chrome/browser/ui/cocoa/web_dialog_window_controller.h index 288ad75..44404b2 100644 --- a/chrome/browser/ui/cocoa/web_dialog_window_controller.h +++ b/chrome/browser/ui/cocoa/web_dialog_window_controller.h @@ -14,9 +14,12 @@ #include "ui/web_dialogs/web_dialog_ui.h" class Browser; -class WebDialogWindowDelegateBridge; -class Profile; class TabContents; +class WebDialogWindowDelegateBridge; + +namespace content { +class BrowserContext; +} // This controller manages a dialog box with properties and HTML content taken // from a WebDialogDelegate object. @@ -36,7 +39,7 @@ class TabContents; // 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*)showWebDialog:(ui::WebDialogDelegate*)delegate - profile:(Profile*)profile + context:(content::BrowserContext*)context browser:(Browser*)browser; @end @@ -46,7 +49,7 @@ class TabContents; // This is the designated initializer. However, this is exposed only // for testing; use showWebDialog instead. - (id)initWithDelegate:(ui::WebDialogDelegate*)delegate - profile:(Profile*)profile + context:(content::BrowserContext*)context browser:(Browser*)browser; // Loads the HTML content from the delegate; this is not a lightweight diff --git a/chrome/browser/ui/cocoa/web_dialog_window_controller.mm b/chrome/browser/ui/cocoa/web_dialog_window_controller.mm index 1a52c15..bee34c8 100644 --- a/chrome/browser/ui/cocoa/web_dialog_window_controller.mm +++ b/chrome/browser/ui/cocoa/web_dialog_window_controller.mm @@ -38,7 +38,7 @@ class WebDialogWindowDelegateBridge public: // All parameters must be non-NULL/non-nil. WebDialogWindowDelegateBridge(WebDialogWindowController* controller, - Profile* profile, + content::BrowserContext* context, Browser* browser, WebDialogDelegate* delegate); @@ -101,12 +101,13 @@ private: namespace browser { gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, - Profile* profile, + content::BrowserContext* context, WebDialogDelegate* delegate) { // TODO(mazda): Remove the dependency on Browser. - Browser* browser = browser::FindLastActiveWithProfile(profile); + Browser* browser = + browser::FindLastActiveWithProfile(Profile::FromBrowserContext(context)); return [WebDialogWindowController showWebDialog:delegate - profile:profile + context:context browser:browser]; } @@ -118,13 +119,13 @@ void CloseWDialog(gfx::NativeWindow window) { WebDialogWindowDelegateBridge::WebDialogWindowDelegateBridge( WebDialogWindowController* controller, - Profile* profile, + content::BrowserContext* context, Browser* browser, WebDialogDelegate* delegate) - : WebDialogWebContentsDelegate(profile), + : WebDialogWebContentsDelegate(context), controller_(controller), delegate_(delegate), - dialog_controller_(new WebDialogController(this, profile, browser)) { + dialog_controller_(new WebDialogController(this, context, browser)) { DCHECK(controller_); DCHECK(delegate_); } @@ -307,11 +308,11 @@ void WebDialogWindowDelegateBridge::HandleKeyboardEvent( // in once we implement modal dialogs. + (NSWindow*)showWebDialog:(WebDialogDelegate*)delegate - profile:(Profile*)profile + context:(content::BrowserContext*)context browser:(Browser*)browser { WebDialogWindowController* webDialogWindowController = [[WebDialogWindowController alloc] initWithDelegate:delegate - profile:profile + context:context browser:browser]; [webDialogWindowController loadDialogContents]; [webDialogWindowController showWindow:nil]; @@ -319,10 +320,10 @@ void WebDialogWindowDelegateBridge::HandleKeyboardEvent( } - (id)initWithDelegate:(WebDialogDelegate*)delegate - profile:(Profile*)profile + context:(content::BrowserContext*)context browser:(Browser*)browser { DCHECK(delegate); - DCHECK(profile); + DCHECK(context); gfx::Size dialogSize; delegate->GetDialogSize(&dialogSize); @@ -348,7 +349,7 @@ void WebDialogWindowDelegateBridge::HandleKeyboardEvent( [window setMinSize:dialogRect.size]; [window center]; delegate_.reset( - new WebDialogWindowDelegateBridge(self, profile, browser, delegate)); + new WebDialogWindowDelegateBridge(self, context, browser, delegate)); return self; } diff --git a/chrome/browser/ui/cocoa/web_dialog_window_controller_unittest.mm b/chrome/browser/ui/cocoa/web_dialog_window_controller_unittest.mm index 571fcae..f9c99f3 100644 --- a/chrome/browser/ui/cocoa/web_dialog_window_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/web_dialog_window_controller_unittest.mm @@ -91,7 +91,7 @@ TEST_F(WebDialogWindowControllerTest, showDialog) { WebDialogWindowController* web_dialog_window_controller = [[WebDialogWindowController alloc] initWithDelegate:&delegate_ - profile:profile() + context:profile() browser:browser()]; [web_dialog_window_controller loadDialogContents]; diff --git a/chrome/browser/ui/gtk/web_dialog_gtk.cc b/chrome/browser/ui/gtk/web_dialog_gtk.cc index abd879f..c8c5e09 100644 --- a/chrome/browser/ui/gtk/web_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/web_dialog_gtk.cc @@ -30,12 +30,13 @@ using ui::WebDialogUI; namespace browser { gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, - Profile* profile, + content::BrowserContext* context, WebDialogDelegate* delegate) { // TODO(mazda): Remove the dependency on Browser. - Browser* browser = browser::FindLastActiveWithProfile(profile); + Browser* browser = + browser::FindLastActiveWithProfile(Profile::FromBrowserContext(context)); WebDialogGtk* web_dialog = - new WebDialogGtk(profile, browser, delegate, parent); + new WebDialogGtk(context, browser, delegate, parent); return web_dialog->InitDialog(); } @@ -64,15 +65,15 @@ void SetDialogStyle() { //////////////////////////////////////////////////////////////////////////////// // WebDialogGtk, public: -WebDialogGtk::WebDialogGtk(Profile* profile, +WebDialogGtk::WebDialogGtk(content::BrowserContext* context, Browser* browser, WebDialogDelegate* delegate, gfx::NativeWindow parent_window) - : WebDialogWebContentsDelegate(profile), + : WebDialogWebContentsDelegate(context), delegate_(delegate), parent_window_(parent_window), dialog_(NULL), - dialog_controller_(new WebDialogController(this, profile, browser)) { + dialog_controller_(new WebDialogController(this, context, browser)) { } WebDialogGtk::~WebDialogGtk() { diff --git a/chrome/browser/ui/gtk/web_dialog_gtk.h b/chrome/browser/ui/gtk/web_dialog_gtk.h index 9529842..b0f3283 100644 --- a/chrome/browser/ui/gtk/web_dialog_gtk.h +++ b/chrome/browser/ui/gtk/web_dialog_gtk.h @@ -20,15 +20,18 @@ typedef struct _GtkWidget GtkWidget; class Browser; -class Profile; class TabContentsContainerGtk; class TabContents; class WebDialogController; +namespace content { +class BrowserContext; +} + class WebDialogGtk : public WebDialogWebContentsDelegate, public ui::WebDialogDelegate { public: - WebDialogGtk(Profile* profile, + WebDialogGtk(content::BrowserContext* context, Browser* browser, ui::WebDialogDelegate* delegate, gfx::NativeWindow parent_window); diff --git a/chrome/browser/ui/views/web_dialog_view.cc b/chrome/browser/ui/views/web_dialog_view.cc index c141077..3e35a12 100644 --- a/chrome/browser/ui/views/web_dialog_view.cc +++ b/chrome/browser/ui/views/web_dialog_view.cc @@ -8,8 +8,8 @@ #include "base/property_bag.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser_dialogs.h" +#include "content/public/browser/browser_context.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_source.h" @@ -39,10 +39,10 @@ namespace browser { // Declared in browser_dialogs.h so that others don't need to depend on our .h. gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, - Profile* profile, + content::BrowserContext* context, WebDialogDelegate* delegate) { views::Widget* widget = views::Widget::CreateWindowWithParent( - new WebDialogView(profile, delegate), parent); + new WebDialogView(context, delegate), parent); widget->Show(); return widget->GetNativeWindow(); } @@ -52,13 +52,13 @@ gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, //////////////////////////////////////////////////////////////////////////////// // WebDialogView, public: -WebDialogView::WebDialogView(Profile* profile, +WebDialogView::WebDialogView(content::BrowserContext* context, WebDialogDelegate* delegate) : ClientView(NULL, NULL), - WebDialogWebContentsDelegate(profile), + WebDialogWebContentsDelegate(context), initialized_(false), delegate_(delegate), - web_view_(new views::WebView(profile)) { + web_view_(new views::WebView(context)) { web_view_->set_allow_accelerators(true); AddChildView(web_view_); set_contents_view(web_view_); diff --git a/chrome/browser/ui/views/web_dialog_view.h b/chrome/browser/ui/views/web_dialog_view.h index e6a718c4..b22d108 100644 --- a/chrome/browser/ui/views/web_dialog_view.h +++ b/chrome/browser/ui/views/web_dialog_view.h @@ -18,7 +18,9 @@ #include "ui/views/window/client_view.h" #include "ui/web_dialogs/web_dialog_delegate.h" -class Profile; +namespace content { +class BrowserContext; +} namespace views { class WebView; @@ -37,16 +39,13 @@ class WebView; // 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 Profile, only -// content::BrowserContext. -class WebDialogView - : public views::ClientView, - public WebDialogWebContentsDelegate, - public ui::WebDialogDelegate, - public views::WidgetDelegate, - public TabRenderWatcher::Delegate { +class WebDialogView : public views::ClientView, + public WebDialogWebContentsDelegate, + public ui::WebDialogDelegate, + public views::WidgetDelegate, + public TabRenderWatcher::Delegate { public: - WebDialogView(Profile* profile, + WebDialogView(content::BrowserContext* context, ui::WebDialogDelegate* delegate); virtual ~WebDialogView(); diff --git a/chrome/browser/ui/views/web_dialog_view_browsertest.cc b/chrome/browser/ui/views/web_dialog_view_browsertest.cc index 4086563..272d9a5 100644 --- a/chrome/browser/ui/views/web_dialog_view_browsertest.cc +++ b/chrome/browser/ui/views/web_dialog_view_browsertest.cc @@ -8,12 +8,14 @@ #include "base/memory/singleton.h" #include "base/message_loop.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.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" +#include "content/public/browser/browser_context.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" diff --git a/chrome/browser/ui/webui/web_dialog_controller.cc b/chrome/browser/ui/webui/web_dialog_controller.cc index 50b7298..90515a7 100644 --- a/chrome/browser/ui/webui/web_dialog_controller.cc +++ b/chrome/browser/ui/webui/web_dialog_controller.cc @@ -7,6 +7,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_notification_types.h" +#include "content/public/browser/browser_context.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "ui/web_dialogs/web_dialog_delegate.h" @@ -15,7 +16,7 @@ using ui::WebDialogDelegate; WebDialogController::WebDialogController( WebDialogDelegate* delegate, - Profile* profile, + content::BrowserContext* context, Browser* browser) : dialog_delegate_(delegate) { // It's only safe to show an off the record profile under one of two @@ -23,6 +24,7 @@ WebDialogController::WebDialogController( // 1. For a modal dialog where the parent will maintain the profile. // 2. If we have a browser which will keep the reference to this profile // alive. The dialog will be closed if this browser is closed. + Profile* profile = Profile::FromBrowserContext(context); DCHECK(!profile->IsOffTheRecord() || delegate->GetDialogModalType() != ui::MODAL_TYPE_NONE || (browser && browser->profile() == profile)); diff --git a/chrome/browser/ui/webui/web_dialog_controller.h b/chrome/browser/ui/webui/web_dialog_controller.h index 7188a38..cb2ce57 100644 --- a/chrome/browser/ui/webui/web_dialog_controller.h +++ b/chrome/browser/ui/webui/web_dialog_controller.h @@ -11,7 +11,10 @@ #include "ui/web_dialogs/web_dialog_ui.h" class Browser; -class Profile; + +namespace content { +class BrowserContext; +} // This provides the common functionality for WebDialogs of notifying the // dialog that it should close when the browser that created it has closed to @@ -19,7 +22,7 @@ class Profile; class WebDialogController : public content::NotificationObserver { public: WebDialogController(ui::WebDialogDelegate* delegate, - Profile* profile, + content::BrowserContext* context, Browser* browser); // content::NotificationObserver implementation. diff --git a/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc b/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc index 7d34bf4..fa20fc9 100644 --- a/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc +++ b/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/memory/scoped_ptr.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/webui/test_web_dialog_delegate.h" #include "chrome/browser/ui/webui/web_dialog_controller.h" diff --git a/chrome/browser/ui/webui/web_dialog_web_contents_delegate.cc b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.cc index 25737ca..116497b 100644 --- a/chrome/browser/ui/webui/web_dialog_web_contents_delegate.cc +++ b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.cc @@ -20,8 +20,9 @@ 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. -WebDialogWebContentsDelegate::WebDialogWebContentsDelegate(Profile* profile) - : profile_(profile) { +WebDialogWebContentsDelegate::WebDialogWebContentsDelegate( + content::BrowserContext* context) + : profile_(Profile::FromBrowserContext(context)) { } WebDialogWebContentsDelegate::~WebDialogWebContentsDelegate() { diff --git a/chrome/browser/ui/webui/web_dialog_web_contents_delegate.h b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.h index eea5268..080a514 100644 --- a/chrome/browser/ui/webui/web_dialog_web_contents_delegate.h +++ b/chrome/browser/ui/webui/web_dialog_web_contents_delegate.h @@ -43,7 +43,7 @@ class WebDialogWebContentsDelegate : public content::WebContentsDelegate { bool user_gesture); // Profile must be non-NULL. - explicit WebDialogWebContentsDelegate(Profile* profile); + explicit WebDialogWebContentsDelegate(content::BrowserContext* context); virtual ~WebDialogWebContentsDelegate(); |