summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_about_handler.cc2
-rw-r--r--chrome/browser/collected_cookies_browsertest.cc8
-rw-r--r--chrome/browser/ui/browser.cc5
-rw-r--r--chrome/browser/ui/browser_commands.cc8
-rw-r--r--chrome/browser/ui/browser_content_setting_bubble_model_delegate.cc4
-rw-r--r--chrome/browser/ui/browser_dialogs.h26
-rw-r--r--chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm11
-rw-r--r--chrome/browser/ui/cocoa/hung_renderer_controller.h4
-rw-r--r--chrome/browser/ui/cocoa/hung_renderer_controller.mm33
-rw-r--r--chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h10
-rw-r--r--chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm60
-rw-r--r--chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm4
-rw-r--r--chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h7
-rw-r--r--chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm30
-rw-r--r--chrome/browser/ui/cocoa/tab_dialogs_cocoa.h34
-rw-r--r--chrome/browser/ui/cocoa/tab_dialogs_cocoa.mm56
-rw-r--r--chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm4
-rw-r--r--chrome/browser/ui/passwords/manage_passwords_ui_controller.cc5
-rw-r--r--chrome/browser/ui/sync/one_click_signin_sync_starter.cc6
-rw-r--r--chrome/browser/ui/tab_dialogs.cc21
-rw-r--r--chrome/browser/ui/tab_dialogs.h59
-rw-r--r--chrome/browser/ui/tab_helpers.cc2
-rw-r--r--chrome/browser/ui/views/collected_cookies_views.cc10
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc1
-rw-r--r--chrome/browser/ui/views/hung_renderer_view.cc51
-rw-r--r--chrome/browser/ui/views/hung_renderer_view.h4
-rw-r--r--chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc32
-rw-r--r--chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc16
-rw-r--r--chrome/browser/ui/views/tab_dialogs_views.cc68
-rw-r--r--chrome/browser/ui/views/tab_dialogs_views.h35
-rw-r--r--chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc19
31 files changed, 392 insertions, 243 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index a01735f..7d19585 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -6,7 +6,9 @@
#include <string>
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/browser_dialogs.h"
diff --git a/chrome/browser/collected_cookies_browsertest.cc b/chrome/browser/collected_cookies_browsertest.cc
index bcabfac..687ea6d 100644
--- a/chrome/browser/collected_cookies_browsertest.cc
+++ b/chrome/browser/collected_cookies_browsertest.cc
@@ -7,7 +7,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/content_settings/cookie_settings.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_dialogs.h"
+#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -31,8 +31,8 @@ IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, DoubleDisplay) {
// Click on the info link twice.
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
- chrome::ShowCollectedCookiesDialog(web_contents);
- chrome::ShowCollectedCookiesDialog(web_contents);
+ TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
+ TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
}
// If this crashes on Windows, use http://crbug.com/79331
@@ -50,7 +50,7 @@ IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, NavigateAway) {
// Click on the info link.
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
- chrome::ShowCollectedCookiesDialog(web_contents);
+ TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
// Navigate to another page.
ui_test_utils::NavigateToURL(
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index e4a22e9..702f432 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -124,6 +124,7 @@
#include "chrome/browser/ui/status_bubble.h"
#include "chrome/browser/ui/sync/browser_synced_window_delegate.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
+#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/browser/ui/tab_helpers.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog.h"
#include "chrome/browser/ui/tabs/tab_menu_model.h"
@@ -1611,11 +1612,11 @@ void Browser::RendererUnresponsive(WebContents* source) {
if (tab_strip_model_->IsTabBlocked(index))
return;
- chrome::ShowHungRendererDialog(source);
+ TabDialogs::FromWebContents(source)->ShowHungRendererDialog();
}
void Browser::RendererResponsive(WebContents* source) {
- chrome::HideHungRendererDialog(source);
+ TabDialogs::FromWebContents(source)->HideHungRendererDialog();
}
void Browser::WorkerCrashed(WebContents* source) {
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index 4992f92..244d459 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -45,10 +45,12 @@
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/find_bar/find_tab_helper.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
+#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/search/search_tab_helper.h"
#include "chrome/browser/ui/status_bubble.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
+#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/upgrade_detector.h"
#include "chrome/common/chrome_switches.h"
@@ -814,7 +816,11 @@ void ManagePasswordsForPage(Browser* browser) {
WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
- chrome::ShowManagePasswordsBubble(web_contents);
+ ManagePasswordsUIController* controller =
+ ManagePasswordsUIController::FromWebContents(web_contents);
+ TabDialogs::FromWebContents(web_contents)
+ ->ShowManagePasswordsBubble(
+ !password_manager::ui::IsAutomaticDisplayState(controller->state()));
}
#if defined(OS_WIN)
diff --git a/chrome/browser/ui/browser_content_setting_bubble_model_delegate.cc b/chrome/browser/ui/browser_content_setting_bubble_model_delegate.cc
index 3ee712a..3bcdd11 100644
--- a/chrome/browser/ui/browser_content_setting_bubble_model_delegate.cc
+++ b/chrome/browser/ui/browser_content_setting_bubble_model_delegate.cc
@@ -6,9 +6,9 @@
#include "chrome/browser/content_settings/chrome_content_settings_utils.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/common/url_constants.h"
#include "components/google/core/browser/google_util.h"
@@ -27,7 +27,7 @@ BrowserContentSettingBubbleModelDelegate::
void BrowserContentSettingBubbleModelDelegate::ShowCollectedCookiesDialog(
content::WebContents* web_contents) {
- chrome::ShowCollectedCookiesDialog(web_contents);
+ TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
}
void BrowserContentSettingBubbleModelDelegate::ShowContentSettingsPage(
diff --git a/chrome/browser/ui/browser_dialogs.h b/chrome/browser/ui/browser_dialogs.h
index 8a4aa9d..2d78b9e 100644
--- a/chrome/browser/ui/browser_dialogs.h
+++ b/chrome/browser/ui/browser_dialogs.h
@@ -6,16 +6,13 @@
#define CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
#include "base/callback.h"
-#include "chrome/browser/profiles/profile_window.h"
#include "content/public/common/signed_certificate_timestamp_id_and_status.h"
-#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/native_widget_types.h"
class Browser;
class Profile;
class SkBitmap;
-class TabModalConfirmDialogDelegate;
namespace content {
class BrowserContext;
@@ -28,7 +25,6 @@ class Extension;
}
namespace ui {
-class ProfileSigninConfirmationDelegate;
class WebDialogDelegate;
}
@@ -44,9 +40,6 @@ gfx::NativeWindow ShowWebDialog(gfx::NativeView parent,
content::BrowserContext* context,
ui::WebDialogDelegate* delegate);
-// Shows the collected cookies dialog box.
-void ShowCollectedCookiesDialog(content::WebContents* web_contents);
-
// Creates the ExtensionInstalledBubble and schedules it to be shown once
// the extension has loaded. |extension| is the installed extension. |browser|
// is the browser window which will host the bubble. |icon| is the install
@@ -55,12 +48,6 @@ void ShowExtensionInstalledBubble(const extensions::Extension* extension,
Browser* browser,
const SkBitmap& icon);
-// Shows or hide the hung renderer dialog for the given WebContents.
-// We need to pass the WebContents to the dialog, because multiple tabs can hang
-// and it needs to keep track of which tabs are currently hung.
-void ShowHungRendererDialog(content::WebContents* contents);
-void HideHungRendererDialog(content::WebContents* contents);
-
// Shows or hides the Task Manager. |browser| can be NULL when called from Ash.
void ShowTaskManager(Browser* browser);
void HideTaskManager();
@@ -83,25 +70,12 @@ void ShowCreateChromeAppShortcutsDialog(
content::ColorChooser* ShowColorChooser(content::WebContents* web_contents,
SkColor initial_color);
-void ShowProfileSigninConfirmationDialog(
- Browser* browser,
- content::WebContents* web_contents,
- Profile* profile,
- const std::string& username,
- ui::ProfileSigninConfirmationDelegate* delegate);
-
// Shows the Signed Certificate Timestamps viewer, to view the signed
// certificate timestamps in |sct_ids_list|
void ShowSignedCertificateTimestampsViewer(
content::WebContents* web_contents,
const content::SignedCertificateTimestampIDStatusList& sct_ids_list);
-// Shows the ManagePasswords bubble for a particular |web_contents|.
-void ShowManagePasswordsBubble(content::WebContents* web_contents);
-
-// Closes the bubble if it's shown for |web_contents|.
-void CloseManagePasswordsBubble(content::WebContents* web_contents);
-
} // namespace chrome
#endif // CHROME_BROWSER_UI_BROWSER_DIALOGS_H_
diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm
index 52c0115..4644170 100644
--- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm
+++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm
@@ -15,7 +15,6 @@
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.h"
#import "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controller.h"
#import "chrome/browser/ui/cocoa/vertical_gradient_view.h"
@@ -50,16 +49,6 @@ enum TabViewItemIndices {
} // namespace
-namespace chrome {
-
-// Declared in browser_dialogs.h so others don't have to depend on our header.
-void ShowCollectedCookiesDialog(content::WebContents* web_contents) {
- // Deletes itself on close.
- new CollectedCookiesMac(web_contents);
-}
-
-} // namespace chrome
-
#pragma mark Constrained window delegate
CollectedCookiesMac::CollectedCookiesMac(content::WebContents* web_contents) {
diff --git a/chrome/browser/ui/cocoa/hung_renderer_controller.h b/chrome/browser/ui/cocoa/hung_renderer_controller.h
index 5e03a17..58a662b 100644
--- a/chrome/browser/ui/cocoa/hung_renderer_controller.h
+++ b/chrome/browser/ui/cocoa/hung_renderer_controller.h
@@ -53,6 +53,10 @@ class WebContents;
base::scoped_nsobject<NSArray> hungFavicons_;
}
+// Shows or hides the hung renderer dialog for the given WebContents.
++ (void)showForWebContents:(content::WebContents*)contents;
++ (void)endForWebContents:(content::WebContents*)contents;
+
// Kills the hung renderers.
- (IBAction)kill:(id)sender;
diff --git a/chrome/browser/ui/cocoa/hung_renderer_controller.mm b/chrome/browser/ui/cocoa/hung_renderer_controller.mm
index 125939b..8a5af60 100644
--- a/chrome/browser/ui/cocoa/hung_renderer_controller.mm
+++ b/chrome/browser/ui/cocoa/hung_renderer_controller.mm
@@ -10,7 +10,6 @@
#include "base/mac/mac_util.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#import "chrome/browser/ui/cocoa/multi_key_equivalent_button.h"
#import "chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
@@ -107,6 +106,20 @@ class HungRendererWebContentsObserverBridge
[waitButton_ addKeyEquivalent:key];
}
++ (void)showForWebContents:(content::WebContents*)contents {
+ if (!logging::DialogsAreSuppressed()) {
+ if (!g_instance)
+ g_instance = [[HungRendererController alloc]
+ initWithWindowNibName:@"HungRendererDialog"];
+ [g_instance showForWebContents:contents];
+ }
+}
+
++ (void)endForWebContents:(content::WebContents*)contents {
+ if (!logging::DialogsAreSuppressed() && g_instance)
+ [g_instance endForWebContents:contents];
+}
+
- (IBAction)kill:(id)sender {
if (hungContents_)
base::KillProcess(hungContents_->GetRenderProcessHost()->GetHandle(),
@@ -217,21 +230,3 @@ class HungRendererWebContentsObserverBridge
return waitButton_;
}
@end
-
-namespace chrome {
-
-void ShowHungRendererDialog(WebContents* contents) {
- if (!logging::DialogsAreSuppressed()) {
- if (!g_instance)
- g_instance = [[HungRendererController alloc]
- initWithWindowNibName:@"HungRendererDialog"];
- [g_instance showForWebContents:contents];
- }
-}
-
-void HideHungRendererDialog(WebContents* contents) {
- if (!logging::DialogsAreSuppressed() && g_instance)
- [g_instance endForWebContents:contents];
-}
-
-} // namespace chrome
diff --git a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h
index 7143598..4b7b2dd 100644
--- a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h
+++ b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h
@@ -14,10 +14,6 @@ namespace content {
class WebContents;
}
-namespace chrome {
-void ShowManagePasswordsBubble(content::WebContents* webContents);
-}
-
@class ManagePasswordsBubbleController;
@class ManagePasswordsBubbleCocoaNotificationBridge;
class ManagePasswordsIcon;
@@ -27,9 +23,7 @@ class ManagePasswordsBubbleCocoa : public ManagePasswordsBubble {
public:
// Creates and shows the bubble, which owns itself. Does nothing if the bubble
// is already shown.
- static void ShowBubble(content::WebContents* webContents,
- DisplayReason displayReason,
- ManagePasswordsIcon* icon);
+ static void Show(content::WebContents* webContents, bool user_action);
// Closes and deletes the bubble.
void Close();
@@ -43,8 +37,6 @@ class ManagePasswordsBubbleCocoa : public ManagePasswordsBubble {
private:
friend class ManagePasswordsBubbleCocoaTest;
friend class ManagePasswordsBubbleTest;
- friend void chrome::ShowManagePasswordsBubble(
- content::WebContents* webContents);
// Instance-specific logic. Clients should use the static interface.
ManagePasswordsBubbleCocoa(content::WebContents* webContents,
diff --git a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm
index 739c43d5..4f19743 100644
--- a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm
+++ b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm
@@ -5,14 +5,12 @@
#import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h"
#include "base/mac/scoped_block.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
#import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller.h"
#include "chrome/browser/ui/passwords/manage_passwords_icon.h"
-#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "content/public/browser/web_contents.h"
typedef void (^Callback)(void);
@@ -39,37 +37,6 @@ typedef void (^Callback)(void);
// static
ManagePasswordsBubbleCocoa* ManagePasswordsBubbleCocoa::bubble_ = NULL;
-namespace chrome {
-void ShowManagePasswordsBubble(content::WebContents* webContents) {
- ManagePasswordsBubbleCocoa* instance = ManagePasswordsBubbleCocoa::instance();
- if (instance && (instance->webContents_ != webContents)) {
- // The bubble is currently shown for some other tab. We should close it now
- // and open for |webContents|.
- instance->Close();
- }
-
- ManagePasswordsUIController* controller =
- ManagePasswordsUIController::FromWebContents(webContents);
- NSWindow* window = [webContents->GetNativeView() window];
- if (!window) {
- // The tab isn't active right now.
- return;
- }
- BrowserWindowController* bwc =
- [BrowserWindowController browserWindowControllerForWindow:window];
- ManagePasswordsBubbleCocoa::ShowBubble(
- webContents,
- password_manager::ui::IsAutomaticDisplayState(controller->state())
- ? ManagePasswordsBubble::AUTOMATIC
- : ManagePasswordsBubble::USER_ACTION,
- [bwc locationBarBridge]->manage_passwords_decoration()->icon());
-}
-
-void CloseManagePasswordsBubble(content::WebContents* web_contents) {
- // The bubble is closed when it loses the focus.
-}
-} // namespace chrome
-
ManagePasswordsBubbleCocoa::ManagePasswordsBubbleCocoa(
content::WebContents* webContents,
DisplayReason displayReason,
@@ -86,7 +53,7 @@ ManagePasswordsBubbleCocoa::ManagePasswordsBubbleCocoa(
ManagePasswordsBubbleCocoa::~ManagePasswordsBubbleCocoa() {
[[NSNotificationCenter defaultCenter] removeObserver:bridge_];
- // Clear the global instance pointer.
+ // Clear the global bubble_ pointer.
bubble_ = NULL;
if (icon_)
icon_->SetActive(false);
@@ -130,11 +97,28 @@ void ManagePasswordsBubbleCocoa::OnClose() {
}
// static
-void ManagePasswordsBubbleCocoa::ShowBubble(content::WebContents* webContents,
- DisplayReason displayReason,
- ManagePasswordsIcon* icon) {
+void ManagePasswordsBubbleCocoa::Show(content::WebContents* webContents,
+ bool user_action) {
+ if (bubble_ && (bubble_->webContents_ != webContents)) {
+ // The bubble is currently shown for some other tab. We should close it now
+ // and open for |webContents|.
+ bubble_->Close();
+ }
if (bubble_)
return;
- bubble_ = new ManagePasswordsBubbleCocoa(webContents, displayReason, icon);
+
+ NSWindow* window = [webContents->GetNativeView() window];
+ if (!window) {
+ // The tab isn't active right now.
+ return;
+ }
+ BrowserWindowController* bwc =
+ [BrowserWindowController browserWindowControllerForWindow:window];
+ bubble_ = new ManagePasswordsBubbleCocoa(
+ webContents,
+ user_action ? ManagePasswordsBubble::USER_ACTION
+ : ManagePasswordsBubble::AUTOMATIC,
+ [bwc locationBarBridge]->manage_passwords_decoration()->icon());
+
bubble_->Show();
}
diff --git a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm
index 11080b01..e678e3d 100644
--- a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm
+++ b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm
@@ -19,6 +19,7 @@
#import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller.h"
#include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
+#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/site_instance.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -54,7 +55,8 @@ class ManagePasswordsBubbleCocoaTest : public CocoaProfileTest {
}
void ShowBubble() {
- chrome::ShowManagePasswordsBubble(test_web_contents_);
+ TabDialogs::FromWebContents(test_web_contents_)
+ ->ShowManagePasswordsBubble(false);
if (ManagePasswordsBubbleCocoa::instance()) {
// Disable animations so that closing happens immediately.
InfoBubbleWindow* bubbleWindow = base::mac::ObjCCast<InfoBubbleWindow>(
diff --git a/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h b/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h
index 6aee999..47160ae 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h
+++ b/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h
@@ -41,6 +41,13 @@ class ProfileSigninConfirmationDialogCocoa : ConstrainedWindowMacDelegate {
bool offer_profile_creation);
virtual ~ProfileSigninConfirmationDialogCocoa();
+ // Shows the dialog if needed.
+ static void Show(Browser* browser,
+ content::WebContents* web_contents,
+ Profile* profile,
+ const std::string& username,
+ ui::ProfileSigninConfirmationDelegate* delegate);
+
// Closes the dialog, which deletes itself.
void Close();
diff --git a/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm b/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm
index 44fa0c3..a46b4eb 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm
@@ -6,7 +6,6 @@
#include "base/message_loop/message_loop.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.h"
@@ -35,23 +34,6 @@ void ShowDialog(
} // namespace
-namespace chrome {
-
-// Declared in browser_dialogs.h
-void ShowProfileSigninConfirmationDialog(
- Browser* browser,
- content::WebContents* web_contents,
- Profile* profile,
- const std::string& username,
- ui::ProfileSigninConfirmationDelegate* delegate) {
- ui::CheckShouldPromptForNewProfile(
- profile,
- base::Bind(ShowDialog,
- browser, web_contents, profile, username, delegate));
-}
-
-} // namespace chrome
-
ProfileSigninConfirmationDialogCocoa::ProfileSigninConfirmationDialogCocoa(
Browser* browser,
content::WebContents* web_contents,
@@ -83,6 +65,18 @@ ProfileSigninConfirmationDialogCocoa::ProfileSigninConfirmationDialogCocoa(
ProfileSigninConfirmationDialogCocoa::~ProfileSigninConfirmationDialogCocoa() {
}
+// static
+void ProfileSigninConfirmationDialogCocoa::Show(
+ Browser* browser,
+ content::WebContents* web_contents,
+ Profile* profile,
+ const std::string& username,
+ ui::ProfileSigninConfirmationDelegate* delegate) {
+ ui::CheckShouldPromptForNewProfile(
+ profile, base::Bind(ShowDialog, browser, web_contents, profile, username,
+ delegate));
+}
+
void ProfileSigninConfirmationDialogCocoa::Close() {
window_->CloseWebContentsModalDialog();
}
diff --git a/chrome/browser/ui/cocoa/tab_dialogs_cocoa.h b/chrome/browser/ui/cocoa/tab_dialogs_cocoa.h
new file mode 100644
index 0000000..593680b
--- /dev/null
+++ b/chrome/browser/ui/cocoa/tab_dialogs_cocoa.h
@@ -0,0 +1,34 @@
+// Copyright 2014 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_COCOA_TAB_DIALOGS_COCOA_H_
+#define CHROME_BROWSER_UI_COCOA_TAB_DIALOGS_COCOA_H_
+
+#include "chrome/browser/ui/tab_dialogs.h"
+
+// Cocoa implementation of TabDialogs interface.
+class TabDialogsCocoa : public TabDialogs {
+ public:
+ explicit TabDialogsCocoa(content::WebContents* contents);
+ ~TabDialogsCocoa() override;
+
+ // TabDialogs:
+ void ShowCollectedCookies() override;
+ void ShowHungRendererDialog() override;
+ void HideHungRendererDialog() override;
+ void ShowProfileSigninConfirmation(
+ Browser* browser,
+ Profile* profile,
+ const std::string& username,
+ ui::ProfileSigninConfirmationDelegate* delegate) override;
+ void ShowManagePasswordsBubble(bool user_action) override;
+ void HideManagePasswordsBubble() override;
+
+ private:
+ content::WebContents* web_contents_; // Weak. Owns this.
+
+ DISALLOW_COPY_AND_ASSIGN(TabDialogsCocoa);
+};
+
+#endif // CHROME_BROWSER_UI_COCOA_TAB_DIALOGS_COCOA_H_
diff --git a/chrome/browser/ui/cocoa/tab_dialogs_cocoa.mm b/chrome/browser/ui/cocoa/tab_dialogs_cocoa.mm
new file mode 100644
index 0000000..12126f1
--- /dev/null
+++ b/chrome/browser/ui/cocoa/tab_dialogs_cocoa.mm
@@ -0,0 +1,56 @@
+// Copyright 2014 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/cocoa/tab_dialogs_cocoa.h"
+
+#import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h"
+#import "chrome/browser/ui/cocoa/hung_renderer_controller.h"
+#import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h"
+#import "chrome/browser/ui/cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h"
+#include "content/public/browser/web_contents.h"
+
+// static
+void TabDialogs::CreateForWebContents(content::WebContents* contents) {
+ DCHECK(contents);
+ if (!FromWebContents(contents))
+ contents->SetUserData(UserDataKey(), new TabDialogsCocoa(contents));
+}
+
+TabDialogsCocoa::TabDialogsCocoa(content::WebContents* contents)
+ : web_contents_(contents) {
+ DCHECK(contents);
+}
+
+TabDialogsCocoa::~TabDialogsCocoa() {
+}
+
+void TabDialogsCocoa::ShowCollectedCookies() {
+ // Deletes itself on close.
+ new CollectedCookiesMac(web_contents_);
+}
+
+void TabDialogsCocoa::ShowHungRendererDialog() {
+ [HungRendererController showForWebContents:web_contents_];
+}
+
+void TabDialogsCocoa::HideHungRendererDialog() {
+ [HungRendererController endForWebContents:web_contents_];
+}
+
+void TabDialogsCocoa::ShowProfileSigninConfirmation(
+ Browser* browser,
+ Profile* profile,
+ const std::string& username,
+ ui::ProfileSigninConfirmationDelegate* delegate) {
+ ProfileSigninConfirmationDialogCocoa::Show(
+ browser, web_contents_, profile, username, delegate);
+}
+
+void TabDialogsCocoa::ShowManagePasswordsBubble(bool user_action) {
+ ManagePasswordsBubbleCocoa::Show(web_contents_, user_action);
+}
+
+void TabDialogsCocoa::HideManagePasswordsBubble() {
+ // The bubble is closed when it loses the focus.
+}
diff --git a/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm b/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
index 6ce06ca..d8abfc7 100644
--- a/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
@@ -13,12 +13,12 @@
#include "base/strings/sys_string_conversions.h"
#import "chrome/browser/certificate_viewer.h"
#include "chrome/browser/infobars/infobar_service.h"
-#import "chrome/browser/ui/browser_dialogs.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/info_bubble_view.h"
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#import "chrome/browser/ui/cocoa/website_settings/permission_selector_button.h"
+#import "chrome/browser/ui/tab_dialogs.h"
#include "chrome/browser/ui/website_settings/permission_menu_model.h"
#include "chrome/browser/ui/website_settings/website_settings_utils.h"
#include "chrome/common/url_constants.h"
@@ -524,7 +524,7 @@ NSColor* IdentityVerifiedTextColor() {
DCHECK(webContents_);
presenter_->RecordWebsiteSettingsAction(
WebsiteSettings::WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED);
- chrome::ShowCollectedCookiesDialog(webContents_);
+ TabDialogs::FromWebContents(webContents_)->ShowCollectedCookies();
}
// Handler for the link button to show certificate information.
diff --git a/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc b/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc
index 513bd1e..4c32358 100644
--- a/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc
@@ -8,12 +8,13 @@
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/ui/browser_command_controller.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/passwords/manage_passwords_icon.h"
#include "chrome/browser/ui/passwords/password_bubble_experiment.h"
+#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/common/url_constants.h"
#include "components/password_manager/content/common/credential_manager_types.h"
#include "components/password_manager/core/browser/password_form_manager.h"
@@ -277,7 +278,7 @@ void ManagePasswordsUIController::DidNavigateMainFrame(
void ManagePasswordsUIController::WasHidden() {
#if !defined(OS_ANDROID)
- chrome::CloseManagePasswordsBubble(web_contents());
+ TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble();
#endif
}
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
index 98a1c98..080db0e 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
@@ -25,7 +25,6 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
@@ -33,9 +32,9 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/sync/one_click_signin_sync_observer.h"
+#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
-#include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
@@ -229,9 +228,8 @@ void OneClickSigninSyncStarter::OnRegisteredForPolicy(
CancelSigninAndDelete();
return;
}
- chrome::ShowProfileSigninConfirmationDialog(
+ TabDialogs::FromWebContents(web_contents)->ShowProfileSigninConfirmation(
browser_,
- web_contents,
profile_,
signin->GetUsernameForAuthInProgress(),
new SigninDialogDelegate(weak_pointer_factory_.GetWeakPtr()));
diff --git a/chrome/browser/ui/tab_dialogs.cc b/chrome/browser/ui/tab_dialogs.cc
new file mode 100644
index 0000000..64c6569
--- /dev/null
+++ b/chrome/browser/ui/tab_dialogs.cc
@@ -0,0 +1,21 @@
+// Copyright 2014 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/tab_dialogs.h"
+#include "content/public/browser/web_contents.h"
+
+namespace {
+int kUserDataKey; // The value is not important, the address is a key.
+}
+
+// static
+TabDialogs* TabDialogs::FromWebContents(content::WebContents* contents) {
+ DCHECK(contents);
+ return static_cast<TabDialogs*>(contents->GetUserData(UserDataKey()));
+}
+
+// static
+const void* TabDialogs::UserDataKey() {
+ return &kUserDataKey;
+}
diff --git a/chrome/browser/ui/tab_dialogs.h b/chrome/browser/ui/tab_dialogs.h
new file mode 100644
index 0000000..ca87915
--- /dev/null
+++ b/chrome/browser/ui/tab_dialogs.h
@@ -0,0 +1,59 @@
+// Copyright 2014 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_TAB_DIALOGS_H_
+#define CHROME_BROWSER_UI_TAB_DIALOGS_H_
+
+#include <string>
+
+#include "base/supports_user_data.h"
+
+class Browser;
+class Profile;
+
+namespace content {
+class WebContents;
+}
+
+namespace ui {
+class ProfileSigninConfirmationDelegate;
+}
+
+// A cross-platform interface for invoking various tab modal dialogs/bubbles.
+class TabDialogs : public base::SupportsUserData::Data {
+ public:
+ virtual ~TabDialogs() {}
+
+ // Creates a platform specific instance, and attaches it to |contents|.
+ // If an instance is already attached, does nothing.
+ static void CreateForWebContents(content::WebContents* contents);
+
+ // Returns the instance that was attached to |contents|.
+ // If no instance was attached, returns NULL.
+ static TabDialogs* FromWebContents(content::WebContents* contents);
+
+ // Shows the collected cookies dialog box.
+ virtual void ShowCollectedCookies() = 0;
+
+ // Shows or hides the hung renderer dialog.
+ virtual void ShowHungRendererDialog() = 0;
+ virtual void HideHungRendererDialog() = 0;
+
+ // Shows a dialog asking the user to confirm linking to a managed account.
+ virtual void ShowProfileSigninConfirmation(
+ Browser* browser,
+ Profile* profile,
+ const std::string& username,
+ ui::ProfileSigninConfirmationDelegate* delegate) = 0;
+
+ // Shows or hides the ManagePasswords bubble.
+ // Pass true for |user_action| if this is a user initiated action.
+ virtual void ShowManagePasswordsBubble(bool user_action) = 0;
+ virtual void HideManagePasswordsBubble() = 0;
+
+ protected:
+ static const void* UserDataKey();
+};
+
+#endif // CHROME_BROWSER_UI_TAB_DIALOGS_H_
diff --git a/chrome/browser/ui/tab_helpers.cc b/chrome/browser/ui/tab_helpers.cc
index c391c92..4828802 100644
--- a/chrome/browser/ui/tab_helpers.cc
+++ b/chrome/browser/ui/tab_helpers.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "chrome/browser/ui/search/search_tab_helper.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
+#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/common/chrome_switches.h"
#include "components/autofill/content/browser/content_autofill_driver_factory.h"
#include "components/autofill/core/browser/autofill_manager.h"
@@ -180,6 +181,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(web_contents);
SearchEngineTabHelper::CreateForWebContents(web_contents);
TabContentsSyncedTabDelegate::CreateForWebContents(web_contents);
+ TabDialogs::CreateForWebContents(web_contents);
ThumbnailTabHelper::CreateForWebContents(web_contents);
web_modal::WebContentsModalDialogManager::CreateForWebContents(web_contents);
#endif
diff --git a/chrome/browser/ui/views/collected_cookies_views.cc b/chrome/browser/ui/views/collected_cookies_views.cc
index e01d122..b293fe5 100644
--- a/chrome/browser/ui/views/collected_cookies_views.cc
+++ b/chrome/browser/ui/views/collected_cookies_views.cc
@@ -44,16 +44,6 @@
#include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h"
-namespace chrome {
-
-// Declared in browser_dialogs.h so others don't have to depend on our header.
-void ShowCollectedCookiesDialog(content::WebContents* web_contents) {
- // Deletes itself on close.
- new CollectedCookiesViews(web_contents);
-}
-
-} // namespace chrome
-
namespace {
// Spacing between the infobar frame and its contents.
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index e92353e..6c1539f 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/sessions/tab_restore_service.h"
diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc
index 353826a..5d2503c 100644
--- a/chrome/browser/ui/views/hung_renderer_view.cc
+++ b/chrome/browser/ui/views/hung_renderer_view.cc
@@ -9,7 +9,6 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/platform_util.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
@@ -188,6 +187,30 @@ HungRendererDialogView* HungRendererDialogView::GetInstance() {
}
// static
+void HungRendererDialogView::Show(WebContents* contents) {
+ if (logging::DialogsAreSuppressed())
+ return;
+
+ gfx::NativeWindow window =
+ platform_util::GetTopLevel(contents->GetNativeView());
+#if defined(USE_AURA)
+ // Don't show the dialog if there is no root window for the renderer, because
+ // it's invisible to the user (happens when the renderer is for prerendering
+ // for example).
+ if (!window->GetRootWindow())
+ return;
+#endif
+ HungRendererDialogView* view = HungRendererDialogView::Create(window);
+ view->ShowForWebContents(contents);
+}
+
+// static
+void HungRendererDialogView::Hide(WebContents* contents) {
+ if (!logging::DialogsAreSuppressed() && HungRendererDialogView::GetInstance())
+ HungRendererDialogView::GetInstance()->EndForWebContents(contents);
+}
+
+// static
bool HungRendererDialogView::IsFrameActive(WebContents* contents) {
gfx::NativeWindow window =
platform_util::GetTopLevel(contents->GetNativeView());
@@ -423,29 +446,3 @@ void HungRendererDialogView::InitClass() {
initialized = true;
}
}
-
-namespace chrome {
-
-void ShowHungRendererDialog(WebContents* contents) {
- if (logging::DialogsAreSuppressed())
- return;
-
- gfx::NativeWindow window =
- platform_util::GetTopLevel(contents->GetNativeView());
-#if defined(USE_AURA)
- // Don't show the dialog if there is no root window for the renderer, because
- // it's invisible to the user (happens when the renderer is for prerendering
- // for example).
- if (!window->GetRootWindow())
- return;
-#endif
- HungRendererDialogView* view = HungRendererDialogView::Create(window);
- view->ShowForWebContents(contents);
-}
-
-void HideHungRendererDialog(WebContents* contents) {
- if (!logging::DialogsAreSuppressed() && HungRendererDialogView::GetInstance())
- HungRendererDialogView::GetInstance()->EndForWebContents(contents);
-}
-
-} // namespace chrome
diff --git a/chrome/browser/ui/views/hung_renderer_view.h b/chrome/browser/ui/views/hung_renderer_view.h
index 58d3f33..162f669 100644
--- a/chrome/browser/ui/views/hung_renderer_view.h
+++ b/chrome/browser/ui/views/hung_renderer_view.h
@@ -104,6 +104,10 @@ class HungRendererDialogView : public views::DialogDelegateView,
// Returns a pointer to the singleton instance if any.
static HungRendererDialogView* GetInstance();
+ // Shows or hides the hung renderer dialog for the given WebContents.
+ static void Show(content::WebContents* contents);
+ static void Hide(content::WebContents* contents);
+
// Platform specific function to kill the renderer process identified by the
// render process host passed in.
static void KillRendererProcess(content::RenderProcessHost* rph);
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
index 36ecd1f..c250f6a 100644
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
-#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
@@ -174,37 +173,6 @@ std::string PresentURL(const GURL& url) {
} // namespace
-// Globals --------------------------------------------------------------------
-
-namespace chrome {
-
-void ShowManagePasswordsBubble(content::WebContents* web_contents) {
- if (ManagePasswordsBubbleView::IsShowing()) {
- // The bubble is currently shown for some other tab. We should close it now
- // and open for |web_contents|.
- ManagePasswordsBubbleView::CloseBubble();
- }
- ManagePasswordsUIController* controller =
- ManagePasswordsUIController::FromWebContents(web_contents);
- ManagePasswordsBubbleView::ShowBubble(
- web_contents,
- password_manager::ui::IsAutomaticDisplayState(controller->state())
- ? ManagePasswordsBubbleView::AUTOMATIC
- : ManagePasswordsBubbleView::USER_ACTION);
-}
-
-void CloseManagePasswordsBubble(content::WebContents* web_contents) {
- if (!ManagePasswordsBubbleView::IsShowing())
- return;
- content::WebContents* bubble_web_contents =
- ManagePasswordsBubbleView::manage_password_bubble()->web_contents();
- if (web_contents == bubble_web_contents)
- ManagePasswordsBubbleView::CloseBubble();
-}
-
-} // namespace chrome
-
-
// ManagePasswordsBubbleView::AccountChooserView ------------------------------
// A view offering the user the ability to choose credentials for
diff --git a/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc b/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc
index ca05270..f92c5b2 100644
--- a/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc
+++ b/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc
@@ -8,7 +8,6 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/host_desktop.h"
@@ -34,21 +33,6 @@
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_client_view.h"
-namespace chrome {
-// Declared in browser_dialogs.h
-void ShowProfileSigninConfirmationDialog(
- Browser* browser,
- content::WebContents* web_contents,
- Profile* profile,
- const std::string& username,
- ui::ProfileSigninConfirmationDelegate* delegate) {
- ProfileSigninConfirmationDialogViews::ShowDialog(browser,
- profile,
- username,
- delegate);
-}
-} // namespace chrome
-
ProfileSigninConfirmationDialogViews::ProfileSigninConfirmationDialogViews(
Browser* browser,
const std::string& username,
diff --git a/chrome/browser/ui/views/tab_dialogs_views.cc b/chrome/browser/ui/views/tab_dialogs_views.cc
new file mode 100644
index 0000000..40573a9
--- /dev/null
+++ b/chrome/browser/ui/views/tab_dialogs_views.cc
@@ -0,0 +1,68 @@
+// Copyright 2014 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/views/tab_dialogs_views.h"
+
+#include "chrome/browser/ui/views/collected_cookies_views.h"
+#include "chrome/browser/ui/views/hung_renderer_view.h"
+#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
+#include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.h"
+#include "content/public/browser/web_contents.h"
+
+// static
+void TabDialogs::CreateForWebContents(content::WebContents* contents) {
+ DCHECK(contents);
+ if (!FromWebContents(contents))
+ contents->SetUserData(UserDataKey(), new TabDialogsViews(contents));
+}
+
+TabDialogsViews::TabDialogsViews(content::WebContents* contents)
+ : web_contents_(contents) {
+ DCHECK(contents);
+}
+
+TabDialogsViews::~TabDialogsViews() {
+}
+
+void TabDialogsViews::ShowCollectedCookies() {
+ // Deletes itself on close.
+ new CollectedCookiesViews(web_contents_);
+}
+
+void TabDialogsViews::ShowHungRendererDialog() {
+ HungRendererDialogView::Show(web_contents_);
+}
+
+void TabDialogsViews::HideHungRendererDialog() {
+ HungRendererDialogView::Hide(web_contents_);
+}
+
+void TabDialogsViews::ShowProfileSigninConfirmation(
+ Browser* browser,
+ Profile* profile,
+ const std::string& username,
+ ui::ProfileSigninConfirmationDelegate* delegate) {
+ ProfileSigninConfirmationDialogViews::ShowDialog(
+ browser, profile, username, delegate);
+}
+
+void TabDialogsViews::ShowManagePasswordsBubble(bool user_action) {
+ if (ManagePasswordsBubbleView::IsShowing()) {
+ // The bubble is currently shown for some other tab. We should close it now
+ // and open for |web_contents_|.
+ ManagePasswordsBubbleView::CloseBubble();
+ }
+ ManagePasswordsBubbleView::ShowBubble(
+ web_contents_, user_action ? ManagePasswordsBubble::USER_ACTION
+ : ManagePasswordsBubble::AUTOMATIC);
+}
+
+void TabDialogsViews::HideManagePasswordsBubble() {
+ if (!ManagePasswordsBubbleView::IsShowing())
+ return;
+ content::WebContents* bubble_web_contents =
+ ManagePasswordsBubbleView::manage_password_bubble()->web_contents();
+ if (web_contents_ == bubble_web_contents)
+ ManagePasswordsBubbleView::CloseBubble();
+}
diff --git a/chrome/browser/ui/views/tab_dialogs_views.h b/chrome/browser/ui/views/tab_dialogs_views.h
new file mode 100644
index 0000000..708198f
--- /dev/null
+++ b/chrome/browser/ui/views/tab_dialogs_views.h
@@ -0,0 +1,35 @@
+// Copyright 2014 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_VIEWS_TAB_DIALOGS_VIEWS_H_
+#define CHROME_BROWSER_UI_VIEWS_TAB_DIALOGS_VIEWS_H_
+
+#include "base/macros.h"
+#include "chrome/browser/ui/tab_dialogs.h"
+
+// Views implementation of TabDialogs interface.
+class TabDialogsViews : public TabDialogs {
+ public:
+ explicit TabDialogsViews(content::WebContents* contents);
+ ~TabDialogsViews() override;
+
+ // TabDialogs:
+ void ShowCollectedCookies() override;
+ void ShowHungRendererDialog() override;
+ void HideHungRendererDialog() override;
+ void ShowProfileSigninConfirmation(
+ Browser* browser,
+ Profile* profile,
+ const std::string& username,
+ ui::ProfileSigninConfirmationDelegate* delegate) override;
+ void ShowManagePasswordsBubble(bool user_action) override;
+ void HideManagePasswordsBubble() override;
+
+ private:
+ content::WebContents* web_contents_; // Weak. Owns this.
+
+ DISALLOW_COPY_AND_ASSIGN(TabDialogsViews);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_TAB_DIALOGS_VIEWS_H_
diff --git a/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc b/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc
index 5ccb7c0..f431323 100644
--- a/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc
+++ b/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc
@@ -10,7 +10,6 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/common/url_constants.h"
@@ -89,24 +88,6 @@ void ProfileSigninConfirmationHandler::OnContinueButtonClicked(
} // namespace
-#if !defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
-namespace chrome {
-// static
-// Declared in browser_dialogs.h
-void ShowProfileSigninConfirmationDialog(
- Browser* browser,
- content::WebContents* web_contents,
- Profile* profile,
- const std::string& username,
- ui::ProfileSigninConfirmationDelegate* delegate) {
- ProfileSigninConfirmationDialog::ShowDialog(web_contents,
- profile,
- username,
- delegate);
-}
-} // namespace chrome
-#endif
-
// ProfileSigninConfirmationDialog ---------------------------------------------
ProfileSigninConfirmationDialog::ProfileSigninConfirmationDialog(