summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 19:01:19 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 19:01:19 +0000
commitf4f50efb4d3ee42470c8057345e902ac42e76801 (patch)
tree5b4d0c57cd94d8169db9dc441f424d6443e4f490
parent0bd22cab9c919ff8d9b35153f6799dc031fe2770 (diff)
downloadchromium_src-f4f50efb4d3ee42470c8057345e902ac42e76801.zip
chromium_src-f4f50efb4d3ee42470c8057345e902ac42e76801.tar.gz
chromium_src-f4f50efb4d3ee42470c8057345e902ac42e76801.tar.bz2
Cleanup: de-inline a bunch of classes, rename and move "PluginInstaller" to "PluginInstallerInfoBarDelegate" for clarity, lots of other misc. stuff
BUG=none TEST=none Review URL: http://codereview.chromium.org/6249010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72166 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/alternate_nav_url_fetcher.cc10
-rw-r--r--chrome/browser/alternate_nav_url_fetcher.h4
-rw-r--r--chrome/browser/autofill/autofill_cc_infobar_delegate.cc35
-rw-r--r--chrome/browser/autofill/autofill_cc_infobar_delegate.h14
-rw-r--r--chrome/browser/automation/automation_provider.cc4
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc5
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc20
-rw-r--r--chrome/browser/automation/testing_automation_provider.h5
-rw-r--r--chrome/browser/download/download_manager.cc3
-rw-r--r--chrome/browser/download/download_request_infobar_delegate.cc21
-rw-r--r--chrome/browser/download/download_request_infobar_delegate.h23
-rw-r--r--chrome/browser/download/download_request_infobar_delegate_unittest.cc78
-rw-r--r--chrome/browser/download/download_util.cc1
-rw-r--r--chrome/browser/extensions/crashed_extension_infobar.cc31
-rw-r--r--chrome/browser/extensions/crashed_extension_infobar.h14
-rw-r--r--chrome/browser/extensions/extension_crash_recovery_browsertest.cc40
-rw-r--r--chrome/browser/extensions/extension_disabled_infobar_delegate.cc202
-rw-r--r--chrome/browser/extensions/extension_dom_ui.cc4
-rw-r--r--chrome/browser/extensions/extension_dom_ui.h4
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.h4
-rw-r--r--chrome/browser/extensions/extension_host.cc10
-rw-r--r--chrome/browser/extensions/extension_host.h19
-rw-r--r--chrome/browser/extensions/extension_infobar_delegate.cc20
-rw-r--r--chrome/browser/extensions/extension_infobar_delegate.h29
-rw-r--r--chrome/browser/extensions/extension_install_ui.cc25
-rw-r--r--chrome/browser/extensions/extension_install_ui_browsertest.cc6
-rw-r--r--chrome/browser/extensions/extension_tabs_module.cc3
-rw-r--r--chrome/browser/extensions/theme_installed_infobar_delegate.cc63
-rw-r--r--chrome/browser/extensions/theme_installed_infobar_delegate.h31
-rw-r--r--chrome/browser/external_tab_container_win.cc5
-rw-r--r--chrome/browser/external_tab_container_win.h4
-rw-r--r--chrome/browser/geolocation/geolocation_permission_context.cc327
-rw-r--r--chrome/browser/geolocation/geolocation_permission_context_unittest.cc26
-rw-r--r--chrome/browser/google/google_url_tracker_unittest.cc11
-rw-r--r--chrome/browser/notifications/balloon_host.cc4
-rw-r--r--chrome/browser/notifications/balloon_host.h4
-rw-r--r--chrome/browser/notifications/desktop_notification_service.cc280
-rw-r--r--chrome/browser/omnibox_search_hint.cc147
-rw-r--r--chrome/browser/password_manager_delegate_impl.cc135
-rw-r--r--chrome/browser/plugin_installer_infobar_delegate.cc (renamed from chrome/browser/plugin_installer.cc)49
-rw-r--r--chrome/browser/plugin_installer_infobar_delegate.h (renamed from chrome/browser/plugin_installer.h)22
-rw-r--r--chrome/browser/printing/print_dialog_gtk.cc4
-rw-r--r--chrome/browser/renderer_host/render_view_host.h4
-rw-r--r--chrome/browser/speech/speech_input_manager.cc3
-rw-r--r--chrome/browser/tab_contents/infobar_delegate.cc121
-rw-r--r--chrome/browser/tab_contents/infobar_delegate.h104
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc200
-rw-r--r--chrome/browser/tab_contents/tab_contents.h10
-rw-r--r--chrome/browser/tab_contents/tab_contents_ssl_helper.cc222
-rw-r--r--chrome/browser/tab_contents/tab_contents_ssl_helper.h5
-rw-r--r--chrome/browser/task_manager/task_manager_browsertest.cc11
-rw-r--r--chrome/browser/translate/languages_menu_model.cc16
-rw-r--r--chrome/browser/translate/translate_infobar_delegate.cc314
-rw-r--r--chrome/browser/translate/translate_infobar_delegate.h22
-rw-r--r--chrome/browser/translate/translate_manager.cc12
-rw-r--r--chrome/browser/translate/translate_manager_unittest.cc31
-rw-r--r--chrome/browser/ui/browser.cc15
-rw-r--r--chrome/browser/ui/browser_init.cc339
-rw-r--r--chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm102
-rw-r--r--chrome/browser/ui/cocoa/infobars/infobar_test_helper.h244
-rw-r--r--chrome/browser/ui/cocoa/infobars/infobar_test_helper.mm144
-rw-r--r--chrome/browser/ui/cocoa/keystone_infobar.mm135
-rw-r--r--chrome/browser/ui/cocoa/translate/translate_infobar_unittest.mm5
-rw-r--r--chrome/browser/ui/gtk/translate/translate_infobar_base_gtk.h2
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h2
-rw-r--r--chrome/browser/ui/views/infobars/infobar_container.cc4
-rw-r--r--chrome/browser/ui/views/infobars/infobar_container.h2
-rw-r--r--chrome/browser/ui/views/infobars/infobars.cc8
-rw-r--r--chrome/browser/ui/views/infobars/translate_infobar_base.cc2
-rw-r--r--chrome/chrome_browser.gypi5
-rw-r--r--chrome/common/automation_messages_internal.h4
72 files changed, 2077 insertions, 1759 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc
index 4d83a65..58f18ed 100644
--- a/chrome/browser/alternate_nav_url_fetcher.cc
+++ b/chrome/browser/alternate_nav_url_fetcher.cc
@@ -98,6 +98,11 @@ void AlternateNavURLFetcher::OnURLFetchComplete(
ShowInfobarIfPossible();
}
+SkBitmap* AlternateNavURLFetcher::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_ALT_NAV_URL);
+}
+
string16 AlternateNavURLFetcher::GetMessageTextWithOffset(
size_t* link_offset) const {
const string16 label = l10n_util::GetStringFUTF16(
@@ -110,11 +115,6 @@ string16 AlternateNavURLFetcher::GetLinkText() const {
return UTF8ToUTF16(alternate_nav_url_.spec());
}
-SkBitmap* AlternateNavURLFetcher::GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_INFOBAR_ALT_NAV_URL);
-}
-
bool AlternateNavURLFetcher::LinkClicked(WindowOpenDisposition disposition) {
infobar_contents_->OpenURL(
alternate_nav_url_, GURL(), disposition,
diff --git a/chrome/browser/alternate_nav_url_fetcher.h b/chrome/browser/alternate_nav_url_fetcher.h
index 7f573dd..1964b29 100644
--- a/chrome/browser/alternate_nav_url_fetcher.h
+++ b/chrome/browser/alternate_nav_url_fetcher.h
@@ -43,6 +43,7 @@ class AlternateNavURLFetcher : public NotificationObserver,
State state() const { return state_; }
+ private:
// NotificationObserver
virtual void Observe(NotificationType type,
const NotificationSource& source,
@@ -57,13 +58,12 @@ class AlternateNavURLFetcher : public NotificationObserver,
const std::string& data);
// LinkInfoBarDelegate
+ virtual SkBitmap* GetIcon() const;
virtual string16 GetMessageTextWithOffset(size_t* link_offset) const;
virtual string16 GetLinkText() const;
- virtual SkBitmap* GetIcon() const;
virtual bool LinkClicked(WindowOpenDisposition disposition);
virtual void InfoBarClosed();
- private:
// Sets |state_| to either SUCCEEDED or FAILED depending on the result of the
// fetch.
void SetStatusFromURLFetch(const GURL& url,
diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
index 6588c46..e3d29ac 100644
--- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
+++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -9,12 +9,8 @@
#include "chrome/browser/autofill/autofill_cc_infobar.h"
#include "chrome/browser/autofill/autofill_manager.h"
#include "chrome/browser/browser_list.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/tab_contents/tab_contents_delegate.h"
-#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
-#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/resource/resource_bundle.h"
AutoFillCCInfoBarDelegate::AutoFillCCInfoBarDelegate(TabContents* tab_contents,
@@ -42,29 +38,26 @@ void AutoFillCCInfoBarDelegate::InfoBarClosed() {
delete this;
}
-string16 AutoFillCCInfoBarDelegate::GetMessageText() const {
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_INFOBAR_TEXT);
-}
-
SkBitmap* AutoFillCCInfoBarDelegate::GetIcon() const {
return ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_INFOBAR_AUTOFILL);
}
+InfoBarDelegate::Type AutoFillCCInfoBarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+}
+
+string16 AutoFillCCInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_INFOBAR_TEXT);
+}
+
int AutoFillCCInfoBarDelegate::GetButtons() const {
return BUTTON_OK | BUTTON_CANCEL;
}
-string16 AutoFillCCInfoBarDelegate::GetButtonLabel(
- ConfirmInfoBarDelegate::InfoBarButton button) const {
- if (button == BUTTON_OK)
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_INFOBAR_ACCEPT);
- else if (button == BUTTON_CANCEL)
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_INFOBAR_DENY);
- else
- NOTREACHED();
-
- return string16();
+string16 AutoFillCCInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
+ IDS_AUTOFILL_CC_INFOBAR_ACCEPT : IDS_AUTOFILL_CC_INFOBAR_DENY);
}
bool AutoFillCCInfoBarDelegate::Accept() {
@@ -101,7 +94,3 @@ InfoBar* AutoFillCCInfoBarDelegate::CreateInfoBar() {
return CreateAutofillCcInfoBar(this);
}
#endif // defined(OS_WIN)
-
-InfoBarDelegate::Type AutoFillCCInfoBarDelegate::GetInfoBarType() {
- return PAGE_ACTION_TYPE;
-}
diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.h b/chrome/browser/autofill/autofill_cc_infobar_delegate.h
index a02b4ca..fae8167 100644
--- a/chrome/browser/autofill/autofill_cc_infobar_delegate.h
+++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -10,22 +10,23 @@
#include "chrome/browser/tab_contents/infobar_delegate.h"
class AutoFillManager;
-class SkBitmap;
-class TabContents;
// An InfoBar delegate that enables the user to allow or deny storing credit
// card information gathered from a form submission.
class AutoFillCCInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
AutoFillCCInfoBarDelegate(TabContents* tab_contents, AutoFillManager* host);
+
+ private:
virtual ~AutoFillCCInfoBarDelegate();
- // ConfirmInfoBarDelegate implementation.
+ // ConfirmInfoBarDelegate:
virtual bool ShouldExpire(
const NavigationController::LoadCommittedDetails& details) const;
virtual void InfoBarClosed();
- virtual string16 GetMessageText() const;
virtual SkBitmap* GetIcon() const;
+ virtual Type GetInfoBarType() const;
+ virtual string16 GetMessageText() const;
virtual int GetButtons() const;
virtual string16 GetButtonLabel(
ConfirmInfoBarDelegate::InfoBarButton button) const;
@@ -39,9 +40,6 @@ class AutoFillCCInfoBarDelegate : public ConfirmInfoBarDelegate {
virtual InfoBar* CreateInfoBar();
#endif // defined(OS_WIN)
- virtual Type GetInfoBarType();
-
- private:
// The AutoFillManager that initiated this InfoBar.
AutoFillManager* host_;
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index f00a0a4..294ba39 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -71,11 +71,9 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/ssl/ssl_manager.h"
#include "chrome/browser/ssl/ssl_blocking_page.h"
-#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
-#include "chrome/browser/translate/translate_infobar_delegate.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
#include "chrome/browser/ui/find_bar/find_bar.h"
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 8b53b4a..111c220 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -696,7 +696,8 @@ BrowserCountChangeNotificationObserver::BrowserCountChangeNotificationObserver(
}
void BrowserCountChangeNotificationObserver::Observe(
- NotificationType type, const NotificationSource& source,
+ NotificationType type,
+ const NotificationSource& source,
const NotificationDetails& details) {
DCHECK(type == NotificationType::BROWSER_OPENED ||
type == NotificationType::BROWSER_CLOSED);
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index a4fc56a..eab458f 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -1676,11 +1676,10 @@ void TestingAutomationProvider::ClickInfoBarAccept(
if (tab_tracker_->ContainsHandle(handle)) {
NavigationController* nav_controller = tab_tracker_->GetResource(handle);
if (nav_controller) {
- int count = nav_controller->tab_contents()->infobar_delegate_count();
- if (info_bar_index >= 0 && info_bar_index < count) {
- if (wait_for_navigation) {
+ if (info_bar_index >= 0 && info_bar_index < nav_controller->
+ tab_contents()->infobar_delegate_count()) {
+ if (wait_for_navigation)
AddNavigationStatusListener(nav_controller, reply_message, 1, false);
- }
InfoBarDelegate* delegate =
nav_controller->tab_contents()->GetInfoBarDelegateAt(
info_bar_index);
@@ -1814,7 +1813,8 @@ void TestingAutomationProvider::ClickAppModalDialogButton(int button,
}
void TestingAutomationProvider::WaitForBrowserWindowCountToBecome(
- int target_count, IPC::Message* reply_message) {
+ int target_count,
+ IPC::Message* reply_message) {
if (static_cast<int>(BrowserList::size()) == target_count) {
AutomationMsg_WaitForBrowserWindowCountToBecome::WriteReplyParams(
reply_message, true);
@@ -2123,11 +2123,9 @@ void TestingAutomationProvider::SetWindowDimensions(
ListValue* TestingAutomationProvider::GetInfobarsInfo(TabContents* tc) {
// Each infobar may have different properties depending on the type.
ListValue* infobars = new ListValue;
- for (int infobar_index = 0;
- infobar_index < tc->infobar_delegate_count();
- ++infobar_index) {
+ for (int i = 0; i < tc->infobar_delegate_count(); ++i) {
DictionaryValue* infobar_item = new DictionaryValue;
- InfoBarDelegate* infobar = tc->GetInfoBarDelegateAt(infobar_index);
+ InfoBarDelegate* infobar = tc->GetInfoBarDelegateAt(i);
if (infobar->AsConfirmInfoBarDelegate()) {
// Also covers ThemeInstalledInfoBarDelegate and
// CrashedExtensionInfoBarDelegate.
@@ -2138,13 +2136,13 @@ ListValue* TestingAutomationProvider::GetInfobarsInfo(TabContents* tc) {
infobar_item->SetString("link_text", confirm_infobar->GetLinkText());
ListValue* buttons_list = new ListValue;
int buttons = confirm_infobar->GetButtons();
- if (ConfirmInfoBarDelegate::BUTTON_OK & buttons) {
+ if (buttons & ConfirmInfoBarDelegate::BUTTON_OK) {
StringValue* button_label = new StringValue(
confirm_infobar->GetButtonLabel(
ConfirmInfoBarDelegate::BUTTON_OK));
buttons_list->Append(button_label);
}
- if (ConfirmInfoBarDelegate::BUTTON_CANCEL & buttons) {
+ if (buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL) {
StringValue* button_label = new StringValue(
confirm_infobar->GetButtonLabel(
ConfirmInfoBarDelegate::BUTTON_CANCEL));
diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h
index 6bda672..941c0b4 100644
--- a/chrome/browser/automation/testing_automation_provider.h
+++ b/chrome/browser/automation/testing_automation_provider.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -296,7 +296,8 @@ class TestingAutomationProvider : public AutomationProvider,
// Causes a click on the "accept" button of the info-bar at |info_bar_index|.
// If |wait_for_navigation| is true, it sends the reply after a navigation has
// occurred.
- void ClickInfoBarAccept(int handle, int info_bar_index,
+ void ClickInfoBarAccept(int handle,
+ int info_bar_index,
bool wait_for_navigation,
IPC::Message* reply_message);
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index de7344a..9e47b35 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -34,7 +34,6 @@
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
-#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/download/download_request_infobar_delegate.cc b/chrome/browser/download/download_request_infobar_delegate.cc
index 417dfa4..5d4b618 100644
--- a/chrome/browser/download/download_request_infobar_delegate.cc
+++ b/chrome/browser/download/download_request_infobar_delegate.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -10,7 +10,8 @@
#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
-DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate(TabContents* tab,
+DownloadRequestInfoBarDelegate::DownloadRequestInfoBarDelegate(
+ TabContents* tab,
DownloadRequestLimiter::TabDownloadState* host)
: ConfirmInfoBarDelegate(tab),
host_(host) {
@@ -27,25 +28,23 @@ void DownloadRequestInfoBarDelegate::InfoBarClosed() {
ConfirmInfoBarDelegate::InfoBarClosed();
}
-string16 DownloadRequestInfoBarDelegate::GetMessageText() const {
- return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING);
-}
-
SkBitmap* DownloadRequestInfoBarDelegate::GetIcon() const {
return ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_INFOBAR_MULTIPLE_DOWNLOADS);
}
+string16 DownloadRequestInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING);
+}
+
int DownloadRequestInfoBarDelegate::GetButtons() const {
return BUTTON_OK | BUTTON_CANCEL;
}
string16 DownloadRequestInfoBarDelegate::GetButtonLabel(
- ConfirmInfoBarDelegate::InfoBarButton button) const {
- if (button == BUTTON_OK)
- return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING_ALLOW);
- else
- return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING_DENY);
+ InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
+ IDS_MULTI_DOWNLOAD_WARNING_ALLOW : IDS_MULTI_DOWNLOAD_WARNING_DENY);
}
bool DownloadRequestInfoBarDelegate::Accept() {
diff --git a/chrome/browser/download/download_request_infobar_delegate.h b/chrome/browser/download/download_request_infobar_delegate.h
index c1280cf..9b1092c 100644
--- a/chrome/browser/download/download_request_infobar_delegate.h
+++ b/chrome/browser/download/download_request_infobar_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -19,30 +19,25 @@ class TabContents;
class DownloadRequestInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
DownloadRequestInfoBarDelegate(
- TabContents* tab, DownloadRequestLimiter::TabDownloadState* host);
-
- virtual ~DownloadRequestInfoBarDelegate();
+ TabContents* tab,
+ DownloadRequestLimiter::TabDownloadState* host);
void set_host(DownloadRequestLimiter::TabDownloadState* host) {
host_ = host;
}
- virtual void InfoBarClosed();
-
- virtual string16 GetMessageText() const;
+ private:
+ virtual ~DownloadRequestInfoBarDelegate();
+ // ConfirmInfoBarDelegate:
+ virtual void InfoBarClosed();
virtual SkBitmap* GetIcon() const;
-
+ virtual string16 GetMessageText() const;
virtual int GetButtons() const;
-
- virtual string16 GetButtonLabel(
- ConfirmInfoBarDelegate::InfoBarButton button) const;
-
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
virtual bool Accept();
-
virtual bool Cancel();
- private:
DownloadRequestLimiter::TabDownloadState* host_;
DISALLOW_COPY_AND_ASSIGN(DownloadRequestInfoBarDelegate);
diff --git a/chrome/browser/download/download_request_infobar_delegate_unittest.cc b/chrome/browser/download/download_request_infobar_delegate_unittest.cc
index 1ceb247..90ec2af 100644
--- a/chrome/browser/download/download_request_infobar_delegate_unittest.cc
+++ b/chrome/browser/download/download_request_infobar_delegate_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -6,36 +6,27 @@
#include "chrome/browser/download/download_request_limiter.h"
#include "testing/gtest/include/gtest/gtest.h"
+// MockTabDownloadState -------------------------------------------------------
+
class MockTabDownloadState : public DownloadRequestLimiter::TabDownloadState {
public:
- MockTabDownloadState() : responded_(false), accepted_(false) {
- }
-
- virtual ~MockTabDownloadState() {
- EXPECT_TRUE(responded_);
- }
-
- virtual void Accept() {
- EXPECT_FALSE(responded_);
- responded_ = true;
- accepted_ = true;
- }
+ MockTabDownloadState();
+ virtual ~MockTabDownloadState();
- virtual void Cancel() {
- EXPECT_FALSE(responded_);
- responded_ = true;
- accepted_ = false;
- }
+ // DownloadRequestLimiter::TabDownloadState
+ virtual void Cancel();
+ virtual void Accept();
- bool responded() {
- return responded_;
- }
-
- bool accepted() {
- return responded_ && accepted_;
+ ConfirmInfoBarDelegate* infobar() {
+ return infobar_->AsConfirmInfoBarDelegate();
}
+ bool responded() const { return responded_; }
+ bool accepted() const { return accepted_; }
private:
+ // The actual infobar delegate we're listening to.
+ scoped_ptr<InfoBarDelegate> infobar_;
+
// True if we have gotten some sort of response.
bool responded_;
@@ -44,23 +35,44 @@ class MockTabDownloadState : public DownloadRequestLimiter::TabDownloadState {
bool accepted_;
};
-TEST(DownloadRequestInfobar, AcceptTest) {
+MockTabDownloadState::MockTabDownloadState()
+ : responded_(false), accepted_(false) {
+ infobar_.reset(new DownloadRequestInfoBarDelegate(NULL, this));
+}
+
+MockTabDownloadState::~MockTabDownloadState() {
+ EXPECT_TRUE(responded_);
+}
+
+void MockTabDownloadState::Cancel() {
+ EXPECT_FALSE(responded_);
+ responded_ = true;
+ accepted_ = false;
+}
+
+void MockTabDownloadState::Accept() {
+ EXPECT_FALSE(responded_);
+ responded_ = true;
+ accepted_ = true;
+}
+
+
+// Tests ----------------------------------------------------------------------
+
+TEST(DownloadRequestInfobarDelegate, AcceptTest) {
MockTabDownloadState state;
- DownloadRequestInfoBarDelegate infobar(NULL, &state);
- infobar.Accept();
+ state.infobar()->Accept();
EXPECT_TRUE(state.accepted());
}
-TEST(DownloadRequestInfobar, CancelTest) {
+TEST(DownloadRequestInfobarDelegate, CancelTest) {
MockTabDownloadState state;
- DownloadRequestInfoBarDelegate infobar(NULL, &state);
- infobar.Cancel();
+ state.infobar()->Cancel();
EXPECT_FALSE(state.accepted());
}
-TEST(DownloadRequestInfobar, CloseTest) {
+TEST(DownloadRequestInfobarDelegate, CloseTest) {
MockTabDownloadState state;
- DownloadRequestInfoBarDelegate infobar(NULL, &state);
- infobar.InfoBarClosed();
+ state.infobar()->InfoBarClosed();
EXPECT_FALSE(state.accepted());
}
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index eadebbb..61574d3 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -37,7 +37,6 @@
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
-#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_paths.h"
diff --git a/chrome/browser/extensions/crashed_extension_infobar.cc b/chrome/browser/extensions/crashed_extension_infobar.cc
index 1077d44..dc527a8 100644
--- a/chrome/browser/extensions/crashed_extension_infobar.cc
+++ b/chrome/browser/extensions/crashed_extension_infobar.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -25,9 +25,7 @@ CrashedExtensionInfoBarDelegate::CrashedExtensionInfoBarDelegate(
DCHECK(!extension_id_.empty());
}
-CrashedExtensionInfoBarDelegate* CrashedExtensionInfoBarDelegate::
-AsCrashedExtensionInfoBarDelegate() {
- return this;
+CrashedExtensionInfoBarDelegate::~CrashedExtensionInfoBarDelegate() {
}
bool CrashedExtensionInfoBarDelegate::ShouldExpire(
@@ -35,11 +33,6 @@ bool CrashedExtensionInfoBarDelegate::ShouldExpire(
return false;
}
-string16 CrashedExtensionInfoBarDelegate::GetMessageText() const {
- return l10n_util::GetStringFUTF16(IDS_EXTENSION_CRASHED_INFOBAR_MESSAGE,
- UTF8ToUTF16(extension_name_));
-}
-
void CrashedExtensionInfoBarDelegate::InfoBarClosed() {
delete this;
}
@@ -50,17 +43,25 @@ SkBitmap* CrashedExtensionInfoBarDelegate::GetIcon() const {
IDR_INFOBAR_PLUGIN_CRASHED);
}
+CrashedExtensionInfoBarDelegate*
+ CrashedExtensionInfoBarDelegate::AsCrashedExtensionInfoBarDelegate() {
+ return this;
+}
+
+string16 CrashedExtensionInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(IDS_EXTENSION_CRASHED_INFOBAR_MESSAGE,
+ UTF8ToUTF16(extension_name_));
+}
+
int CrashedExtensionInfoBarDelegate::GetButtons() const {
return BUTTON_OK;
}
string16 CrashedExtensionInfoBarDelegate::GetButtonLabel(
- ConfirmInfoBarDelegate::InfoBarButton button) const {
- if (button == BUTTON_OK) {
- return l10n_util::GetStringUTF16(
- IDS_EXTENSION_CRASHED_INFOBAR_RESTART_BUTTON);
- }
- return ConfirmInfoBarDelegate::GetButtonLabel(button);
+ InfoBarButton button) const {
+ DCHECK_EQ(BUTTON_OK, button);
+ return l10n_util::GetStringUTF16(
+ IDS_EXTENSION_CRASHED_INFOBAR_RESTART_BUTTON);
}
bool CrashedExtensionInfoBarDelegate::Accept() {
diff --git a/chrome/browser/extensions/crashed_extension_infobar.h b/chrome/browser/extensions/crashed_extension_infobar.h
index 201e606..892a04d 100644
--- a/chrome/browser/extensions/crashed_extension_infobar.h
+++ b/chrome/browser/extensions/crashed_extension_infobar.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -28,21 +28,21 @@ class CrashedExtensionInfoBarDelegate : public ConfirmInfoBarDelegate {
const std::string extension_id() { return extension_id_; }
- // InfoBarDelegate
- virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate();
- virtual bool ShouldExpire(
- const NavigationController::LoadCommittedDetails& details) const;
+ private:
+ virtual ~CrashedExtensionInfoBarDelegate();
// ConfirmInfoBarDelegate
- virtual string16 GetMessageText() const;
+ virtual bool ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const;
virtual void InfoBarClosed();
virtual SkBitmap* GetIcon() const;
+ virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate();
+ virtual string16 GetMessageText() const;
virtual int GetButtons() const;
virtual string16 GetButtonLabel(
ConfirmInfoBarDelegate::InfoBarButton button) const;
virtual bool Accept();
- private:
ExtensionService* extensions_service_;
const std::string extension_id_;
diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
index cc5e62e..bd01595 100644
--- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
+++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -28,25 +28,21 @@ class ExtensionCrashRecoveryTest : public ExtensionBrowserTest {
return browser()->profile()->GetExtensionProcessManager();
}
- CrashedExtensionInfoBarDelegate* GetCrashedExtensionInfoBarDelegate(
- int index) {
+ ConfirmInfoBarDelegate* GetInfoBarDelegate(int index) {
TabContents* current_tab = browser()->GetSelectedTabContents();
EXPECT_LT(index, current_tab->infobar_delegate_count());
- InfoBarDelegate* delegate = current_tab->GetInfoBarDelegateAt(index);
- return delegate->AsCrashedExtensionInfoBarDelegate();
+ return current_tab->GetInfoBarDelegateAt(index)->AsConfirmInfoBarDelegate();
}
- void AcceptCrashedExtensionInfobar(int index) {
- CrashedExtensionInfoBarDelegate* infobar =
- GetCrashedExtensionInfoBarDelegate(index);
+ void AcceptInfoBar(int index) {
+ ConfirmInfoBarDelegate* infobar = GetInfoBarDelegate(index);
ASSERT_TRUE(infobar);
infobar->Accept();
WaitForExtensionLoad();
}
- void CancelCrashedExtensionInfobar(int index) {
- CrashedExtensionInfoBarDelegate* infobar =
- GetCrashedExtensionInfoBarDelegate(index);
+ void CancelInfoBar(int index) {
+ ConfirmInfoBarDelegate* infobar = GetInfoBarDelegate(index);
ASSERT_TRUE(infobar);
infobar->Cancel();
}
@@ -118,7 +114,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, Basic) {
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
ASSERT_EQ(crash_size_before + 1,
GetExtensionService()->terminated_extensions()->size());
- AcceptCrashedExtensionInfobar(0);
+ AcceptInfoBar(0);
SCOPED_TRACE("after clicking the infobar");
CheckExtensionConsistency(size_before);
@@ -136,7 +132,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, CloseAndReload) {
ASSERT_EQ(crash_size_before + 1,
GetExtensionService()->terminated_extensions()->size());
- CancelCrashedExtensionInfobar(0);
+ CancelInfoBar(0);
ReloadExtension(first_extension_id_);
SCOPED_TRACE("after reloading");
@@ -306,7 +302,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsCrashFirst) {
LoadSecondExtension();
CrashExtension(size_before);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
- AcceptCrashedExtensionInfobar(0);
+ AcceptInfoBar(0);
SCOPED_TRACE("after clicking the infobar");
CheckExtensionConsistency(size_before);
@@ -319,7 +315,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsCrashSecond) {
LoadSecondExtension();
CrashExtension(size_before + 1);
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
- AcceptCrashedExtensionInfobar(0);
+ AcceptInfoBar(0);
SCOPED_TRACE("after clicking the infobar");
CheckExtensionConsistency(size_before);
@@ -344,13 +340,13 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
{
SCOPED_TRACE("first infobar");
- AcceptCrashedExtensionInfobar(0);
+ AcceptInfoBar(0);
CheckExtensionConsistency(size_before);
}
{
SCOPED_TRACE("second infobar");
- AcceptCrashedExtensionInfobar(0);
+ AcceptInfoBar(0);
CheckExtensionConsistency(size_before);
CheckExtensionConsistency(size_before + 1);
}
@@ -367,13 +363,13 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest, TwoExtensionsOneByOne) {
{
SCOPED_TRACE("first infobar");
- AcceptCrashedExtensionInfobar(0);
+ AcceptInfoBar(0);
CheckExtensionConsistency(size_before);
}
{
SCOPED_TRACE("second infobar");
- AcceptCrashedExtensionInfobar(0);
+ AcceptInfoBar(0);
CheckExtensionConsistency(size_before);
CheckExtensionConsistency(size_before + 1);
}
@@ -403,8 +399,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
CrashExtension(size_before);
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
- CancelCrashedExtensionInfobar(0);
- AcceptCrashedExtensionInfobar(1);
+ CancelInfoBar(0);
+ AcceptInfoBar(1);
SCOPED_TRACE("infobars done");
ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
@@ -435,7 +431,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
{
SCOPED_TRACE("second: infobar");
- AcceptCrashedExtensionInfobar(0);
+ AcceptInfoBar(0);
CheckExtensionConsistency(size_before);
CheckExtensionConsistency(size_before + 1);
}
diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc
index 28e0709..a60ecf2 100644
--- a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc
+++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -20,34 +20,24 @@
#include "chrome/common/notification_source.h"
#include "grit/generated_resources.h"
+// ExtensionDisabledDialogDelegate --------------------------------------------
+
class ExtensionDisabledDialogDelegate
: public ExtensionInstallUI::Delegate,
public base::RefCountedThreadSafe<ExtensionDisabledDialogDelegate> {
public:
ExtensionDisabledDialogDelegate(Profile* profile,
ExtensionService* service,
- const Extension* extension)
- : service_(service), extension_(extension) {
- AddRef(); // Balanced in Proceed or Abort.
-
- install_ui_.reset(new ExtensionInstallUI(profile));
- install_ui_->ConfirmInstall(this, extension_);
- }
-
- // Overridden from ExtensionInstallUI::Delegate:
- virtual void InstallUIProceed() {
- service_->GrantPermissionsAndEnableExtension(extension_);
- Release();
- }
- virtual void InstallUIAbort() {
- // Do nothing. The extension will remain disabled.
- Release();
- }
+ const Extension* extension);
private:
friend class base::RefCountedThreadSafe<ExtensionDisabledDialogDelegate>;
- virtual ~ExtensionDisabledDialogDelegate() {}
+ virtual ~ExtensionDisabledDialogDelegate();
+
+ // ExtensionInstallUI::Delegate:
+ virtual void InstallUIProceed();
+ virtual void InstallUIAbort();
// The UI for showing the install dialog when enabling.
scoped_ptr<ExtensionInstallUI> install_ui_;
@@ -56,83 +46,129 @@ class ExtensionDisabledDialogDelegate
const Extension* extension_;
};
-class ExtensionDisabledInfobarDelegate
- : public ConfirmInfoBarDelegate,
- public NotificationObserver {
+ExtensionDisabledDialogDelegate::ExtensionDisabledDialogDelegate(
+ Profile* profile,
+ ExtensionService* service,
+ const Extension* extension)
+ : service_(service), extension_(extension) {
+ AddRef(); // Balanced in Proceed or Abort.
+
+ install_ui_.reset(new ExtensionInstallUI(profile));
+ install_ui_->ConfirmInstall(this, extension_);
+}
+
+ExtensionDisabledDialogDelegate::~ExtensionDisabledDialogDelegate() {
+}
+
+void ExtensionDisabledDialogDelegate::InstallUIProceed() {
+ service_->GrantPermissionsAndEnableExtension(extension_);
+ Release();
+}
+
+void ExtensionDisabledDialogDelegate::InstallUIAbort() {
+ // Do nothing. The extension will remain disabled.
+ Release();
+}
+
+
+// ExtensionDisabledInfobarDelegate -------------------------------------------
+
+class ExtensionDisabledInfobarDelegate : public ConfirmInfoBarDelegate,
+ public NotificationObserver {
public:
ExtensionDisabledInfobarDelegate(TabContents* tab_contents,
ExtensionService* service,
- const Extension* extension)
- : ConfirmInfoBarDelegate(tab_contents),
- tab_contents_(tab_contents),
- service_(service),
- extension_(extension) {
- // The user might re-enable the extension in other ways, so watch for that.
- registrar_.Add(this, NotificationType::EXTENSION_LOADED,
- Source<Profile>(service->profile()));
- registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
- Source<Profile>(service->profile()));
- }
- virtual ~ExtensionDisabledInfobarDelegate() {
- }
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringFUTF16(extension_->is_app() ?
- IDS_APP_DISABLED_INFOBAR_LABEL : IDS_EXTENSION_DISABLED_INFOBAR_LABEL,
- UTF8ToUTF16(extension_->name()));
- }
- virtual SkBitmap* GetIcon() const {
- return NULL;
- }
- virtual int GetButtons() const {
- return BUTTON_OK;
- }
- virtual string16 GetButtonLabel(
- ConfirmInfoBarDelegate::InfoBarButton button) const {
- return l10n_util::GetStringUTF16(
- IDS_EXTENSION_DISABLED_INFOBAR_ENABLE_BUTTON);
- }
- virtual bool Accept() {
- // This object manages its own lifetime.
- new ExtensionDisabledDialogDelegate(tab_contents_->profile(),
- service_, extension_);
- return true;
- }
- virtual void InfoBarClosed() {
- delete this;
- }
+ const Extension* extension);
+ private:
+ virtual ~ExtensionDisabledInfobarDelegate();
+
+ // ConfirmInfoBarDelegate:
+ virtual void InfoBarClosed();
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
+
+ // NotificationObserver:
virtual void Observe(NotificationType type,
const NotificationSource& source,
- const NotificationDetails& details) {
- // TODO(mpcomplete): RemoveInfoBar doesn't seem to always result in us
- // getting deleted.
- const Extension* extension = NULL;
- switch (type.value) {
- case NotificationType::EXTENSION_LOADED:
- extension = Details<const Extension>(details).ptr();
- break;
- case NotificationType::EXTENSION_UNLOADED: {
- UnloadedExtensionInfo* info =
- Details<UnloadedExtensionInfo>(details).ptr();
- if (info->reason == UnloadedExtensionInfo::DISABLE)
- extension = info->extension;
- break;
- }
- default:
- NOTREACHED();
- return;
- }
- if (extension == extension_)
- tab_contents_->RemoveInfoBar(this);
- }
+ const NotificationDetails& details);
- private:
NotificationRegistrar registrar_;
TabContents* tab_contents_;
ExtensionService* service_;
const Extension* extension_;
};
+ExtensionDisabledInfobarDelegate::ExtensionDisabledInfobarDelegate(
+ TabContents* tab_contents,
+ ExtensionService* service,
+ const Extension* extension)
+ : ConfirmInfoBarDelegate(tab_contents),
+ tab_contents_(tab_contents),
+ service_(service),
+ extension_(extension) {
+ // The user might re-enable the extension in other ways, so watch for that.
+ registrar_.Add(this, NotificationType::EXTENSION_LOADED,
+ Source<Profile>(service->profile()));
+ registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
+ Source<Profile>(service->profile()));
+}
+
+ExtensionDisabledInfobarDelegate::~ExtensionDisabledInfobarDelegate() {
+}
+
+void ExtensionDisabledInfobarDelegate::InfoBarClosed() {
+ delete this;
+}
+
+string16 ExtensionDisabledInfobarDelegate::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(extension_->is_app() ?
+ IDS_APP_DISABLED_INFOBAR_LABEL : IDS_EXTENSION_DISABLED_INFOBAR_LABEL,
+ UTF8ToUTF16(extension_->name()));
+}
+
+int ExtensionDisabledInfobarDelegate::GetButtons() const {
+ return BUTTON_OK;
+}
+
+string16 ExtensionDisabledInfobarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ DCHECK_EQ(BUTTON_OK, button);
+ return l10n_util::GetStringUTF16(
+ IDS_EXTENSION_DISABLED_INFOBAR_ENABLE_BUTTON);
+}
+
+bool ExtensionDisabledInfobarDelegate::Accept() {
+ // This object manages its own lifetime.
+ new ExtensionDisabledDialogDelegate(tab_contents_->profile(), service_,
+ extension_);
+ return true;
+}
+
+void ExtensionDisabledInfobarDelegate::Observe(
+ NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ // TODO(mpcomplete): RemoveInfoBar doesn't seem to always result in us getting
+ // deleted.
+ const Extension* extension;
+ if (type.value == NotificationType::EXTENSION_LOADED) {
+ extension = Details<const Extension>(details).ptr();
+ } else {
+ DCHECK_EQ(NotificationType::EXTENSION_UNLOADED, type.value);
+ UnloadedExtensionInfo* info = Details<UnloadedExtensionInfo>(details).ptr();
+ extension = (info->reason == UnloadedExtensionInfo::DISABLE) ?
+ info->extension : NULL;
+ }
+ if (extension == extension_)
+ tab_contents_->RemoveInfoBar(this);
+}
+
+
+// Globals --------------------------------------------------------------------
+
void ShowExtensionDisabledUI(ExtensionService* service, Profile* profile,
const Extension* extension) {
Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc
index 97889d7..92907be 100644
--- a/chrome/browser/extensions/extension_dom_ui.cc
+++ b/chrome/browser/extensions/extension_dom_ui.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -184,7 +184,7 @@ void ExtensionDOMUI::ProcessDOMUIMessage(
extension_function_dispatcher_->HandleRequest(params);
}
-Browser* ExtensionDOMUI::GetBrowser() const {
+Browser* ExtensionDOMUI::GetBrowser() {
TabContents* contents = tab_contents();
TabContentsIterator tab_iterator;
for (; !tab_iterator.done(); ++tab_iterator) {
diff --git a/chrome/browser/extensions/extension_dom_ui.h b/chrome/browser/extensions/extension_dom_ui.h
index ea59b41..c0f8cf6 100644
--- a/chrome/browser/extensions/extension_dom_ui.h
+++ b/chrome/browser/extensions/extension_dom_ui.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -47,7 +47,7 @@ class ExtensionDOMUI
virtual void ProcessDOMUIMessage(const ViewHostMsg_DomMessage_Params& params);
// ExtensionFunctionDispatcher::Delegate
- virtual Browser* GetBrowser() const;
+ virtual Browser* GetBrowser();
virtual gfx::NativeView GetNativeViewOfHost();
virtual gfx::NativeWindow GetCustomFrameNativeWindow();
virtual TabContents* associated_tab_contents() const;
diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h
index 9969b1f..5a10b92 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.h
+++ b/chrome/browser/extensions/extension_function_dispatcher.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -34,7 +34,7 @@ class ExtensionFunctionDispatcher {
public:
// Returns the browser that this delegate is associated with, if any.
// Returns NULL otherwise.
- virtual Browser* GetBrowser() const = 0;
+ virtual Browser* GetBrowser() = 0;
// Returns the native view for this extension view, if any. This may be NULL
// if the view is not visible.
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index c5f55a0..92ce3d0 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -212,7 +212,11 @@ void ExtensionHost::CreateRenderViewNow() {
this);
}
-Browser* ExtensionHost::GetBrowser() const {
+const Browser* ExtensionHost::GetBrowser() const {
+ return view() ? view()->browser() : NULL;
+}
+
+Browser* ExtensionHost::GetBrowser() {
return view() ? view()->browser() : NULL;
}
@@ -791,7 +795,7 @@ int ExtensionHost::GetBrowserWindowID() const {
// If the host is bound to a browser, then extract its window id.
// Extensions hosted in ExternalTabContainer objects may not have
// an associated browser.
- Browser* browser = GetBrowser();
+ const Browser* browser = GetBrowser();
if (browser)
window_id = ExtensionTabUtil::GetWindowId(browser);
} else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) {
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 1109147..234e40e 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -53,14 +53,14 @@ class ExtensionHost : public RenderViewHostDelegate,
#if defined(TOOLKIT_VIEWS)
void set_view(ExtensionView* view) { view_.reset(view); }
- ExtensionView* view() const { return view_.get(); }
+ const ExtensionView* view() const { return view_.get(); }
+ ExtensionView* view() { return view_.get(); }
#elif defined(OS_MACOSX)
- ExtensionViewMac* view() const { return view_.get(); }
+ const ExtensionViewMac* view() const { return view_.get(); }
+ ExtensionViewMac* view() { return view_.get(); }
#elif defined(TOOLKIT_GTK)
- ExtensionViewGtk* view() const { return view_.get(); }
-#else
- // TODO(port): implement
- void* view() const { return NULL; }
+ const ExtensionViewGtk* view() const { return view_.get(); }
+ ExtensionViewGtk* view() { return view_.get(); }
#endif
// Create an ExtensionView and tie it to this host and |browser|. Note NULL
@@ -69,7 +69,7 @@ class ExtensionHost : public RenderViewHostDelegate,
// instantiate Browser objects.
void CreateView(Browser* browser);
- const Extension* extension() { return extension_; }
+ const Extension* extension() const { return extension_; }
RenderViewHost* render_view_host() const { return render_view_host_; }
RenderProcessHost* render_process_host() const;
SiteInstance* site_instance() const;
@@ -220,8 +220,11 @@ class ExtensionHost : public RenderViewHostDelegate,
// Actually create the RenderView for this host. See CreateRenderViewSoon.
void CreateRenderViewNow();
+ // Const version of below function.
+ const Browser* GetBrowser() const;
+
// ExtensionFunctionDispatcher::Delegate
- virtual Browser* GetBrowser() const;
+ virtual Browser* GetBrowser();
virtual gfx::NativeView GetNativeViewOfHost();
// Handles keyboard events that were not handled by HandleKeyboardEvent().
diff --git a/chrome/browser/extensions/extension_infobar_delegate.cc b/chrome/browser/extensions/extension_infobar_delegate.cc
index 140a82f..c37e5d0 100644
--- a/chrome/browser/extensions/extension_infobar_delegate.cc
+++ b/chrome/browser/extensions/extension_infobar_delegate.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -39,10 +39,6 @@ ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() {
observer_->OnDelegateDeleted();
}
-void ExtensionInfoBarDelegate::InfoBarDismissed() {
- closing_ = true;
-}
-
bool ExtensionInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
ExtensionInfoBarDelegate* extension_delegate =
delegate->AsExtensionInfoBarDelegate();
@@ -59,17 +55,21 @@ bool ExtensionInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
extension_host_->extension();
}
+void ExtensionInfoBarDelegate::InfoBarDismissed() {
+ closing_ = true;
+}
+
void ExtensionInfoBarDelegate::InfoBarClosed() {
delete this;
}
-ExtensionInfoBarDelegate*
-ExtensionInfoBarDelegate::AsExtensionInfoBarDelegate() {
- return this;
+InfoBarDelegate::Type ExtensionInfoBarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
}
-InfoBarDelegate::Type ExtensionInfoBarDelegate::GetInfoBarType() {
- return PAGE_ACTION_TYPE;
+ExtensionInfoBarDelegate*
+ ExtensionInfoBarDelegate::AsExtensionInfoBarDelegate() {
+ return this;
}
void ExtensionInfoBarDelegate::Observe(NotificationType type,
diff --git a/chrome/browser/extensions/extension_infobar_delegate.h b/chrome/browser/extensions/extension_infobar_delegate.h
index f286a11..43ca959 100644
--- a/chrome/browser/extensions/extension_infobar_delegate.h
+++ b/chrome/browser/extensions/extension_infobar_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -27,30 +27,33 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate,
virtual ~DelegateObserver() {}
};
- ExtensionInfoBarDelegate(Browser* browser, TabContents* contents,
- const Extension* extension, const GURL& url);
- ~ExtensionInfoBarDelegate();
-
+ ExtensionInfoBarDelegate(Browser* browser,
+ TabContents* contents,
+ const Extension* extension,
+ const GURL& url);
const Extension* extension() { return extension_; }
ExtensionHost* extension_host() { return extension_host_.get(); }
void set_observer(DelegateObserver* observer) { observer_ = observer; }
- // Overridden from InfoBarDelegate:
- virtual void InfoBarDismissed();
+ bool closing() { return closing_; }
+
+ private:
+ virtual ~ExtensionInfoBarDelegate();
+
+ // InfoBarDelegate:
+ virtual InfoBar* CreateInfoBar();
virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
+ virtual void InfoBarDismissed();
virtual void InfoBarClosed();
- virtual InfoBar* CreateInfoBar();
+ virtual Type GetInfoBarType() const;
virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate();
- virtual Type GetInfoBarType();
- // Overridden from NotificationObserver:
+ // NotificationObserver:
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
- bool closing() { return closing_; }
- private:
// The extension host we are showing the InfoBar for. The delegate needs to
// own this since the InfoBar gets deleted and recreated when you switch tabs
// and come back (and we don't want the user's interaction with the InfoBar to
@@ -61,9 +64,7 @@ class ExtensionInfoBarDelegate : public InfoBarDelegate,
DelegateObserver* observer_;
const Extension* extension_;
-
TabContents* tab_contents_;
-
NotificationRegistrar registrar_;
// Whether we are currently animating to close. This is used to ignore
diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc
index 94b5ada..ab496f5 100644
--- a/chrome/browser/extensions/extension_install_ui.cc
+++ b/chrome/browser/extensions/extension_install_ui.cc
@@ -228,9 +228,10 @@ void ExtensionInstallUI::OnImageLoaded(
}
}
-void ExtensionInstallUI::ShowThemeInfoBar(
- const std::string& previous_theme_id, bool previous_use_system_theme,
- const Extension* new_theme, Profile* profile) {
+void ExtensionInstallUI::ShowThemeInfoBar(const std::string& previous_theme_id,
+ bool previous_use_system_theme,
+ const Extension* new_theme,
+ Profile* profile) {
if (!new_theme->is_theme())
return;
@@ -263,10 +264,8 @@ void ExtensionInstallUI::ShowThemeInfoBar(
}
// Then either replace that old one or add a new one.
- InfoBarDelegate* new_delegate =
- GetNewThemeInstalledInfoBarDelegate(
- tab_contents, new_theme,
- previous_theme_id, previous_use_system_theme);
+ InfoBarDelegate* new_delegate = GetNewThemeInstalledInfoBarDelegate(
+ tab_contents, new_theme, previous_theme_id, previous_use_system_theme);
if (old_delegate)
tab_contents->ReplaceInfoBar(old_delegate, new_delegate);
@@ -303,20 +302,22 @@ void ExtensionInstallUI::ShowGenericExtensionInstalledInfoBar(
extension_name) +
UTF8ToUTF16(" ") +
l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC);
- InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate(
- tab_contents, msg, new SkBitmap(icon_), true);
+ InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate(tab_contents,
+ new SkBitmap(icon_), msg, true);
tab_contents->AddInfoBar(delegate);
}
#endif
InfoBarDelegate* ExtensionInstallUI::GetNewThemeInstalledInfoBarDelegate(
- TabContents* tab_contents, const Extension* new_theme,
- const std::string& previous_theme_id, bool previous_use_system_theme) {
+ TabContents* tab_contents,
+ const Extension* new_theme,
+ const std::string& previous_theme_id,
+ bool previous_use_system_theme) {
#if defined(TOOLKIT_GTK)
return new GtkThemeInstalledInfoBarDelegate(tab_contents, new_theme,
previous_theme_id, previous_use_system_theme);
#else
return new ThemeInstalledInfoBarDelegate(tab_contents, new_theme,
- previous_theme_id);
+ previous_theme_id);
#endif
}
diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc
index 6866325..57c9bc8 100644
--- a/chrome/browser/extensions/extension_install_ui_browsertest.cc
+++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -25,8 +25,8 @@ class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest {
TabContents* tab_contents = browser()->GetSelectedTabContents();
ASSERT_TRUE(tab_contents);
ASSERT_EQ(1, tab_contents->infobar_delegate_count());
- ThemeInstalledInfoBarDelegate* delegate = tab_contents->
- GetInfoBarDelegateAt(0)->AsThemePreviewInfobarDelegate();
+ ConfirmInfoBarDelegate* delegate =
+ tab_contents->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
ASSERT_TRUE(delegate);
delegate->Cancel();
ASSERT_EQ(0, tab_contents->infobar_delegate_count());
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index b58e07c..e39d1f5 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -16,7 +16,6 @@
#include "chrome/browser/browser_window.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/browser/extensions/extension_infobar_delegate.h"
#include "chrome/browser/extensions/extension_tabs_module_constants.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc
index 3656175..5289f66 100644
--- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc
+++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -33,6 +33,10 @@ ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate(
NotificationService::AllSources());
}
+bool ThemeInstalledInfoBarDelegate::MatchesTheme(const Extension* theme) {
+ return theme && (theme->id() == theme_id_);
+}
+
ThemeInstalledInfoBarDelegate::~ThemeInstalledInfoBarDelegate() {
// We don't want any notifications while we're running our destructor.
registrar_.RemoveAll();
@@ -40,13 +44,25 @@ ThemeInstalledInfoBarDelegate::~ThemeInstalledInfoBarDelegate() {
profile_->GetThemeProvider()->OnInfobarDestroyed();
}
-void ThemeInstalledInfoBarDelegate::InfoBarClosed() {
- delete this;
+bool ThemeInstalledInfoBarDelegate::Cancel() {
+ if (!previous_theme_id_.empty()) {
+ ExtensionService* service = profile_->GetExtensionService();
+ if (service) {
+ const Extension* previous_theme =
+ service->GetExtensionById(previous_theme_id_, true);
+ if (previous_theme) {
+ profile_->SetTheme(previous_theme);
+ return true;
+ }
+ }
+ }
+
+ profile_->ClearTheme();
+ return true;
}
-string16 ThemeInstalledInfoBarDelegate::GetMessageText() const {
- return l10n_util::GetStringFUTF16(IDS_THEME_INSTALL_INFOBAR_LABEL,
- UTF8ToUTF16(name_));
+void ThemeInstalledInfoBarDelegate::InfoBarClosed() {
+ delete this;
}
SkBitmap* ThemeInstalledInfoBarDelegate::GetIcon() const {
@@ -60,34 +76,19 @@ ThemeInstalledInfoBarDelegate*
return this;
}
+string16 ThemeInstalledInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(IDS_THEME_INSTALL_INFOBAR_LABEL,
+ UTF8ToUTF16(name_));
+}
+
int ThemeInstalledInfoBarDelegate::GetButtons() const {
return BUTTON_CANCEL;
}
string16 ThemeInstalledInfoBarDelegate::GetButtonLabel(
- ConfirmInfoBarDelegate::InfoBarButton button) const {
- // The InfoBar will create a default OK button and make it invisible.
- // TODO(mirandac): remove the default OK button from ConfirmInfoBar.
- return (button == BUTTON_CANCEL) ?
- l10n_util::GetStringUTF16(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON) :
- string16();
-}
-
-bool ThemeInstalledInfoBarDelegate::Cancel() {
- if (!previous_theme_id_.empty()) {
- ExtensionService* service = profile_->GetExtensionService();
- if (service) {
- const Extension* previous_theme =
- service->GetExtensionById(previous_theme_id_, true);
- if (previous_theme) {
- profile_->SetTheme(previous_theme);
- return true;
- }
- }
- }
-
- profile_->ClearTheme();
- return true;
+ InfoBarButton button) const {
+ DCHECK_EQ(BUTTON_CANCEL, button);
+ return l10n_util::GetStringUTF16(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON);
}
void ThemeInstalledInfoBarDelegate::Observe(
@@ -115,7 +116,3 @@ void ThemeInstalledInfoBarDelegate::Observe(
}
}
}
-
-bool ThemeInstalledInfoBarDelegate::MatchesTheme(const Extension* theme) {
- return (theme && theme->id() == theme_id_);
-}
diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h
index b1ed99e..94db6bb 100644
--- a/chrome/browser/extensions/theme_installed_infobar_delegate.h
+++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -21,28 +21,33 @@ class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate,
ThemeInstalledInfoBarDelegate(TabContents* tab_contents,
const Extension* new_theme,
const std::string& previous_theme_id);
+
+ // Returns true if the given theme is the same as the one associated with this
+ // info bar.
+ bool MatchesTheme(const Extension* theme);
+
+ protected:
virtual ~ThemeInstalledInfoBarDelegate();
+
+ Profile* profile() { return profile_; }
+
+ // ConfirmInfoBarDelegate:
+ virtual bool Cancel();
+
+ private:
+ // ConfirmInfoBarDelegate:
virtual void InfoBarClosed();
- virtual string16 GetMessageText() const;
virtual SkBitmap* GetIcon() const;
virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate();
+ virtual string16 GetMessageText() const;
virtual int GetButtons() const;
- virtual string16 GetButtonLabel(
- ConfirmInfoBarDelegate::InfoBarButton button) const;
- virtual bool Cancel();
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
- // Returns true if the given theme is the same as the one associated with this
- // info bar.
- bool MatchesTheme(const Extension* theme);
-
- // NotificationObserver implementation.
+ // NotificationObserver:
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
- protected:
- Profile* profile() { return profile_; }
- private:
Profile* profile_;
// Name of theme that's just been installed.
diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc
index 19518c8..a20e829 100644
--- a/chrome/browser/external_tab_container_win.cc
+++ b/chrome/browser/external_tab_container_win.cc
@@ -921,10 +921,9 @@ void ExternalTabContainer::SetEnableExtensionAutomation(
}
}
-void ExternalTabContainer::InfoBarSizeChanged(bool is_animating) {
- if (external_tab_view_) {
+void ExternalTabContainer::InfoBarContainerSizeChanged(bool is_animating) {
+ if (external_tab_view_)
external_tab_view_->Layout();
- }
}
// ExternalTabContainer instances do not have a window.
diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h
index 0495dde..58d656d 100644
--- a/chrome/browser/external_tab_container_win.h
+++ b/chrome/browser/external_tab_container_win.h
@@ -38,7 +38,7 @@ class ViewProp;
// This class serves as the container window for an external tab.
// An external tab is a Chrome tab that is meant to displayed in an
// external process. This class provides the FocusManger needed by the
-// TabContents as well as an implementation of TabContentsDelagate.
+// TabContents as well as an implementation of TabContentsDelegate.
class ExternalTabContainer : public TabContentsDelegate,
public NotificationObserver,
public views::WidgetWin,
@@ -207,7 +207,7 @@ class ExternalTabContainer : public TabContentsDelegate,
}
// InfoBarContainer::Delegate overrides
- virtual void InfoBarSizeChanged(bool is_animating);
+ virtual void InfoBarContainerSizeChanged(bool is_animating);
virtual void TabContentsCreated(TabContents* new_contents);
diff --git a/chrome/browser/geolocation/geolocation_permission_context.cc b/chrome/browser/geolocation/geolocation_permission_context.cc
index fa07261..04c9c6e5 100644
--- a/chrome/browser/geolocation/geolocation_permission_context.cc
+++ b/chrome/browser/geolocation/geolocation_permission_context.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -34,16 +34,7 @@
#include "net/base/net_util.h"
#include "ui/base/resource/resource_bundle.h"
-namespace {
-
-const char kGeolocationLearnMoreUrl[] =
-#if defined(OS_CHROMEOS)
- "http://www.google.com/support/chromeos/bin/answer.py?answer=142065";
-#else
- "http://www.google.com/support/chrome/bin/answer.py?answer=142065";
-#endif
-
-} // namespace
+// GeolocationInfoBarQueueController ------------------------------------------
// This class controls the geolocation infobar queue per profile, and it's an
// internal class to GeolocationPermissionContext.
@@ -62,25 +53,32 @@ class GeolocationInfoBarQueueController : NotificationObserver {
// The InfoBar will be displayed immediately if the tab is not already
// displaying one, otherwise it'll be queued.
- void CreateInfoBarRequest(
- int render_process_id, int render_view_id, int bridge_id,
- const GURL& requesting_frame, const GURL& emebedder);
+ void CreateInfoBarRequest(int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ const GURL& emebedder);
// Cancels a specific infobar request.
- void CancelInfoBarRequest(
- int render_process_id, int render_view_id, int bridge_id);
+ void CancelInfoBarRequest(int render_process_id,
+ int render_view_id,
+ int bridge_id);
// Called by the InfoBarDelegate to notify it's closed. It'll display a new
// InfoBar if there's any request pending for this tab.
- void OnInfoBarClosed(
- int render_process_id, int render_view_id, int bridge_id);
+ void OnInfoBarClosed(int render_process_id,
+ int render_view_id,
+ int bridge_id);
// Called by the InfoBarDelegate to notify permission has been set.
// It'll notify and dismiss any other pending InfoBar request for the same
// |requesting_frame| and embedder.
- void OnPermissionSet(
- int render_process_id, int render_view_id, int bridge_id,
- const GURL& requesting_frame, const GURL& embedder, bool allowed);
+ void OnPermissionSet(int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ const GURL& embedder,
+ bool allowed);
// NotificationObserver
virtual void Observe(NotificationType type,
@@ -108,74 +106,41 @@ class GeolocationInfoBarQueueController : NotificationObserver {
namespace {
-// This is the delegate used to display the confirmation info bar.
+const char kGeolocationLearnMoreUrl[] =
+#if defined(OS_CHROMEOS)
+ "http://www.google.com/support/chromeos/bin/answer.py?answer=142065";
+#else
+ "http://www.google.com/support/chrome/bin/answer.py?answer=142065";
+#endif
+
+
+// GeolocationConfirmInfoBarDelegate ------------------------------------------
+
class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
GeolocationConfirmInfoBarDelegate(
- TabContents* tab_contents, GeolocationInfoBarQueueController* controller,
- int render_process_id, int render_view_id, int bridge_id,
+ TabContents* tab_contents,
+ GeolocationInfoBarQueueController* controller,
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
const GURL& requesting_frame_url,
- const std::string& display_languages)
- : ConfirmInfoBarDelegate(tab_contents),
- tab_contents_(tab_contents),
- controller_(controller),
- render_process_id_(render_process_id),
- render_view_id_(render_view_id),
- bridge_id_(bridge_id),
- requesting_frame_url_(requesting_frame_url),
- display_languages_(display_languages) {
- }
-
- // ConfirmInfoBarDelegate
- virtual void InfoBarClosed() {
- controller_->OnInfoBarClosed(render_process_id_, render_view_id_,
- bridge_id_);
- delete this;
- }
- virtual Type GetInfoBarType() { return PAGE_ACTION_TYPE; }
- virtual bool Accept() { return OnPermissionSet(true); }
- virtual bool Cancel() { return OnPermissionSet(false); }
- virtual int GetButtons() const { return BUTTON_OK | BUTTON_CANCEL; }
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- switch (button) {
- case BUTTON_OK:
- return l10n_util::GetStringUTF16(IDS_GEOLOCATION_ALLOW_BUTTON);
- case BUTTON_CANCEL:
- return l10n_util::GetStringUTF16(IDS_GEOLOCATION_DENY_BUTTON);
- default:
- // All buttons are labeled above.
- NOTREACHED() << "Bad button id " << button;
- return string16();
- }
- }
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringFUTF16(
- IDS_GEOLOCATION_INFOBAR_QUESTION,
- net::FormatUrl(requesting_frame_url_.GetOrigin(), display_languages_));
- }
- virtual SkBitmap* GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_GEOLOCATION_INFOBAR_ICON);
- }
- virtual string16 GetLinkText() {
- return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
- }
- virtual bool LinkClicked(WindowOpenDisposition disposition) {
- GURL learn_more_url =
- google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl));
- // Ignore the click disposition and always open in a new top level tab.
- tab_contents_->OpenURL(
- learn_more_url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
- return false; // Do not dismiss the info bar.
- }
+ const std::string& display_languages);
private:
- bool OnPermissionSet(bool confirm) {
- controller_->OnPermissionSet(
- render_process_id_, render_view_id_, bridge_id_, requesting_frame_url_,
- tab_contents_->GetURL(), confirm);
- return true;
- }
+ virtual ~GeolocationConfirmInfoBarDelegate();
+
+ // ConfirmInfoBarDelegate:
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual Type GetInfoBarType() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
+ virtual bool Cancel();
+ virtual string16 GetLinkText();
+ virtual bool LinkClicked(WindowOpenDisposition disposition);
TabContents* tab_contents_;
GeolocationInfoBarQueueController* controller_;
@@ -188,8 +153,88 @@ class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate {
DISALLOW_IMPLICIT_CONSTRUCTORS(GeolocationConfirmInfoBarDelegate);
};
+GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate(
+ TabContents* tab_contents,
+ GeolocationInfoBarQueueController* controller,
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame_url,
+ const std::string& display_languages)
+ : ConfirmInfoBarDelegate(tab_contents),
+ tab_contents_(tab_contents),
+ controller_(controller),
+ render_process_id_(render_process_id),
+ render_view_id_(render_view_id),
+ bridge_id_(bridge_id),
+ requesting_frame_url_(requesting_frame_url),
+ display_languages_(display_languages) {
+}
+
+GeolocationConfirmInfoBarDelegate::~GeolocationConfirmInfoBarDelegate() {
+}
+
+void GeolocationConfirmInfoBarDelegate::InfoBarClosed() {
+ controller_->OnInfoBarClosed(render_process_id_, render_view_id_,
+ bridge_id_);
+ delete this;
+}
+
+SkBitmap* GeolocationConfirmInfoBarDelegate::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_GEOLOCATION_INFOBAR_ICON);
+}
+
+InfoBarDelegate::Type
+ GeolocationConfirmInfoBarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+}
+
+string16 GeolocationConfirmInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION,
+ net::FormatUrl(requesting_frame_url_.GetOrigin(), display_languages_));
+}
+
+int GeolocationConfirmInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
+
+string16 GeolocationConfirmInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
+ IDS_GEOLOCATION_ALLOW_BUTTON : IDS_GEOLOCATION_DENY_BUTTON);
+}
+
+bool GeolocationConfirmInfoBarDelegate::Accept() {
+ controller_->OnPermissionSet(render_process_id_, render_view_id_, bridge_id_,
+ requesting_frame_url_, tab_contents_->GetURL(), true);
+ return true;
+}
+
+bool GeolocationConfirmInfoBarDelegate::Cancel() {
+ controller_->OnPermissionSet(render_process_id_, render_view_id_, bridge_id_,
+ requesting_frame_url_, tab_contents_->GetURL(), false);
+ return true;
+}
+
+string16 GeolocationConfirmInfoBarDelegate::GetLinkText() {
+ return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
+}
+
+bool GeolocationConfirmInfoBarDelegate::LinkClicked(
+ WindowOpenDisposition disposition) {
+ // Ignore the click disposition and always open in a new top level tab.
+ tab_contents_->OpenURL(
+ google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)),
+ GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
+ return false; // Do not dismiss the info bar.
+}
+
} // namespace
+
+// GeolocationInfoBarQueueController ------------------------------------------
+
struct GeolocationInfoBarQueueController::PendingInfoBarRequest {
int render_process_id;
int render_view_id;
@@ -228,8 +273,11 @@ GeolocationInfoBarQueueController::~GeolocationInfoBarQueueController() {
}
void GeolocationInfoBarQueueController::CreateInfoBarRequest(
- int render_process_id, int render_view_id, int bridge_id,
- const GURL& requesting_frame, const GURL& embedder) {
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ const GURL& embedder) {
// This makes sure that no duplicates are added to
// |pending_infobar_requests_| as an artificial permission request may
// already exist in the queue as per
@@ -238,14 +286,13 @@ void GeolocationInfoBarQueueController::CreateInfoBarRequest(
// TODO(joth): Once we have CLIENT_BASED_GEOLOCATION and
// WTF_USE_PREEMPT_GEOLOCATION_PERMISSION set in WebKit we should be able to
// just use a DCHECK to check if a duplicate is attempting to be added.
- PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin();
- while (i != pending_infobar_requests_.end()) {
+ for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin();
+ i != pending_infobar_requests_.end(); ++i) {
if (i->Equals(render_process_id, render_view_id, bridge_id)) {
// The request already exists.
DCHECK(i->IsForPair(requesting_frame, embedder));
return;
}
- ++i;
}
PendingInfoBarRequest pending_infobar_request;
pending_infobar_request.render_process_id = render_process_id;
@@ -259,18 +306,21 @@ void GeolocationInfoBarQueueController::CreateInfoBarRequest(
}
void GeolocationInfoBarQueueController::CancelInfoBarRequest(
- int render_process_id, int render_view_id, int bridge_id) {
+ int render_process_id,
+ int render_view_id,
+ int bridge_id) {
for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin();
i != pending_infobar_requests_.end(); ++i) {
if (i->Equals(render_process_id, render_view_id, bridge_id)) {
CancelInfoBarRequestInternal(i);
- break;
+ return;
}
}
}
-void GeolocationInfoBarQueueController::OnInfoBarClosed(
- int render_process_id, int render_view_id, int bridge_id) {
+void GeolocationInfoBarQueueController::OnInfoBarClosed(int render_process_id,
+ int render_view_id,
+ int bridge_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin();
i != pending_infobar_requests_.end(); ++i) {
@@ -283,8 +333,12 @@ void GeolocationInfoBarQueueController::OnInfoBarClosed(
}
void GeolocationInfoBarQueueController::OnPermissionSet(
- int render_process_id, int render_view_id, int bridge_id,
- const GURL& requesting_frame, const GURL& embedder, bool allowed) {
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ const GURL& embedder,
+ bool allowed) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Persist the permission.
ContentSetting content_setting =
@@ -306,11 +360,11 @@ void GeolocationInfoBarQueueController::OnPermissionSet(
// Cancel it first, and then notify the permission.
// Note: if the pending request had an infobar, TabContents will
// eventually close it and we will pump the queue via OnInfoBarClosed().
- PendingInfoBarRequest other_request = *i;
+ PendingInfoBarRequest copied_request = *i;
i = CancelInfoBarRequestInternal(i);
geolocation_permission_context_->NotifyPermissionSet(
- other_request.render_process_id, other_request.render_view_id,
- other_request.bridge_id, other_request.requesting_frame, allowed);
+ copied_request.render_process_id, copied_request.render_view_id,
+ copied_request.bridge_id, copied_request.requesting_frame, allowed);
} else {
++i;
}
@@ -335,8 +389,8 @@ void GeolocationInfoBarQueueController::Observe(
}
}
-void GeolocationInfoBarQueueController::ShowQueuedInfoBar(
- int render_process_id, int render_view_id) {
+void GeolocationInfoBarQueueController::ShowQueuedInfoBar(int render_process_id,
+ int render_view_id) {
TabContents* tab_contents =
tab_util::GetTabContentsByID(render_process_id, render_view_id);
for (PendingInfoBarRequests::iterator i = pending_infobar_requests_.begin();
@@ -352,17 +406,14 @@ void GeolocationInfoBarQueueController::ShowQueuedInfoBar(
// Check if already displayed.
if (i->infobar_delegate)
break;
- if (!registrar_.IsRegistered(
- this, NotificationType::TAB_CONTENTS_DESTROYED,
+ if (!registrar_.IsRegistered(this, NotificationType::TAB_CONTENTS_DESTROYED,
Source<TabContents>(tab_contents))) {
- registrar_.Add(
- this, NotificationType::TAB_CONTENTS_DESTROYED,
+ registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
Source<TabContents>(tab_contents));
}
- i->infobar_delegate = new GeolocationConfirmInfoBarDelegate(
- tab_contents, this,
- render_process_id, render_view_id,
- i->bridge_id, i->requesting_frame,
+ i->infobar_delegate = new GeolocationConfirmInfoBarDelegate(tab_contents,
+ this, render_process_id, render_view_id, i->bridge_id,
+ i->requesting_frame,
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
tab_contents->AddInfoBar(i->infobar_delegate);
break;
@@ -388,9 +439,8 @@ std::vector<GeolocationInfoBarQueueController::PendingInfoBarRequest>::iterator
GeolocationPermissionContext::GeolocationPermissionContext(
Profile* profile)
: profile_(profile),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- geolocation_infobar_queue_controller_(
- new GeolocationInfoBarQueueController(this, profile))) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(geolocation_infobar_queue_controller_(
+ new GeolocationInfoBarQueueController(this, profile))) {
}
GeolocationPermissionContext::~GeolocationPermissionContext() {
@@ -400,11 +450,9 @@ void GeolocationPermissionContext::RequestGeolocationPermission(
int render_process_id, int render_view_id, int bridge_id,
const GURL& requesting_frame) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &GeolocationPermissionContext::RequestGeolocationPermission,
- render_process_id, render_view_id, bridge_id, requesting_frame));
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod(
+ this, &GeolocationPermissionContext::RequestGeolocationPermission,
+ render_process_id, render_view_id, bridge_id, requesting_frame));
return;
}
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -430,8 +478,8 @@ void GeolocationPermissionContext::RequestGeolocationPermission(
if (!tab_contents) {
// The tab may have gone away, or the request may not be from a tab at all.
LOG(WARNING) << "Attempt to use geolocation tabless renderer: "
- << render_process_id << "," << render_view_id << "," << bridge_id
- << " (can't prompt user without a visible tab)";
+ << render_process_id << "," << render_view_id << ","
+ << bridge_id << " (can't prompt user without a visible tab)";
NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
requesting_frame, false);
return;
@@ -440,8 +488,8 @@ void GeolocationPermissionContext::RequestGeolocationPermission(
GURL embedder = tab_contents->GetURL();
if (!requesting_frame.is_valid() || !embedder.is_valid()) {
LOG(WARNING) << "Attempt to use geolocation from an invalid URL: "
- << requesting_frame << "," << embedder
- << " (geolocation is not supported in popups)";
+ << requesting_frame << "," << embedder
+ << " (geolocation is not supported in popups)";
NotifyPermissionSet(render_process_id, render_view_id, bridge_id,
requesting_frame, false);
return;
@@ -464,14 +512,19 @@ void GeolocationPermissionContext::RequestGeolocationPermission(
}
void GeolocationPermissionContext::CancelGeolocationPermissionRequest(
- int render_process_id, int render_view_id, int bridge_id,
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
const GURL& requesting_frame) {
CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id);
}
void GeolocationPermissionContext::NotifyPermissionSet(
- int render_process_id, int render_view_id, int bridge_id,
- const GURL& requesting_frame, bool allowed) {
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ bool allowed) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
TabContents* tab_contents =
@@ -485,17 +538,13 @@ void GeolocationPermissionContext::NotifyPermissionSet(
allowed);
}
- CallRenderViewHost(
- render_process_id, render_view_id,
- &RenderViewHost::Send,
+ CallRenderViewHost(render_process_id, render_view_id, &RenderViewHost::Send,
new ViewMsg_Geolocation_PermissionSet(render_view_id, bridge_id,
- allowed));
+ allowed));
if (allowed) {
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &GeolocationPermissionContext::NotifyArbitratorPermissionGranted,
- requesting_frame));
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod(
+ this, &GeolocationPermissionContext::NotifyArbitratorPermissionGranted,
+ requesting_frame));
}
}
@@ -506,16 +555,16 @@ void GeolocationPermissionContext::NotifyArbitratorPermissionGranted(
}
void GeolocationPermissionContext::CancelPendingInfoBarRequest(
- int render_process_id, int render_view_id, int bridge_id) {
+ int render_process_id,
+ int render_view_id,
+ int bridge_id) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &GeolocationPermissionContext::CancelPendingInfoBarRequest,
- render_process_id, render_view_id, bridge_id));
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod(
+ this, &GeolocationPermissionContext::CancelPendingInfoBarRequest,
+ render_process_id, render_view_id, bridge_id));
return;
}
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- geolocation_infobar_queue_controller_->CancelInfoBarRequest(
- render_process_id, render_view_id, bridge_id);
+ geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id,
+ render_view_id, bridge_id);
}
diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
index c6e748b..f0346f4 100644
--- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -168,12 +168,10 @@ TEST_F(GeolocationPermissionContextTests, SinglePermission) {
TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
GURL requesting_frame_0("http://www.example.com/geolocation");
GURL requesting_frame_1("http://www.example-2.com/geolocation");
- EXPECT_EQ(
- CONTENT_SETTING_ASK,
+ EXPECT_EQ(CONTENT_SETTING_ASK,
profile()->GetGeolocationContentSettingsMap()->GetContentSetting(
requesting_frame_0, requesting_frame_0));
- EXPECT_EQ(
- CONTENT_SETTING_ASK,
+ EXPECT_EQ(CONTENT_SETTING_ASK,
profile()->GetGeolocationContentSettingsMap()->GetContentSetting(
requesting_frame_1, requesting_frame_0));
@@ -219,12 +217,10 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
infobar_1->InfoBarClosed();
EXPECT_EQ(0, contents()->infobar_delegate_count());
// Ensure the persisted permissions are ok.
- EXPECT_EQ(
- CONTENT_SETTING_ALLOW,
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
profile()->GetGeolocationContentSettingsMap()->GetContentSetting(
requesting_frame_0, requesting_frame_0));
- EXPECT_EQ(
- CONTENT_SETTING_BLOCK,
+ EXPECT_EQ(CONTENT_SETTING_BLOCK,
profile()->GetGeolocationContentSettingsMap()->GetContentSetting(
requesting_frame_1, requesting_frame_0));
}
@@ -232,12 +228,10 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) {
TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) {
GURL requesting_frame_0("http://www.example.com/geolocation");
GURL requesting_frame_1("http://www.example-2.com/geolocation");
- EXPECT_EQ(
- CONTENT_SETTING_ASK,
+ EXPECT_EQ(CONTENT_SETTING_ASK,
profile()->GetGeolocationContentSettingsMap()->GetContentSetting(
requesting_frame_0, requesting_frame_0));
- EXPECT_EQ(
- CONTENT_SETTING_ASK,
+ EXPECT_EQ(CONTENT_SETTING_ASK,
profile()->GetGeolocationContentSettingsMap()->GetContentSetting(
requesting_frame_1, requesting_frame_0));
@@ -280,12 +274,10 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) {
infobar_1->InfoBarClosed();
EXPECT_EQ(0, contents()->infobar_delegate_count());
// Ensure the persisted permissions are ok.
- EXPECT_EQ(
- CONTENT_SETTING_ASK,
+ EXPECT_EQ(CONTENT_SETTING_ASK,
profile()->GetGeolocationContentSettingsMap()->GetContentSetting(
requesting_frame_0, requesting_frame_0));
- EXPECT_EQ(
- CONTENT_SETTING_ALLOW,
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
profile()->GetGeolocationContentSettingsMap()->GetContentSetting(
requesting_frame_1, requesting_frame_0));
}
diff --git a/chrome/browser/google/google_url_tracker_unittest.cc b/chrome/browser/google/google_url_tracker_unittest.cc
index 14e9b95..f1c660b 100644
--- a/chrome/browser/google/google_url_tracker_unittest.cc
+++ b/chrome/browser/google/google_url_tracker_unittest.cc
@@ -60,15 +60,16 @@ class TestInfoBarDelegate : public InfoBarDelegate {
public:
TestInfoBarDelegate(GoogleURLTracker* google_url_tracker,
const GURL& new_google_url);
- virtual ~TestInfoBarDelegate();
-
- // InfoBarDelegate
- virtual InfoBar* CreateInfoBar();
GoogleURLTracker* google_url_tracker() const { return google_url_tracker_; }
GURL new_google_url() const { return new_google_url_; }
private:
+ virtual ~TestInfoBarDelegate();
+
+ // InfoBarDelegate:
+ virtual InfoBar* CreateInfoBar();
+
GoogleURLTracker* google_url_tracker_;
GURL new_google_url_;
};
@@ -299,7 +300,7 @@ void GoogleURLTrackerTest::InfoBarClosed() {
ASSERT_TRUE(infobar);
ASSERT_TRUE(infobar->google_url_tracker());
infobar->google_url_tracker()->InfoBarClosed();
- delete infobar;
+ delete g_browser_process->google_url_tracker()->infobar_;
}
void GoogleURLTrackerTest::ExpectDefaultURLs() {
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index 0364e9c..db96e39 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -50,7 +50,7 @@ void BalloonHost::Shutdown() {
}
}
-Browser* BalloonHost::GetBrowser() const {
+Browser* BalloonHost::GetBrowser() {
// Notifications aren't associated with a particular browser.
return NULL;
}
diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h
index 98da5ba..8ab8206 100644
--- a/chrome/browser/notifications/balloon_host.h
+++ b/chrome/browser/notifications/balloon_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -35,7 +35,7 @@ class BalloonHost : public RenderViewHostDelegate,
void Shutdown();
// ExtensionFunctionDispatcher::Delegate overrides.
- virtual Browser* GetBrowser() const;
+ virtual Browser* GetBrowser();
virtual gfx::NativeView GetNativeViewOfHost();
virtual TabContents* associated_tab_contents() const;
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index c1366c5..0bdb0a8 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -43,6 +43,167 @@ using WebKit::WebTextDirection;
const ContentSetting kDefaultSetting = CONTENT_SETTING_ASK;
+// NotificationPermissionCallbackTask -----------------------------------------
+
+// A task object which calls the renderer to inform the web page that the
+// permission request has completed.
+class NotificationPermissionCallbackTask : public Task {
+ public:
+ NotificationPermissionCallbackTask(int process_id,
+ int route_id,
+ int request_id);
+ virtual ~NotificationPermissionCallbackTask();
+
+ private:
+ virtual void Run();
+
+ int process_id_;
+ int route_id_;
+ int request_id_;
+};
+
+NotificationPermissionCallbackTask::NotificationPermissionCallbackTask(
+ int process_id,
+ int route_id,
+ int request_id)
+ : process_id_(process_id),
+ route_id_(route_id),
+ request_id_(request_id) {
+}
+
+NotificationPermissionCallbackTask::~NotificationPermissionCallbackTask() {
+}
+
+void NotificationPermissionCallbackTask::Run() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
+ if (host)
+ host->Send(new ViewMsg_PermissionRequestDone(route_id_, request_id_));
+}
+
+
+// NotificationPermissionInfoBarDelegate --------------------------------------
+
+// The delegate for the infobar shown when an origin requests notification
+// permissions.
+class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate {
+ public:
+ NotificationPermissionInfoBarDelegate(TabContents* contents,
+ const GURL& origin,
+ const string16& display_name,
+ int process_id,
+ int route_id,
+ int callback_context);
+
+ private:
+ virtual ~NotificationPermissionInfoBarDelegate();
+
+ // ConfirmInfoBarDelegate:
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual Type GetInfoBarType() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
+ virtual bool Cancel();
+
+ // The origin we are asking for permissions on.
+ GURL origin_;
+
+ // The display name for the origin to be displayed. Will be different from
+ // origin_ for extensions.
+ string16 display_name_;
+
+ // The Profile that we restore sessions from.
+ Profile* profile_;
+
+ // The callback information that tells us how to respond to javascript via
+ // the correct RenderView.
+ int process_id_;
+ int route_id_;
+ int callback_context_;
+
+ // Whether the user clicked one of the buttons.
+ bool action_taken_;
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationPermissionInfoBarDelegate);
+};
+
+NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate(
+ TabContents* contents,
+ const GURL& origin,
+ const string16& display_name,
+ int process_id,
+ int route_id,
+ int callback_context)
+ : ConfirmInfoBarDelegate(contents),
+ origin_(origin),
+ display_name_(display_name),
+ profile_(contents->profile()),
+ process_id_(process_id),
+ route_id_(route_id),
+ callback_context_(callback_context),
+ action_taken_(false) {
+}
+
+NotificationPermissionInfoBarDelegate::
+ ~NotificationPermissionInfoBarDelegate() {
+}
+
+void NotificationPermissionInfoBarDelegate::InfoBarClosed() {
+ if (!action_taken_)
+ UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Ignored", 1);
+
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ new NotificationPermissionCallbackTask(process_id_, route_id_,
+ callback_context_));
+
+ delete this;
+}
+
+SkBitmap* NotificationPermissionInfoBarDelegate::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_PRODUCT_ICON_32);
+}
+
+InfoBarDelegate::Type
+ NotificationPermissionInfoBarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+}
+
+string16 NotificationPermissionInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(IDS_NOTIFICATION_PERMISSIONS,
+ display_name_);
+}
+
+int NotificationPermissionInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
+
+string16 NotificationPermissionInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
+ IDS_NOTIFICATION_PERMISSION_YES : IDS_NOTIFICATION_PERMISSION_NO);
+}
+
+bool NotificationPermissionInfoBarDelegate::Accept() {
+ UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1);
+ profile_->GetDesktopNotificationService()->GrantPermission(origin_);
+ action_taken_ = true;
+ return true;
+}
+
+bool NotificationPermissionInfoBarDelegate::Cancel() {
+ UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1);
+ profile_->GetDesktopNotificationService()->DenyPermission(origin_);
+ action_taken_ = true;
+ return true;
+}
+
+
+// DesktopNotificationService -------------------------------------------------
+
// static
string16 DesktopNotificationService::CreateDataUrl(
const GURL& icon_url, const string16& title, const string16& body,
@@ -94,123 +255,6 @@ string16 DesktopNotificationService::CreateDataUrl(
EscapeQueryParamValue(data, false));
}
-// A task object which calls the renderer to inform the web page that the
-// permission request has completed.
-class NotificationPermissionCallbackTask : public Task {
- public:
- NotificationPermissionCallbackTask(int process_id, int route_id,
- int request_id)
- : process_id_(process_id),
- route_id_(route_id),
- request_id_(request_id) {
- }
-
- virtual void Run() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
- if (host)
- host->Send(new ViewMsg_PermissionRequestDone(route_id_, request_id_));
- }
-
- private:
- int process_id_;
- int route_id_;
- int request_id_;
-};
-
-// The delegate for the infobar shown when an origin requests notification
-// permissions.
-class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate {
- public:
- NotificationPermissionInfoBarDelegate(TabContents* contents,
- const GURL& origin,
- const string16& display_name,
- int process_id,
- int route_id,
- int callback_context)
- : ConfirmInfoBarDelegate(contents),
- origin_(origin),
- display_name_(display_name),
- profile_(contents->profile()),
- process_id_(process_id),
- route_id_(route_id),
- callback_context_(callback_context),
- action_taken_(false) {
- }
-
- // Overridden from ConfirmInfoBarDelegate:
- virtual void InfoBarClosed() {
- if (!action_taken_)
- UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Ignored", 1);
-
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- new NotificationPermissionCallbackTask(
- process_id_, route_id_, callback_context_));
-
- delete this;
- }
-
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringFUTF16(IDS_NOTIFICATION_PERMISSIONS,
- display_name_);
- }
-
- virtual SkBitmap* GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_PRODUCT_ICON_32);
- }
-
- virtual int GetButtons() const {
- return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT;
- }
-
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- return button == BUTTON_OK ?
- l10n_util::GetStringUTF16(IDS_NOTIFICATION_PERMISSION_YES) :
- l10n_util::GetStringUTF16(IDS_NOTIFICATION_PERMISSION_NO);
- }
-
- virtual bool Accept() {
- UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Allowed", 1);
- profile_->GetDesktopNotificationService()->GrantPermission(origin_);
- action_taken_ = true;
- return true;
- }
-
- virtual bool Cancel() {
- UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Denied", 1);
- profile_->GetDesktopNotificationService()->DenyPermission(origin_);
- action_taken_ = true;
- return true;
- }
-
- // Overridden from InfoBarDelegate:
- virtual Type GetInfoBarType() { return PAGE_ACTION_TYPE; }
-
- private:
- // The origin we are asking for permissions on.
- GURL origin_;
-
- // The display name for the origin to be displayed. Will be different from
- // origin_ for extensions.
- string16 display_name_;
-
- // The Profile that we restore sessions from.
- Profile* profile_;
-
- // The callback information that tells us how to respond to javascript via
- // the correct RenderView.
- int process_id_;
- int route_id_;
- int callback_context_;
-
- // Whether the user clicked one of the buttons.
- bool action_taken_;
-
- DISALLOW_COPY_AND_ASSIGN(NotificationPermissionInfoBarDelegate);
-};
-
DesktopNotificationService::DesktopNotificationService(Profile* profile,
NotificationUIManager* ui_manager)
: profile_(profile),
diff --git a/chrome/browser/omnibox_search_hint.cc b/chrome/browser/omnibox_search_hint.cc
index ebd32fc..2000155 100644
--- a/chrome/browser/omnibox_search_hint.cc
+++ b/chrome/browser/omnibox_search_hint.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -42,73 +42,30 @@ const char* kSearchEngineURLs[] = {
"http://www.wolframalpha.com/",
};
-class HintInfoBar : public ConfirmInfoBarDelegate {
- public:
- explicit HintInfoBar(OmniboxSearchHint* omnibox_hint)
- : ConfirmInfoBarDelegate(omnibox_hint->tab()),
- omnibox_hint_(omnibox_hint),
- action_taken_(false),
- should_expire_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
- // We want the info-bar to stick-around for few seconds and then be hidden
- // on the next navigation after that.
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- method_factory_.NewRunnableMethod(&HintInfoBar::Expire),
- 8000); // 8 seconds.
- }
-
- virtual bool ShouldExpire(
- const NavigationController::LoadCommittedDetails& details) const {
- return should_expire_;
- }
- // Overridden from ConfirmInfoBarDelegate:
- virtual void InfoBarClosed() {
- if (!action_taken_)
- UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Ignored", 1);
- delete this;
- }
-
- virtual void InfoBarDismissed() {
- action_taken_ = true;
- UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Closed", 1);
- // User closed the infobar, let's not bug him again with this in the future.
- omnibox_hint_->DisableHint();
- }
+// HintInfoBar ----------------------------------------------------------------
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringUTF16(IDS_OMNIBOX_SEARCH_HINT_INFOBAR_TEXT);
- }
-
- virtual SkBitmap* GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_INFOBAR_QUESTION_MARK);
- }
-
- virtual int GetButtons() const {
- return BUTTON_OK;
- }
-
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- return l10n_util::GetStringUTF16(
- IDS_OMNIBOX_SEARCH_HINT_INFOBAR_BUTTON_LABEL);
- }
+class HintInfoBar : public ConfirmInfoBarDelegate {
+ public:
+ explicit HintInfoBar(OmniboxSearchHint* omnibox_hint);
- virtual Type GetInfoBarType() { return PAGE_ACTION_TYPE; }
+ private:
+ virtual ~HintInfoBar();
- virtual bool Accept() {
- action_taken_ = true;
- UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.ShowMe", 1);
- omnibox_hint_->DisableHint();
- omnibox_hint_->ShowEnteringQuery();
- return true;
- }
+ void AllowExpiry() { should_expire_ = true; }
- void Expire() {
- should_expire_ = true;
- }
+ // ConfirmInfoBarDelegate:
+ virtual bool ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const;
+ virtual void InfoBarDismissed();
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual Type GetInfoBarType() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
- private:
// The omnibox hint that shows us.
OmniboxSearchHint* omnibox_hint_;
@@ -124,6 +81,72 @@ class HintInfoBar : public ConfirmInfoBarDelegate {
DISALLOW_COPY_AND_ASSIGN(HintInfoBar);
};
+HintInfoBar::HintInfoBar(OmniboxSearchHint* omnibox_hint)
+ : ConfirmInfoBarDelegate(omnibox_hint->tab()),
+ omnibox_hint_(omnibox_hint),
+ action_taken_(false),
+ should_expire_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ // We want the info-bar to stick-around for few seconds and then be hidden
+ // on the next navigation after that.
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ method_factory_.NewRunnableMethod(&HintInfoBar::AllowExpiry),
+ 8000); // 8 seconds.
+}
+HintInfoBar::~HintInfoBar() {
+}
+
+bool HintInfoBar::ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const {
+ return should_expire_;
+}
+
+void HintInfoBar::InfoBarDismissed() {
+ action_taken_ = true;
+ UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Closed", 1);
+ // User closed the infobar, let's not bug him again with this in the future.
+ omnibox_hint_->DisableHint();
+}
+
+void HintInfoBar::InfoBarClosed() {
+ if (!action_taken_)
+ UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.Ignored", 1);
+ delete this;
+}
+
+SkBitmap* HintInfoBar::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_QUESTION_MARK);
+}
+
+InfoBarDelegate::Type HintInfoBar::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+}
+
+string16 HintInfoBar::GetMessageText() const {
+ return l10n_util::GetStringUTF16(IDS_OMNIBOX_SEARCH_HINT_INFOBAR_TEXT);
+}
+
+int HintInfoBar::GetButtons() const {
+ return BUTTON_OK;
+}
+
+string16 HintInfoBar::GetButtonLabel(InfoBarButton button) const {
+ return l10n_util::GetStringUTF16(
+ IDS_OMNIBOX_SEARCH_HINT_INFOBAR_BUTTON_LABEL);
+}
+
+bool HintInfoBar::Accept() {
+ action_taken_ = true;
+ UMA_HISTOGRAM_COUNTS("OmniboxSearchHint.ShowMe", 1);
+ omnibox_hint_->DisableHint();
+ omnibox_hint_->ShowEnteringQuery();
+ return true;
+}
+
+
+// OmniboxSearchHint ----------------------------------------------------------
+
OmniboxSearchHint::OmniboxSearchHint(TabContents* tab) : tab_(tab) {
NavigationController* controller = &(tab->controller());
notification_registrar_.Add(this,
diff --git a/chrome/browser/password_manager_delegate_impl.cc b/chrome/browser/password_manager_delegate_impl.cc
index 1660709..39de4c5 100644
--- a/chrome/browser/password_manager_delegate_impl.cc
+++ b/chrome/browser/password_manager_delegate_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -27,77 +27,94 @@
class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
SavePasswordInfoBarDelegate(TabContents* tab_contents,
- PasswordFormManager* form_to_save)
- : ConfirmInfoBarDelegate(tab_contents),
- form_to_save_(form_to_save),
- infobar_response_(NO_RESPONSE) {}
-
- virtual ~SavePasswordInfoBarDelegate() {}
-
- // Begin ConfirmInfoBarDelegate implementation.
- virtual void InfoBarClosed() {
- UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse",
- infobar_response_, NUM_RESPONSE_TYPES);
- delete this;
- }
-
- virtual Type GetInfoBarType() { return PAGE_ACTION_TYPE; }
-
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT);
- }
-
- virtual SkBitmap* GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_INFOBAR_SAVE_PASSWORD);
- }
-
- virtual int GetButtons() const {
- return BUTTON_OK | BUTTON_CANCEL;
- }
-
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- if (button == BUTTON_OK)
- return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON);
- if (button == BUTTON_CANCEL)
- return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON);
- NOTREACHED();
- return string16();
- }
-
- virtual bool Accept() {
- DCHECK(form_to_save_.get());
- form_to_save_->Save();
- infobar_response_ = REMEMBER_PASSWORD;
- return true;
- }
-
- virtual bool Cancel() {
- DCHECK(form_to_save_.get());
- form_to_save_->PermanentlyBlacklist();
- infobar_response_ = DONT_REMEMBER_PASSWORD;
- return true;
- }
- // End ConfirmInfoBarDelegate implementation.
+ PasswordFormManager* form_to_save);
private:
- // The PasswordFormManager managing the form we're asking the user about,
- // and should update as per her decision.
- scoped_ptr<PasswordFormManager> form_to_save_;
-
- // Used to track the results we get from the info bar.
enum ResponseType {
NO_RESPONSE = 0,
REMEMBER_PASSWORD,
DONT_REMEMBER_PASSWORD,
NUM_RESPONSE_TYPES,
};
+
+ virtual ~SavePasswordInfoBarDelegate();
+
+ // ConfirmInfoBarDelegate
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual Type GetInfoBarType() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
+ virtual bool Cancel();
+
+ // The PasswordFormManager managing the form we're asking the user about,
+ // and should update as per her decision.
+ scoped_ptr<PasswordFormManager> form_to_save_;
+
+ // Used to track the results we get from the info bar.
ResponseType infobar_response_;
DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate);
};
-//----------------------------------------------------------------------------
+SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate(
+ TabContents* tab_contents,
+ PasswordFormManager* form_to_save)
+ : ConfirmInfoBarDelegate(tab_contents),
+ form_to_save_(form_to_save),
+ infobar_response_(NO_RESPONSE) {
+}
+
+SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() {
+}
+
+void SavePasswordInfoBarDelegate::InfoBarClosed() {
+ UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse",
+ infobar_response_, NUM_RESPONSE_TYPES);
+ delete this;
+}
+
+SkBitmap* SavePasswordInfoBarDelegate::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_SAVE_PASSWORD);
+}
+
+InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+}
+
+string16 SavePasswordInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT);
+}
+
+int SavePasswordInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
+
+string16 SavePasswordInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
+ IDS_PASSWORD_MANAGER_SAVE_BUTTON : IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON);
+}
+
+bool SavePasswordInfoBarDelegate::Accept() {
+ DCHECK(form_to_save_.get());
+ form_to_save_->Save();
+ infobar_response_ = REMEMBER_PASSWORD;
+ return true;
+}
+
+bool SavePasswordInfoBarDelegate::Cancel() {
+ DCHECK(form_to_save_.get());
+ form_to_save_->PermanentlyBlacklist();
+ infobar_response_ = DONT_REMEMBER_PASSWORD;
+ return true;
+}
+
+
+// PasswordManagerDelegateImpl ------------------------------------------------
void PasswordManagerDelegateImpl::FillPasswordForm(
const webkit_glue::PasswordFormFillData& form_data) {
diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer_infobar_delegate.cc
index 1ba83b9..867ae2d 100644
--- a/chrome/browser/plugin_installer.cc
+++ b/chrome/browser/plugin_installer_infobar_delegate.cc
@@ -1,34 +1,30 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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/plugin_installer.h"
+#include "chrome/browser/plugin_installer_infobar_delegate.h"
#include "app/l10n_util.h"
-#include "base/string_util.h"
+#include "app/resource_bundle.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
-#include "ui/base/resource/resource_bundle.h"
#include "webkit/plugins/npapi/default_plugin_shared.h"
-// The URL for the "Problems installing" page for the Plugins infobar.
-static const char kLearnMorePluginInstallerUrl[] =
- "http://www.google.com/support/chrome/bin/answer.py?answer=95697&amp;topic=14687";
-
-PluginInstaller::PluginInstaller(TabContents* tab_contents)
+PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate(
+ TabContents* tab_contents)
: ConfirmInfoBarDelegate(tab_contents),
tab_contents_(tab_contents) {
}
-PluginInstaller::~PluginInstaller() {
+PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() {
// Remove any InfoBars we may be showing.
tab_contents_->RemoveInfoBar(this);
}
-void PluginInstaller::OnMissingPluginStatus(int status) {
+void PluginInstallerInfoBarDelegate::OnMissingPluginStatus(int status) {
switch (status) {
case webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE: {
tab_contents_->AddInfoBar(this);
@@ -47,37 +43,40 @@ void PluginInstaller::OnMissingPluginStatus(int status) {
}
}
-string16 PluginInstaller::GetMessageText() const {
- return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT);
-}
-
-SkBitmap* PluginInstaller::GetIcon() const {
+SkBitmap* PluginInstallerInfoBarDelegate::GetIcon() const {
return ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_INFOBAR_PLUGIN_INSTALL);
}
-int PluginInstaller::GetButtons() const {
+string16 PluginInstallerInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT);
+}
+
+int PluginInstallerInfoBarDelegate::GetButtons() const {
return BUTTON_OK;
}
-string16 PluginInstaller::GetButtonLabel(InfoBarButton button) const {
- if (button == BUTTON_OK)
- return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON);
- return ConfirmInfoBarDelegate::GetButtonLabel(button);
+string16 PluginInstallerInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ DCHECK_EQ(BUTTON_OK, button);
+ return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON);
}
-bool PluginInstaller::Accept() {
+bool PluginInstallerInfoBarDelegate::Accept() {
tab_contents_->render_view_host()->InstallMissingPlugin();
return true;
}
-string16 PluginInstaller::GetLinkText() {
+string16 PluginInstallerInfoBarDelegate::GetLinkText() {
return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_PROBLEMSINSTALLING);
}
-bool PluginInstaller::LinkClicked(WindowOpenDisposition disposition) {
+bool PluginInstallerInfoBarDelegate::LinkClicked(
+ WindowOpenDisposition disposition) {
// Ignore the click dispostion and always open in a new top level tab.
+ static const char kLearnMorePluginInstallerUrl[] = "http://www.google.com/"
+ "support/chrome/bin/answer.py?answer=95697&amp;topic=14687";
tab_contents_->OpenURL(GURL(kLearnMorePluginInstallerUrl), GURL(),
NEW_FOREGROUND_TAB, PageTransition::LINK);
- return false; // Do not dismiss the info bar.
+ return false;
}
diff --git a/chrome/browser/plugin_installer.h b/chrome/browser/plugin_installer_infobar_delegate.h
index b56034d..a7771c3 100644
--- a/chrome/browser/plugin_installer.h
+++ b/chrome/browser/plugin_installer_infobar_delegate.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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_PLUGIN_INSTALLER_H_
-#define CHROME_BROWSER_PLUGIN_INSTALLER_H_
+#ifndef CHROME_BROWSER_PLUGIN_INSTALLER_INFOBAR_DELEGATE_H_
+#define CHROME_BROWSER_PLUGIN_INSTALLER_INFOBAR_DELEGATE_H_
#pragma once
#include "chrome/browser/tab_contents/infobar_delegate.h"
@@ -12,19 +12,17 @@ class TabContents;
// The main purpose for this class is to popup/close the infobar when there is
// a missing plugin.
-class PluginInstaller : public ConfirmInfoBarDelegate {
+class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- explicit PluginInstaller(TabContents* tab_contents);
- ~PluginInstaller();
+ explicit PluginInstallerInfoBarDelegate(TabContents* tab_contents);
+ virtual ~PluginInstallerInfoBarDelegate();
void OnMissingPluginStatus(int status);
- // A new page starts loading. This is the perfect time to close the info bar.
- void OnStartLoading();
private:
- // Overridden from ConfirmInfoBarDelegate:
- virtual string16 GetMessageText() const;
+ // ConfirmInfoBarDelegate:
virtual SkBitmap* GetIcon() const;
+ virtual string16 GetMessageText() const;
virtual int GetButtons() const;
virtual string16 GetButtonLabel(InfoBarButton button) const;
virtual bool Accept();
@@ -34,7 +32,7 @@ class PluginInstaller : public ConfirmInfoBarDelegate {
// The containing TabContents
TabContents* tab_contents_;
- DISALLOW_COPY_AND_ASSIGN(PluginInstaller);
+ DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate);
};
-#endif // CHROME_BROWSER_PLUGIN_INSTALLER_H_
+#endif // CHROME_BROWSER_PLUGIN_INSTALLER_INFOBAR_DELEGATE_H_
diff --git a/chrome/browser/printing/print_dialog_gtk.cc b/chrome/browser/printing/print_dialog_gtk.cc
index 2421e91..b51056a 100644
--- a/chrome/browser/printing/print_dialog_gtk.cc
+++ b/chrome/browser/printing/print_dialog_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -53,7 +53,7 @@ class PdfUnsupportedInfoBarDelegate : public LinkInfoBarDelegate {
return UTF8ToUTF16("here");
}
- virtual Type GetInfoBarType() { return WARNING_TYPE; }
+ virtual Type GetInfoBarType() const { return WARNING_TYPE; }
virtual bool LinkClicked(WindowOpenDisposition disposition) {
browser_->OpenURL(
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 69579d5..4b8619e 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -381,7 +381,7 @@ class RenderViewHost : public RenderWidgetHost {
void UpdateWebPreferences(const WebPreferences& prefs);
// Request the Renderer to ask the default plugin to start installation of
- // missing plugin. Called by PluginInstaller.
+ // missing plugin. Called by PluginInstallerInfoBarDelegate.
void InstallMissingPlugin();
// Load all blocked plugins in the RenderView.
diff --git a/chrome/browser/speech/speech_input_manager.cc b/chrome/browser/speech/speech_input_manager.cc
index 4cdc608..6634b42 100644
--- a/chrome/browser/speech/speech_input_manager.cc
+++ b/chrome/browser/speech/speech_input_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -20,7 +20,6 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/speech/speech_input_bubble_controller.h"
#include "chrome/browser/speech/speech_recognizer.h"
-#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
diff --git a/chrome/browser/tab_contents/infobar_delegate.cc b/chrome/browser/tab_contents/infobar_delegate.cc
index 671d17b..5ef969a 100644
--- a/chrome/browser/tab_contents/infobar_delegate.cc
+++ b/chrome/browser/tab_contents/infobar_delegate.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -12,7 +12,10 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"
-// InfoBarDelegate: ------------------------------------------------------------
+// InfoBarDelegate ------------------------------------------------------------
+
+InfoBarDelegate::~InfoBarDelegate() {
+}
bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
return false;
@@ -20,21 +23,26 @@ bool InfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
bool InfoBarDelegate::ShouldExpire(
const NavigationController::LoadCommittedDetails& details) const {
- bool is_reload =
- PageTransition::StripQualifier(details.entry->transition_type()) ==
- PageTransition::RELOAD;
- return is_reload || (contents_unique_id_ != details.entry->unique_id());
+ return (contents_unique_id_ != details.entry->unique_id()) ||
+ (PageTransition::StripQualifier(details.entry->transition_type()) ==
+ PageTransition::RELOAD);
+}
+
+void InfoBarDelegate::InfoBarDismissed() {
+}
+
+void InfoBarDelegate::InfoBarClosed() {
}
SkBitmap* InfoBarDelegate::GetIcon() const {
return NULL;
}
-AlertInfoBarDelegate* InfoBarDelegate::AsAlertInfoBarDelegate() {
- return NULL;
+InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const {
+ return WARNING_TYPE;
}
-LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() {
+AlertInfoBarDelegate* InfoBarDelegate::AsAlertInfoBarDelegate() {
return NULL;
}
@@ -42,26 +50,26 @@ ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() {
return NULL;
}
-ThemeInstalledInfoBarDelegate*
-InfoBarDelegate::AsThemePreviewInfobarDelegate() {
+CrashedExtensionInfoBarDelegate*
+InfoBarDelegate::AsCrashedExtensionInfoBarDelegate() {
return NULL;
}
-TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
+ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() {
return NULL;
}
-ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() {
+LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() {
return NULL;
}
-CrashedExtensionInfoBarDelegate*
-InfoBarDelegate::AsCrashedExtensionInfoBarDelegate() {
+ThemeInstalledInfoBarDelegate*
+ InfoBarDelegate::AsThemePreviewInfobarDelegate() {
return NULL;
}
-InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() {
- return WARNING_TYPE;
+TranslateInfoBarDelegate* InfoBarDelegate::AsTranslateInfoBarDelegate() {
+ return NULL;
}
InfoBarDelegate::InfoBarDelegate(TabContents* contents)
@@ -75,29 +83,28 @@ void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) {
contents_unique_id_ = active_entry ? active_entry->unique_id() : 0;
}
-// AlertInfoBarDelegate: -------------------------------------------------------
-SkBitmap* AlertInfoBarDelegate::GetIcon() const {
- return NULL;
-}
+// AlertInfoBarDelegate -------------------------------------------------------
bool AlertInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
AlertInfoBarDelegate* alert_delegate = delegate->AsAlertInfoBarDelegate();
- if (!alert_delegate)
- return false;
+ return alert_delegate &&
+ (alert_delegate->GetMessageText() == GetMessageText());
+}
- return alert_delegate->GetMessageText() == GetMessageText();
+AlertInfoBarDelegate::AlertInfoBarDelegate(TabContents* contents)
+ : InfoBarDelegate(contents) {
+}
+
+AlertInfoBarDelegate::~AlertInfoBarDelegate() {
}
AlertInfoBarDelegate* AlertInfoBarDelegate::AsAlertInfoBarDelegate() {
return this;
}
-AlertInfoBarDelegate::AlertInfoBarDelegate(TabContents* contents)
- : InfoBarDelegate(contents) {
-}
-// LinkInfoBarDelegate: --------------------------------------------------------
+// LinkInfoBarDelegate --------------------------------------------------------
string16 LinkInfoBarDelegate::GetMessageTextWithOffset(
size_t* link_offset) const {
@@ -105,36 +112,30 @@ string16 LinkInfoBarDelegate::GetMessageTextWithOffset(
return string16();
}
-SkBitmap* LinkInfoBarDelegate::GetIcon() const {
- return NULL;
-}
-
bool LinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
return true;
}
+LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents)
+ : InfoBarDelegate(contents) {
+}
+
+LinkInfoBarDelegate::~LinkInfoBarDelegate() {
+}
+
LinkInfoBarDelegate* LinkInfoBarDelegate::AsLinkInfoBarDelegate() {
return this;
}
-LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents)
- : InfoBarDelegate(contents) {
-}
-// ConfirmInfoBarDelegate: -----------------------------------------------------
+// ConfirmInfoBarDelegate -----------------------------------------------------
int ConfirmInfoBarDelegate::GetButtons() const {
return BUTTON_NONE;
}
-string16 ConfirmInfoBarDelegate::GetButtonLabel(
- InfoBarButton button) const {
- if (button == BUTTON_OK)
- return l10n_util::GetStringUTF16(IDS_OK);
- if (button == BUTTON_CANCEL)
- return l10n_util::GetStringUTF16(IDS_CANCEL);
- NOTREACHED();
- return string16();
+string16 ConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL);
}
bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const {
@@ -157,43 +158,47 @@ bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
return true;
}
+ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents)
+ : AlertInfoBarDelegate(contents) {
+}
+
+ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() {
+}
+
ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() {
return this;
}
-ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents)
- : AlertInfoBarDelegate(contents) {
-}
-// SimpleAlertInfoBarDelegate: -------------------------------------------------
+// SimpleAlertInfoBarDelegate -------------------------------------------------
SimpleAlertInfoBarDelegate::SimpleAlertInfoBarDelegate(
TabContents* contents,
- const string16& message,
SkBitmap* icon,
+ const string16& message,
bool auto_expire)
: AlertInfoBarDelegate(contents),
- message_(message),
icon_(icon),
+ message_(message),
auto_expire_(auto_expire) {
}
+SimpleAlertInfoBarDelegate::~SimpleAlertInfoBarDelegate() {
+}
+
bool SimpleAlertInfoBarDelegate::ShouldExpire(
const NavigationController::LoadCommittedDetails& details) const {
- if (auto_expire_)
- return AlertInfoBarDelegate::ShouldExpire(details);
-
- return false;
+ return auto_expire_ && AlertInfoBarDelegate::ShouldExpire(details);
}
-string16 SimpleAlertInfoBarDelegate::GetMessageText() const {
- return message_;
+void SimpleAlertInfoBarDelegate::InfoBarClosed() {
+ delete this;
}
SkBitmap* SimpleAlertInfoBarDelegate::GetIcon() const {
return icon_;
}
-void SimpleAlertInfoBarDelegate::InfoBarClosed() {
- delete this;
+string16 SimpleAlertInfoBarDelegate::GetMessageText() const {
+ return message_;
}
diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/tab_contents/infobar_delegate.h
index c48d82b..ca7b497 100644
--- a/chrome/browser/tab_contents/infobar_delegate.h
+++ b/chrome/browser/tab_contents/infobar_delegate.h
@@ -15,11 +15,11 @@ class AlertInfoBarDelegate;
class ConfirmInfoBarDelegate;
class CrashedExtensionInfoBarDelegate;
class ExtensionInfoBarDelegate;
-class TranslateInfoBarDelegate;
class InfoBar;
class LinkInfoBarDelegate;
class SkBitmap;
class ThemeInstalledInfoBarDelegate;
+class TranslateInfoBarDelegate;
// An interface implemented by objects wishing to control an InfoBar.
// Implementing this interface is not sufficient to use an InfoBar, since it
@@ -52,6 +52,12 @@ class InfoBarDelegate {
PAGE_ACTION_TYPE,
};
+ virtual ~InfoBarDelegate();
+
+ // Called to create the InfoBar. Implementation of this method is
+ // platform-specific.
+ virtual InfoBar* CreateInfoBar() = 0;
+
// Returns true if the supplied |delegate| is equal to this one. Equality is
// left to the implementation to define. This function is called by the
// TabContents when determining whether or not a delegate should be added
@@ -67,64 +73,42 @@ class InfoBarDelegate {
const NavigationController::LoadCommittedDetails& details) const;
// Called when the user clicks on the close button to dismiss the infobar.
- virtual void InfoBarDismissed() {}
+ virtual void InfoBarDismissed();
// Called after the InfoBar is closed. The delegate is free to delete itself
// at this point.
- virtual void InfoBarClosed() {}
-
- // Called to create the InfoBar. Implementation of this method is
- // platform-specific.
- virtual InfoBar* CreateInfoBar() = 0;
+ virtual void InfoBarClosed();
// Return the icon to be shown for this InfoBar. If the returned bitmap is
// NULL, no icon is shown.
virtual SkBitmap* GetIcon() const;
- // Returns a pointer to the AlertInfoBarDelegate interface, if implemented.
- virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate();
-
- // Returns a pointer to the LinkInfoBarDelegate interface, if implemented.
- virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate();
+ // Returns the type of the infobar. The type determines the appearance (such
+ // as background color) of the infobar.
+ virtual Type GetInfoBarType() const;
- // Returns a pointer to the ConfirmInfoBarDelegate interface, if implemented.
+ // Type-checking downcast routines:
+ virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate();
virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate();
-
- // Returns a pointer to the ThemeInstalledInfoBarDelegate interface, if
- // implemented.
+ virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate();
+ virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate();
+ virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate();
virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate();
-
- // Returns a pointer to the TranslateInfoBarDelegate interface, if
- // implemented.
virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate();
- // Returns a pointer to the ExtensionInfoBarDelegate interface, if
- // implemented.
- virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate();
-
- // Returns a pointer to the CrashedExtensionInfoBarDelegate interface, if
- // implemented.
- virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate();
-
- // Returns the type of the infobar. The type determines the appearance (such
- // as background color) of the infobar.
- virtual Type GetInfoBarType();
-
protected:
// Provided to subclasses as a convenience to initialize the state of this
// object. If |contents| is non-NULL, its active entry's unique ID will be
// stored using StoreActiveEntryUniqueID automatically.
explicit InfoBarDelegate(TabContents* contents);
- virtual ~InfoBarDelegate() { }
-
// Store the unique id for the active entry in the specified TabContents, to
// be used later upon navigation to determine if this InfoBarDelegate should
// be expired from |contents_|.
void StoreActiveEntryUniqueID(TabContents* contents);
private:
- // The unique id of the active NavigationEntry of the TabContents taht we were
+ // The unique id of the active NavigationEntry of the TabContents that we were
// opened for. Used to help expire on navigations.
int contents_unique_id_;
@@ -138,16 +122,16 @@ class AlertInfoBarDelegate : public InfoBarDelegate {
// Returns the message string to be displayed for the InfoBar.
virtual string16 GetMessageText() const = 0;
- // Overridden from InfoBarDelegate.
- virtual SkBitmap* GetIcon() const;
-
- // Overridden from InfoBarDelegate:
- virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
+ // InfoBarDelegate:
virtual InfoBar* CreateInfoBar();
- virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate();
+ virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
protected:
explicit AlertInfoBarDelegate(TabContents* contents);
+ virtual ~AlertInfoBarDelegate();
+
+ private:
+ virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate();
DISALLOW_COPY_AND_ASSIGN(AlertInfoBarDelegate);
};
@@ -165,9 +149,6 @@ class LinkInfoBarDelegate : public InfoBarDelegate {
// Returns the text of the link to be displayed.
virtual string16 GetLinkText() const = 0;
- // Overridden from InfoBarDelegate.
- virtual SkBitmap* GetIcon() const;
-
// Called when the Link is clicked. The |disposition| specifies how the
// resulting document should be loaded (based on the event flags present when
// the link was clicked). This function returns true if the InfoBar should be
@@ -175,12 +156,14 @@ class LinkInfoBarDelegate : public InfoBarDelegate {
// it.
virtual bool LinkClicked(WindowOpenDisposition disposition);
- // Overridden from InfoBarDelegate:
- virtual InfoBar* CreateInfoBar();
- virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate();
-
protected:
explicit LinkInfoBarDelegate(TabContents* contents);
+ virtual ~LinkInfoBarDelegate();
+
+ private:
+ // InfoBarDelegate:
+ virtual InfoBar* CreateInfoBar();
+ virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate();
DISALLOW_COPY_AND_ASSIGN(LinkInfoBarDelegate);
};
@@ -193,8 +176,6 @@ class ConfirmInfoBarDelegate : public AlertInfoBarDelegate {
BUTTON_NONE = 0,
BUTTON_OK = 1 << 0,
BUTTON_CANCEL = 1 << 1,
- // Specifies that the OK button should be rendered like a default button.
- BUTTON_OK_DEFAULT = 1 << 2
};
// Return the buttons to be shown for this InfoBar.
@@ -227,12 +208,14 @@ class ConfirmInfoBarDelegate : public AlertInfoBarDelegate {
// Will only be called if GetLinkText() returns non-empty string.
virtual bool LinkClicked(WindowOpenDisposition disposition);
- // Overridden from InfoBarDelegate:
- virtual InfoBar* CreateInfoBar();
- virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate();
-
protected:
explicit ConfirmInfoBarDelegate(TabContents* contents);
+ virtual ~ConfirmInfoBarDelegate();
+
+ private:
+ // InfoBarDelegate:
+ virtual InfoBar* CreateInfoBar();
+ virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate();
DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate);
};
@@ -241,22 +224,23 @@ class ConfirmInfoBarDelegate : public AlertInfoBarDelegate {
class SimpleAlertInfoBarDelegate : public AlertInfoBarDelegate {
public:
- // |icon| may be |NULL|.
SimpleAlertInfoBarDelegate(TabContents* contents,
+ SkBitmap* icon, // May be NULL.
const string16& message,
- SkBitmap* icon,
bool auto_expire);
- // Overridden from AlertInfoBarDelegate:
+ private:
+ virtual ~SimpleAlertInfoBarDelegate();
+
+ // AlertInfoBarDelegate:
virtual bool ShouldExpire(
const NavigationController::LoadCommittedDetails& details) const;
- virtual string16 GetMessageText() const;
- virtual SkBitmap* GetIcon() const;
virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual string16 GetMessageText() const;
- private:
- string16 message_;
SkBitmap* icon_;
+ string16 message_;
bool auto_expire_; // Should it expire automatically on navigation?
DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate);
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 7eba111..fff691f 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -49,7 +49,7 @@
#include "chrome/browser/modal_html_dialog_delegate.h"
#include "chrome/browser/omnibox_search_hint.h"
#include "chrome/browser/platform_util.h"
-#include "chrome/browser/plugin_installer.h"
+#include "chrome/browser/plugin_installer_infobar_delegate.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
@@ -247,82 +247,101 @@ void MakeNavigateParams(const NavigationEntry& entry,
params->request_time = base::Time::Now();
}
+
+// OutdatedPluginInfoBar ------------------------------------------------------
+
class OutdatedPluginInfoBar : public ConfirmInfoBarDelegate {
public:
OutdatedPluginInfoBar(TabContents* tab_contents,
const string16& name,
- const GURL& update_url)
- : ConfirmInfoBarDelegate(tab_contents),
- tab_contents_(tab_contents),
- name_(name),
- update_url_(update_url) {
- UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown"));
- tab_contents->AddInfoBar(this);
- }
+ const GURL& update_url);
- virtual int GetButtons() const {
- return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT;
- }
+ private:
+ virtual ~OutdatedPluginInfoBar();
+
+ // ConfirmInfoBarDelegate:
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
+ virtual bool Cancel();
+ virtual string16 GetLinkText();
+ virtual bool LinkClicked(WindowOpenDisposition disposition);
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- if (button == BUTTON_CANCEL)
- return l10n_util::GetStringUTF16(IDS_PLUGIN_ENABLE_TEMPORARILY);
- if (button == BUTTON_OK)
- return l10n_util::GetStringUTF16(IDS_PLUGIN_UPDATE);
- return ConfirmInfoBarDelegate::GetButtonLabel(button);
- }
+ TabContents* tab_contents_;
+ string16 name_;
+ GURL update_url_;
+};
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_);
- }
+OutdatedPluginInfoBar::OutdatedPluginInfoBar(TabContents* tab_contents,
+ const string16& name,
+ const GURL& update_url)
+ : ConfirmInfoBarDelegate(tab_contents),
+ tab_contents_(tab_contents),
+ name_(name),
+ update_url_(update_url) {
+ UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown"));
+ tab_contents->AddInfoBar(this);
+}
- virtual string16 GetLinkText() {
- return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
- }
+OutdatedPluginInfoBar::~OutdatedPluginInfoBar() {
+}
- virtual SkBitmap* GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_INFOBAR_PLUGIN_INSTALL);
- }
+void OutdatedPluginInfoBar::InfoBarClosed() {
+ UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed"));
+ delete this;
+}
- virtual bool Accept() {
- UserMetrics::RecordAction(
- UserMetricsAction("OutdatedPluginInfobar.Update"));
- tab_contents_->OpenURL(update_url_, GURL(),
- NEW_FOREGROUND_TAB, PageTransition::LINK);
- return false;
- }
+SkBitmap* OutdatedPluginInfoBar::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_PLUGIN_INSTALL);
+}
- virtual bool Cancel() {
- UserMetrics::RecordAction(
- UserMetricsAction("OutdatedPluginInfobar.AllowThisTime"));
- tab_contents_->render_view_host()->LoadBlockedPlugins();
- return true;
- }
+string16 OutdatedPluginInfoBar::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_);
+}
- virtual bool LinkClicked(WindowOpenDisposition disposition) {
- UserMetrics::RecordAction(
- UserMetricsAction("OutdatedPluginInfobar.LearnMore"));
- // TODO(bauerb): Navigate to a help page explaining why we disabled
- // the plugin, once we have one.
- return false;
- }
+int OutdatedPluginInfoBar::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
- virtual void InfoBarClosed() {
- UserMetrics::RecordAction(
- UserMetricsAction("OutdatedPluginInfobar.Closed"));
- delete this;
- }
+string16 OutdatedPluginInfoBar::GetButtonLabel(InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
+ IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY);
+}
- private:
- TabContents* tab_contents_;
- string16 name_;
- GURL update_url_;
-};
+bool OutdatedPluginInfoBar::Accept() {
+ UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update"));
+ tab_contents_->OpenURL(update_url_, GURL(), NEW_FOREGROUND_TAB,
+ PageTransition::LINK);
+ return false;
+}
+
+bool OutdatedPluginInfoBar::Cancel() {
+ UserMetrics::RecordAction(
+ UserMetricsAction("OutdatedPluginInfobar.AllowThisTime"));
+ tab_contents_->render_view_host()->LoadBlockedPlugins();
+ return false;
+}
+
+string16 OutdatedPluginInfoBar::GetLinkText() {
+ return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
+}
+
+bool OutdatedPluginInfoBar::LinkClicked(WindowOpenDisposition disposition) {
+ UserMetrics::RecordAction(
+ UserMetricsAction("OutdatedPluginInfobar.LearnMore"));
+ // TODO(bauerb): Navigate to a help page explaining why we disabled
+ // the plugin, once we have one.
+ return false;
+}
} // namespace
-// -----------------------------------------------------------------------------
+
+// TabContents ----------------------------------------------------------------
// static
int TabContents::find_request_id_counter_ = -1;
@@ -612,9 +631,9 @@ bool TabContents::HostsExtension() const {
return GetURL().SchemeIs(chrome::kExtensionScheme);
}
-PluginInstaller* TabContents::GetPluginInstaller() {
+PluginInstallerInfoBarDelegate* TabContents::GetPluginInstaller() {
if (plugin_installer_.get() == NULL)
- plugin_installer_.reset(new PluginInstaller(this));
+ plugin_installer_.reset(new PluginInstallerInfoBarDelegate(this));
return plugin_installer_.get();
}
@@ -1192,8 +1211,7 @@ void TabContents::AddInfoBar(InfoBarDelegate* delegate) {
infobar_delegates_.push_back(delegate);
NotificationService::current()->Notify(
- NotificationType::TAB_CONTENTS_INFOBAR_ADDED,
- Source<TabContents>(this),
+ NotificationType::TAB_CONTENTS_INFOBAR_ADDED, Source<TabContents>(this),
Details<InfoBarDelegate>(delegate));
// Add ourselves as an observer for navigations the first time a delegate is
@@ -1219,19 +1237,11 @@ void TabContents::RemoveInfoBar(InfoBarDelegate* delegate) {
Source<TabContents>(this),
Details<InfoBarDelegate>(delegate));
- // Just to be safe, make sure the delegate was not removed by an observer.
- it = find(infobar_delegates_.begin(), infobar_delegates_.end(), delegate);
- if (it != infobar_delegates_.end()) {
- infobar_delegates_.erase(it);
- // Remove ourselves as an observer if we are tracking no more InfoBars.
- if (infobar_delegates_.empty()) {
- registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED,
- Source<NavigationController>(&controller_));
- }
- } else {
- // If you hit this NOTREACHED, please comment in bug
- // http://crbug.com/50428 how you got there.
- NOTREACHED();
+ infobar_delegates_.erase(it);
+ // Remove ourselves as an observer if we are tracking no more InfoBars.
+ if (infobar_delegates_.empty()) {
+ registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED,
+ Source<NavigationController>(&controller_));
}
}
}
@@ -1256,16 +1266,8 @@ void TabContents::ReplaceInfoBar(InfoBarDelegate* old_delegate,
Source<TabContents>(this),
Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details.get()));
- // Just to be safe, make sure the delegate was not removed by an observer.
- it = find(infobar_delegates_.begin(), infobar_delegates_.end(), old_delegate);
- if (it != infobar_delegates_.end()) {
- // Remove the old one.
- infobar_delegates_.erase(it);
- } else {
- // If you hit this NOTREACHED, please comment in bug
- // http://crbug.com/50428 how you got there.
- NOTREACHED();
- }
+ // Remove the old one.
+ infobar_delegates_.erase(it);
// Add the new one.
DCHECK(find(infobar_delegates_.begin(),
@@ -1845,13 +1847,6 @@ void TabContents::ExpireInfoBars(
for (int i = infobar_delegate_count() - 1; i >= 0; --i) {
InfoBarDelegate* delegate = GetInfoBarDelegateAt(i);
- if (!delegate) {
- // If you hit this NOTREACHED, please comment in bug
- // http://crbug.com/50428 how you got there.
- NOTREACHED();
- continue;
- }
-
if (delegate->ShouldExpire(details))
RemoveInfoBar(delegate);
}
@@ -2316,16 +2311,14 @@ void TabContents::OnCrashedPlugin(const FilePath& plugin_path) {
}
SkBitmap* crash_icon = ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_INFOBAR_PLUGIN_CRASHED);
- AddInfoBar(new SimpleAlertInfoBarDelegate(
- this, l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT,
- WideToUTF16Hack(plugin_name)),
- crash_icon, true));
+ AddInfoBar(new SimpleAlertInfoBarDelegate(this, crash_icon,
+ l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT,
+ WideToUTF16Hack(plugin_name)), true));
}
void TabContents::OnCrashedWorker() {
- AddInfoBar(new SimpleAlertInfoBarDelegate(
- this, l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT),
- NULL, true));
+ AddInfoBar(new SimpleAlertInfoBarDelegate(this, NULL,
+ l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true));
}
void TabContents::OnDidGetApplicationInfo(int32 page_id,
@@ -3054,9 +3047,8 @@ void TabContents::OnIgnoredUIEvent() {
}
void TabContents::OnJSOutOfMemory() {
- AddInfoBar(new SimpleAlertInfoBarDelegate(
- this, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT),
- NULL, true));
+ AddInfoBar(new SimpleAlertInfoBarDelegate(this, NULL,
+ l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), true));
}
void TabContents::OnCrossSiteResponse(int new_render_process_host_id,
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 556a431..1da5f14 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -65,7 +65,7 @@ class FileSelectHelper;
class InfoBarDelegate;
class LoadNotificationDetails;
class OmniboxSearchHint;
-class PluginInstaller;
+class PluginInstallerInfoBarDelegate;
class Profile;
class PrerenderManager;
struct RendererPreferences;
@@ -146,8 +146,8 @@ class TabContents : public PageNavigator,
// Returns true if contains content rendered by an extension.
bool HostsExtension() const;
- // Returns the PluginInstaller, creating it if necessary.
- PluginInstaller* GetPluginInstaller();
+ // Returns the PluginInstallerInfoBarDelegate, creating it if necessary.
+ PluginInstallerInfoBarDelegate* GetPluginInstaller();
// Returns the TabContentsSSLHelper, creating it if necessary.
TabContentsSSLHelper* GetSSLHelper();
@@ -1125,8 +1125,8 @@ class TabContents : public PageNavigator,
// AutoFillManager.
scoped_ptr<AutoFillManager> autofill_manager_;
- // PluginInstaller, lazily created.
- scoped_ptr<PluginInstaller> plugin_installer_;
+ // PluginInstallerInfoBarDelegate, lazily created.
+ scoped_ptr<PluginInstallerInfoBarDelegate> plugin_installer_;
// TabContentsSSLHelper, lazily created.
scoped_ptr<TabContentsSSLHelper> ssl_helper_;
diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc
index be8e567..06048ac 100644
--- a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc
+++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -29,134 +29,152 @@ SkBitmap* GetCertIcon() {
IDR_INFOBAR_SAVE_PASSWORD);
}
+
+// SSLCertAddedInfoBarDelegate ------------------------------------------------
+
class SSLCertAddedInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
SSLCertAddedInfoBarDelegate(TabContents* tab_contents,
- net::X509Certificate* cert)
- : ConfirmInfoBarDelegate(tab_contents),
- tab_contents_(tab_contents),
- cert_(cert) {
- }
-
- virtual ~SSLCertAddedInfoBarDelegate() {
- }
-
- // Overridden from ConfirmInfoBarDelegate:
- virtual string16 GetMessageText() const {
- // TODO(evanm): GetDisplayName should return UTF-16.
- return l10n_util::GetStringFUTF16(
- IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL,
- UTF8ToUTF16(cert_->issuer().GetDisplayName()));
- }
-
- virtual SkBitmap* GetIcon() const {
- return GetCertIcon();
- }
-
- virtual int GetButtons() const {
- return BUTTON_OK;
- }
-
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- switch (button) {
- case BUTTON_OK:
- return l10n_util::GetStringUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_BUTTON);
- default:
- return string16();
- }
- }
-
- virtual Type GetInfoBarType() {
- return PAGE_ACTION_TYPE;
- }
-
- virtual bool Accept() {
- ShowCertificateViewer(tab_contents_->GetMessageBoxRootWindow(), cert_);
- return false; // Hiding the infobar just as the dialog opens looks weird.
- }
-
- virtual void InfoBarClosed() {
- // ConfirmInfoBarDelegate doesn't delete itself.
- delete this;
- }
+ net::X509Certificate* cert);
private:
+ virtual ~SSLCertAddedInfoBarDelegate();
+
+ // ConfirmInfoBarDelegate:
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual Type GetInfoBarType() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
+
// The TabContents we are attached to
TabContents* tab_contents_;
// The cert we added.
scoped_refptr<net::X509Certificate> cert_;
};
+SSLCertAddedInfoBarDelegate::SSLCertAddedInfoBarDelegate(
+ TabContents* tab_contents,
+ net::X509Certificate* cert)
+ : ConfirmInfoBarDelegate(tab_contents),
+ tab_contents_(tab_contents),
+ cert_(cert) {
+}
+
+SSLCertAddedInfoBarDelegate::~SSLCertAddedInfoBarDelegate() {
+}
+
+void SSLCertAddedInfoBarDelegate::InfoBarClosed() {
+ // ConfirmInfoBarDelegate doesn't delete itself.
+ delete this;
+}
+
+SkBitmap* SSLCertAddedInfoBarDelegate::GetIcon() const {
+ return GetCertIcon();
+}
+
+InfoBarDelegate::Type SSLCertAddedInfoBarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+}
+
+string16 SSLCertAddedInfoBarDelegate::GetMessageText() const {
+ // TODO(evanm): GetDisplayName should return UTF-16.
+ return l10n_util::GetStringFUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL,
+ UTF8ToUTF16(cert_->issuer().GetDisplayName()));
+}
+
+int SSLCertAddedInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK;
+}
+
+string16 SSLCertAddedInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ DCHECK_EQ(BUTTON_OK, button);
+ return l10n_util::GetStringUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_BUTTON);
+}
+
+bool SSLCertAddedInfoBarDelegate::Accept() {
+ ShowCertificateViewer(tab_contents_->GetMessageBoxRootWindow(), cert_);
+ return false; // Hiding the infobar just as the dialog opens looks weird.
+}
+
} // namespace
+
+// TabContentsSSLHelper::SSLAddCertData ---------------------------------------
+
class TabContentsSSLHelper::SSLAddCertData : public NotificationObserver {
public:
- SSLAddCertData(TabContents* tab, SSLAddCertHandler* handler)
- : tab_(tab),
- handler_(handler),
- infobar_delegate_(NULL) {
- // Listen for disappearing InfoBars.
- Source<TabContents> tc_source(tab_);
- registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
- tc_source);
- registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED,
- tc_source);
- }
- ~SSLAddCertData() {}
+ SSLAddCertData(TabContents* tab, SSLAddCertHandler* handler);
+ virtual ~SSLAddCertData();
// Displays |delegate| as an infobar in |tab_|, replacing our current one if
// still active.
- void ShowInfoBar(InfoBarDelegate* delegate) {
- if (infobar_delegate_) {
- tab_->ReplaceInfoBar(infobar_delegate_, delegate);
- } else {
- tab_->AddInfoBar(delegate);
- }
- infobar_delegate_ = delegate;
- }
-
- void ShowErrorInfoBar(const string16& message) {
- ShowInfoBar(
- new SimpleAlertInfoBarDelegate(tab_, message, GetCertIcon(), true));
- }
-
- // NotificationObserver implementation.
+ void ShowInfoBar(InfoBarDelegate* delegate);
+
+ // Same as above, for the common case of wanting to show a simple alert
+ // message.
+ void ShowErrorInfoBar(const string16& message);
+
+ private:
+ // NotificationObserver:
virtual void Observe(NotificationType type,
const NotificationSource& source,
- const NotificationDetails& details) {
- switch (type.value) {
- case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED:
- InfoBarClosed(Details<InfoBarDelegate>(details).ptr());
- break;
- case NotificationType::TAB_CONTENTS_INFOBAR_REPLACED:
- typedef std::pair<InfoBarDelegate*, InfoBarDelegate*>
- InfoBarDelegatePair;
- InfoBarClosed(Details<InfoBarDelegatePair>(details).ptr()->first);
- break;
- default:
- NOTREACHED();
- break;
- }
- }
+ const NotificationDetails& details);
- private:
- void InfoBarClosed(InfoBarDelegate* delegate) {
- if (infobar_delegate_ == delegate)
- infobar_delegate_ = NULL;
- }
-
- // The TabContents we are attached to.
- TabContents* tab_;
- // The handler we call back to.
- scoped_refptr<SSLAddCertHandler> handler_;
- // The current InfoBarDelegate we're displaying.
+ TabContents* tab_contents_;
+ scoped_refptr<SSLAddCertHandler> handler_; // The handler we call back to.
InfoBarDelegate* infobar_delegate_;
-
NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(SSLAddCertData);
};
+TabContentsSSLHelper::SSLAddCertData::SSLAddCertData(TabContents* tab_contents,
+ SSLAddCertHandler* handler)
+ : tab_contents_(tab_contents),
+ handler_(handler),
+ infobar_delegate_(NULL) {
+ Source<TabContents> source(tab_contents_);
+ registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, source);
+ registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, source);
+}
+
+TabContentsSSLHelper::SSLAddCertData::~SSLAddCertData() {
+}
+
+void TabContentsSSLHelper::SSLAddCertData::ShowInfoBar(
+ InfoBarDelegate* delegate) {
+ if (infobar_delegate_)
+ tab_contents_->ReplaceInfoBar(infobar_delegate_, delegate);
+ else
+ tab_contents_->AddInfoBar(delegate);
+ infobar_delegate_ = delegate;
+}
+
+void TabContentsSSLHelper::SSLAddCertData::ShowErrorInfoBar(
+ const string16& message) {
+ ShowInfoBar(new SimpleAlertInfoBarDelegate(tab_contents_, GetCertIcon(),
+ message, true));
+}
+
+void TabContentsSSLHelper::SSLAddCertData::Observe(
+ NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> InfoBarDelegatePair;
+ if (infobar_delegate_ ==
+ ((type.value == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED) ?
+ Details<InfoBarDelegate>(details).ptr() :
+ Details<InfoBarDelegatePair>(details).ptr()->first))
+ infobar_delegate_ = NULL;
+}
+
+
+// TabContentsSSLHelper -------------------------------------------------------
+
TabContentsSSLHelper::TabContentsSSLHelper(TabContents* tab_contents)
: tab_contents_(tab_contents) {
}
diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.h b/chrome/browser/tab_contents/tab_contents_ssl_helper.h
index 9233561..2269c87 100644
--- a/chrome/browser/tab_contents/tab_contents_ssl_helper.h
+++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -11,6 +11,7 @@
#include "base/linked_ptr.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
+class SSLAddCertHandler;
class SSLClientAuthHandler;
class TabContents;
@@ -39,7 +40,7 @@ class TabContentsSSLHelper : public RenderViewHostDelegate::SSL {
class SSLAddCertData;
std::map<int, linked_ptr<SSLAddCertData> > request_id_to_add_cert_data_;
- SSLAddCertData* GetAddCertData(SSLAddCertHandler *handler);
+ SSLAddCertData* GetAddCertData(SSLAddCertHandler* handler);
DISALLOW_COPY_AND_ASSIGN(TabContentsSSLHelper);
};
diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc
index 66c6ca3..79b6dc1 100644
--- a/chrome/browser/task_manager/task_manager_browsertest.cc
+++ b/chrome/browser/task_manager/task_manager_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -386,11 +386,10 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest,
// gets reloaded and noticed in the task manager.
TabContents* current_tab = browser()->GetSelectedTabContents();
ASSERT_EQ(1, current_tab->infobar_delegate_count());
- InfoBarDelegate* delegate = current_tab->GetInfoBarDelegateAt(0);
- CrashedExtensionInfoBarDelegate* crashed_delegate =
- delegate->AsCrashedExtensionInfoBarDelegate();
- ASSERT_TRUE(crashed_delegate);
- crashed_delegate->Accept();
+ ConfirmInfoBarDelegate* delegate =
+ current_tab->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate();
+ ASSERT_TRUE(delegate);
+ delegate->Accept();
WaitForResourceChange(3);
}
diff --git a/chrome/browser/translate/languages_menu_model.cc b/chrome/browser/translate/languages_menu_model.cc
index 5f631d1..bd3ec10 100644
--- a/chrome/browser/translate/languages_menu_model.cc
+++ b/chrome/browser/translate/languages_menu_model.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -21,16 +21,16 @@ LanguagesMenuModel::~LanguagesMenuModel() {
}
bool LanguagesMenuModel::IsCommandIdChecked(int command_id) const {
- if (language_type_ == ORIGINAL)
- return command_id == translate_infobar_delegate_->original_language_index();
- return command_id == translate_infobar_delegate_->target_language_index();
+ return command_id == ((language_type_ == ORIGINAL) ?
+ translate_infobar_delegate_->original_language_index() :
+ translate_infobar_delegate_->target_language_index());
}
bool LanguagesMenuModel::IsCommandIdEnabled(int command_id) const {
- // Prevent from having the same language selectable in original and target.
- if (language_type_ == ORIGINAL)
- return command_id != translate_infobar_delegate_->target_language_index();
- return command_id != translate_infobar_delegate_->original_language_index();
+ // Prevent the same language from being selectable in original and target.
+ return command_id != ((language_type_ == ORIGINAL) ?
+ translate_infobar_delegate_->target_language_index() :
+ translate_infobar_delegate_->original_language_index());
}
bool LanguagesMenuModel::GetAcceleratorForCommandId(
diff --git a/chrome/browser/translate/translate_infobar_delegate.cc b/chrome/browser/translate/translate_infobar_delegate.cc
index c28a5c5..5a9bbc4 100644
--- a/chrome/browser/translate/translate_infobar_delegate.cc
+++ b/chrome/browser/translate/translate_infobar_delegate.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -24,7 +24,7 @@ TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateDelegate(
TabContents* tab_contents,
const std::string& original_language,
const std::string& target_language) {
- DCHECK(type != TRANSLATION_ERROR);
+ DCHECK_NE(TRANSLATION_ERROR, type);
// The original language can only be "unknown" for the "translating"
// infobar, which is the case when the user started a translation from the
// context menu.
@@ -32,14 +32,12 @@ TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateDelegate(
original_language != chrome::kUnknownLanguageCode);
if ((original_language != chrome::kUnknownLanguageCode &&
!TranslateManager::IsSupportedLanguage(original_language)) ||
- !TranslateManager::IsSupportedLanguage(target_language)) {
+ !TranslateManager::IsSupportedLanguage(target_language))
return NULL;
- }
TranslateInfoBarDelegate* delegate =
- new TranslateInfoBarDelegate(type, TranslateErrors::NONE,
- tab_contents,
+ new TranslateInfoBarDelegate(type, TranslateErrors::NONE, tab_contents,
original_language, target_language);
- DCHECK(delegate->target_language_index() != -1);
+ DCHECK_NE(-1, delegate->target_language_index());
return delegate;
}
@@ -52,76 +50,24 @@ TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateErrorDelegate(
original_language, target_language);
}
-TranslateInfoBarDelegate::TranslateInfoBarDelegate(
- Type type,
- TranslateErrors::Type error,
- TabContents* tab_contents,
- const std::string& original_language,
- const std::string& target_language)
- : InfoBarDelegate(tab_contents),
- type_(type),
- background_animation_(NONE),
- tab_contents_(tab_contents),
- original_language_index_(-1),
- initial_original_language_index_(-1),
- target_language_index_(-1),
- error_(error),
- infobar_view_(NULL),
- prefs_(tab_contents_->profile()->GetPrefs()) {
- DCHECK((type_ != TRANSLATION_ERROR && error == TranslateErrors::NONE) ||
- (type_ == TRANSLATION_ERROR && error != TranslateErrors::NONE));
-
- std::vector<std::string> language_codes;
- TranslateManager::GetSupportedLanguages(&language_codes);
-
- languages_.reserve(language_codes.size());
- for (std::vector<std::string>::const_iterator iter = language_codes.begin();
- iter != language_codes.end(); ++iter) {
- std::string language_code = *iter;
-
- string16 language_name = GetLanguageDisplayableName(language_code);
- // Insert the language in languages_ in alphabetical order.
- std::vector<LanguageNamePair>::iterator iter2;
- for (iter2 = languages_.begin(); iter2 != languages_.end(); ++iter2) {
- if (language_name.compare(iter2->second) < 0)
- break;
- }
- languages_.insert(iter2, LanguageNamePair(language_code, language_name));
- }
- for (std::vector<LanguageNamePair>::const_iterator iter = languages_.begin();
- iter != languages_.end(); ++iter) {
- std::string language_code = iter->first;
- if (language_code == original_language) {
- original_language_index_ = iter - languages_.begin();
- initial_original_language_index_ = original_language_index_;
- }
- if (language_code == target_language)
- target_language_index_ = iter - languages_.begin();
- }
-}
-
-TranslateInfoBarDelegate::~TranslateInfoBarDelegate() {}
-
-int TranslateInfoBarDelegate::GetLanguageCount() const {
- return static_cast<int>(languages_.size());
+TranslateInfoBarDelegate::~TranslateInfoBarDelegate() {
}
-std::string TranslateInfoBarDelegate::GetLanguageCodeAt(
- int index) const {
- DCHECK(index >=0 && index < GetLanguageCount());
+std::string TranslateInfoBarDelegate::GetLanguageCodeAt(int index) const {
+ DCHECK(index >= 0 && index < GetLanguageCount());
return languages_[index].first;
}
string16 TranslateInfoBarDelegate::GetLanguageDisplayableNameAt(
int index) const {
- DCHECK(index >=0 && index < GetLanguageCount());
+ DCHECK(index >= 0 && index < GetLanguageCount());
return languages_[index].second;
}
std::string TranslateInfoBarDelegate::GetOriginalLanguageCode() const {
- if (original_language_index() == -1)
- return chrome::kUnknownLanguageCode;
- return GetLanguageCodeAt(original_language_index());
+ return (original_language_index() == -1) ?
+ chrome::kUnknownLanguageCode :
+ GetLanguageCodeAt(original_language_index());
}
std::string TranslateInfoBarDelegate::GetTargetLanguageCode() const {
@@ -129,7 +75,7 @@ std::string TranslateInfoBarDelegate::GetTargetLanguageCode() const {
}
void TranslateInfoBarDelegate::SetOriginalLanguage(int language_index) {
- DCHECK(language_index < static_cast<int>(languages_.size()));
+ DCHECK_LT(language_index, GetLanguageCount());
original_language_index_ = language_index;
if (infobar_view_)
infobar_view_->OriginalLanguageChanged();
@@ -138,7 +84,7 @@ void TranslateInfoBarDelegate::SetOriginalLanguage(int language_index) {
}
void TranslateInfoBarDelegate::SetTargetLanguage(int language_index) {
- DCHECK(language_index < static_cast<int>(languages_.size()));
+ DCHECK_LT(language_index, GetLanguageCount());
target_language_index_ = language_index;
if (infobar_view_)
infobar_view_->TargetLanguageChanged();
@@ -146,10 +92,6 @@ void TranslateInfoBarDelegate::SetTargetLanguage(int language_index) {
Translate();
}
-bool TranslateInfoBarDelegate::IsError() {
- return type_ == TRANSLATION_ERROR;
-}
-
void TranslateInfoBarDelegate::Translate() {
const std::string& original_language_code = GetOriginalLanguageCode();
if (!tab_contents()->profile()->IsOffTheRecord()) {
@@ -157,8 +99,7 @@ void TranslateInfoBarDelegate::Translate() {
prefs_.IncrementTranslationAcceptedCount(original_language_code);
}
- TranslateManager::GetInstance()->TranslatePage(
- tab_contents_,
+ TranslateManager::GetInstance()->TranslatePage(tab_contents_,
GetLanguageCodeAt(original_language_index()),
GetLanguageCodeAt(target_language_index()));
}
@@ -169,8 +110,7 @@ void TranslateInfoBarDelegate::RevertTranslation() {
}
void TranslateInfoBarDelegate::ReportLanguageDetectionError() {
- TranslateManager::GetInstance()->
- ReportLanguageDetectionError(tab_contents_);
+ TranslateManager::GetInstance()->ReportLanguageDetectionError(tab_contents_);
}
void TranslateInfoBarDelegate::TranslationDeclined() {
@@ -188,34 +128,6 @@ void TranslateInfoBarDelegate::TranslationDeclined() {
tab_contents_->language_state().set_translation_declined(true);
}
-void TranslateInfoBarDelegate::InfoBarDismissed() {
- if (type_ != BEFORE_TRANSLATE)
- return;
-
- // The user closed the infobar without clicking the translate button.
- TranslationDeclined();
- UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslateCloseInfobar", 1);
-}
-
-void TranslateInfoBarDelegate::InfoBarClosed() {
- delete this;
-}
-
-SkBitmap* TranslateInfoBarDelegate::GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_INFOBAR_TRANSLATE);
-}
-
-InfoBarDelegate::Type TranslateInfoBarDelegate::GetInfoBarType() {
- return InfoBarDelegate::PAGE_ACTION_TYPE;
-}
-
-TranslateInfoBarDelegate*
-TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
- return this;
-}
-
-
bool TranslateInfoBarDelegate::IsLanguageBlacklisted() {
return prefs_.IsLanguageBlacklisted(GetOriginalLanguageCode());
}
@@ -278,35 +190,31 @@ void TranslateInfoBarDelegate::NeverTranslatePageLanguage() {
}
string16 TranslateInfoBarDelegate::GetMessageInfoBarText() {
- switch (type_) {
- case TRANSLATING:
+ if (type_ == TRANSLATING) {
+ return l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_TRANSLATING_TO,
+ GetLanguageDisplayableNameAt(target_language_index_));
+ }
+
+ DCHECK_EQ(TRANSLATION_ERROR, type_);
+ switch (error_) {
+ case TranslateErrors::NETWORK:
+ return l10n_util::GetStringUTF16(
+ IDS_TRANSLATE_INFOBAR_ERROR_CANT_CONNECT);
+ case TranslateErrors::INITIALIZATION_ERROR:
+ case TranslateErrors::TRANSLATION_ERROR:
+ return l10n_util::GetStringUTF16(
+ IDS_TRANSLATE_INFOBAR_ERROR_CANT_TRANSLATE);
+ case TranslateErrors::UNKNOWN_LANGUAGE:
+ return l10n_util::GetStringUTF16(
+ IDS_TRANSLATE_INFOBAR_UNKNOWN_PAGE_LANGUAGE);
+ case TranslateErrors::UNSUPPORTED_LANGUAGE:
+ return l10n_util::GetStringFUTF16(
+ IDS_TRANSLATE_INFOBAR_UNSUPPORTED_PAGE_LANGUAGE,
+ GetLanguageDisplayableNameAt(target_language_index_));
+ case TranslateErrors::IDENTICAL_LANGUAGES:
return l10n_util::GetStringFUTF16(
- IDS_TRANSLATE_INFOBAR_TRANSLATING_TO,
+ IDS_TRANSLATE_INFOBAR_ERROR_SAME_LANGUAGE,
GetLanguageDisplayableNameAt(target_language_index_));
- case TRANSLATION_ERROR:
- switch (error_) {
- case TranslateErrors::NETWORK:
- return l10n_util::GetStringUTF16(
- IDS_TRANSLATE_INFOBAR_ERROR_CANT_CONNECT);
- case TranslateErrors::INITIALIZATION_ERROR:
- case TranslateErrors::TRANSLATION_ERROR:
- return l10n_util::GetStringUTF16(
- IDS_TRANSLATE_INFOBAR_ERROR_CANT_TRANSLATE);
- case TranslateErrors::UNKNOWN_LANGUAGE:
- return l10n_util::GetStringUTF16(
- IDS_TRANSLATE_INFOBAR_UNKNOWN_PAGE_LANGUAGE);
- case TranslateErrors::UNSUPPORTED_LANGUAGE:
- return l10n_util::GetStringFUTF16(
- IDS_TRANSLATE_INFOBAR_UNSUPPORTED_PAGE_LANGUAGE,
- GetLanguageDisplayableNameAt(target_language_index_));
- case TranslateErrors::IDENTICAL_LANGUAGES:
- return l10n_util::GetStringFUTF16(
- IDS_TRANSLATE_INFOBAR_ERROR_SAME_LANGUAGE,
- GetLanguageDisplayableNameAt(target_language_index_));
- default:
- NOTREACHED();
- return string16();
- }
default:
NOTREACHED();
return string16();
@@ -314,33 +222,26 @@ string16 TranslateInfoBarDelegate::GetMessageInfoBarText() {
}
string16 TranslateInfoBarDelegate::GetMessageInfoBarButtonText() {
- switch (type_) {
- case TRANSLATING:
- return string16();
- case TRANSLATION_ERROR:
- if (error_ == TranslateErrors::IDENTICAL_LANGUAGES ||
- error_ == TranslateErrors::UNKNOWN_LANGUAGE) {
- // No retry button, we would fail again with the same error.
- return string16();
- }
- if (error_ == TranslateErrors::UNSUPPORTED_LANGUAGE)
- return l10n_util::GetStringUTF16(IDS_TRANSLATE_INFOBAR_REVERT);
- return l10n_util::GetStringUTF16(IDS_TRANSLATE_INFOBAR_RETRY);
- default:
- NOTREACHED();
- return string16();
+ if (type_ != TRANSLATION_ERROR) {
+ DCHECK_EQ(TRANSLATING, type_);
+ } else if ((error_ != TranslateErrors::IDENTICAL_LANGUAGES) &&
+ (error_ != TranslateErrors::UNKNOWN_LANGUAGE)) {
+ return l10n_util::GetStringUTF16(
+ (error_ == TranslateErrors::UNSUPPORTED_LANGUAGE) ?
+ IDS_TRANSLATE_INFOBAR_REVERT : IDS_TRANSLATE_INFOBAR_RETRY);
}
+ return string16();
}
void TranslateInfoBarDelegate::MessageInfoBarButtonPressed() {
- DCHECK(type_ == TRANSLATION_ERROR);
+ DCHECK_EQ(TRANSLATION_ERROR, type_);
if (error_ == TranslateErrors::UNSUPPORTED_LANGUAGE) {
RevertTranslation();
return;
}
// This is the "Try again..." case.
- TranslateManager::GetInstance()->TranslatePage(
- tab_contents_, GetOriginalLanguageCode(), GetTargetLanguageCode());
+ TranslateManager::GetInstance()->TranslatePage(tab_contents_,
+ GetOriginalLanguageCode(), GetTargetLanguageCode());
}
bool TranslateInfoBarDelegate::ShouldShowMessageInfoBarButton() {
@@ -348,31 +249,23 @@ bool TranslateInfoBarDelegate::ShouldShowMessageInfoBarButton() {
}
bool TranslateInfoBarDelegate::ShouldShowNeverTranslateButton() {
- DCHECK(type_ == BEFORE_TRANSLATE);
- if (tab_contents()->profile()->IsOffTheRecord())
- return false;
- return prefs_.GetTranslationDeniedCount(GetOriginalLanguageCode()) >= 3;
+ DCHECK_EQ(BEFORE_TRANSLATE, type_);
+ return !tab_contents()->profile()->IsOffTheRecord() &&
+ (prefs_.GetTranslationDeniedCount(GetOriginalLanguageCode()) >= 3);
}
bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateButton() {
- DCHECK(type_ == BEFORE_TRANSLATE);
- if (tab_contents()->profile()->IsOffTheRecord())
- return false;
- return prefs_.GetTranslationAcceptedCount(GetOriginalLanguageCode()) >= 3;
+ DCHECK_EQ(BEFORE_TRANSLATE, type_);
+ return !tab_contents()->profile()->IsOffTheRecord() &&
+ (prefs_.GetTranslationAcceptedCount(GetOriginalLanguageCode()) >= 3);
}
void TranslateInfoBarDelegate::UpdateBackgroundAnimation(
TranslateInfoBarDelegate* previous_infobar) {
- if (!previous_infobar || previous_infobar->IsError() == IsError()) {
+ if (!previous_infobar || previous_infobar->IsError() == IsError())
background_animation_ = NONE;
- return;
- }
- background_animation_ = IsError() ? NORMAL_TO_ERROR: ERROR_TO_NORMAL;
-}
-
-std::string TranslateInfoBarDelegate::GetPageHost() {
- NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
- return entry ? entry->url().HostNoBrackets() : std::string();
+ else
+ background_animation_ = IsError() ? NORMAL_TO_ERROR : ERROR_TO_NORMAL;
}
// static
@@ -392,17 +285,92 @@ void TranslateInfoBarDelegate::GetAfterTranslateStrings(
string16 text =
l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_AFTER_MESSAGE,
string16(), string16(), &offsets);
- DCHECK(offsets.size() == 2U);
+ DCHECK_EQ(2U, offsets.size());
- if (offsets[0] > offsets[1]) {
- // Target language comes before source.
+ *swap_languages = (offsets[0] > offsets[1]);
+ if (*swap_languages)
std::swap(offsets[0], offsets[1]);
- *swap_languages = true;
- } else {
- *swap_languages = false;
- }
strings->push_back(text.substr(0, offsets[0]));
strings->push_back(text.substr(offsets[0], offsets[1] - offsets[0]));
strings->push_back(text.substr(offsets[1]));
}
+
+TranslateInfoBarDelegate::TranslateInfoBarDelegate(
+ Type type,
+ TranslateErrors::Type error,
+ TabContents* tab_contents,
+ const std::string& original_language,
+ const std::string& target_language)
+ : InfoBarDelegate(tab_contents),
+ type_(type),
+ background_animation_(NONE),
+ tab_contents_(tab_contents),
+ original_language_index_(-1),
+ initial_original_language_index_(-1),
+ target_language_index_(-1),
+ error_(error),
+ infobar_view_(NULL),
+ prefs_(tab_contents_->profile()->GetPrefs()) {
+ DCHECK_NE((type_ == TRANSLATION_ERROR), (error == TranslateErrors::NONE));
+
+ std::vector<std::string> language_codes;
+ TranslateManager::GetSupportedLanguages(&language_codes);
+
+ languages_.reserve(language_codes.size());
+ for (std::vector<std::string>::const_iterator iter = language_codes.begin();
+ iter != language_codes.end(); ++iter) {
+ std::string language_code = *iter;
+
+ string16 language_name = GetLanguageDisplayableName(language_code);
+ // Insert the language in languages_ in alphabetical order.
+ std::vector<LanguageNamePair>::iterator iter2;
+ for (iter2 = languages_.begin(); iter2 != languages_.end(); ++iter2) {
+ if (language_name.compare(iter2->second) < 0)
+ break;
+ }
+ languages_.insert(iter2, LanguageNamePair(language_code, language_name));
+ }
+ for (std::vector<LanguageNamePair>::const_iterator iter = languages_.begin();
+ iter != languages_.end(); ++iter) {
+ std::string language_code = iter->first;
+ if (language_code == original_language) {
+ original_language_index_ = iter - languages_.begin();
+ initial_original_language_index_ = original_language_index_;
+ }
+ if (language_code == target_language)
+ target_language_index_ = iter - languages_.begin();
+ }
+}
+
+void TranslateInfoBarDelegate::InfoBarDismissed() {
+ if (type_ != BEFORE_TRANSLATE)
+ return;
+
+ // The user closed the infobar without clicking the translate button.
+ TranslationDeclined();
+ UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslateCloseInfobar", 1);
+}
+
+void TranslateInfoBarDelegate::InfoBarClosed() {
+ delete this;
+}
+
+SkBitmap* TranslateInfoBarDelegate::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_TRANSLATE);
+}
+
+InfoBarDelegate::Type TranslateInfoBarDelegate::GetInfoBarType() const {
+ return InfoBarDelegate::PAGE_ACTION_TYPE;
+}
+
+TranslateInfoBarDelegate*
+ TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
+ return this;
+}
+
+std::string TranslateInfoBarDelegate::GetPageHost() {
+ NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
+ return entry ? entry->url().HostNoBrackets() : std::string();
+}
diff --git a/chrome/browser/translate/translate_infobar_delegate.h b/chrome/browser/translate/translate_infobar_delegate.h
index 549af3d..1bc8a98 100644
--- a/chrome/browser/translate/translate_infobar_delegate.h
+++ b/chrome/browser/translate/translate_infobar_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -54,7 +54,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate {
virtual ~TranslateInfoBarDelegate();
// Returns the number of languages supported.
- int GetLanguageCount() const;
+ int GetLanguageCount() const { return static_cast<int>(languages_.size()); }
// Returns the ISO code for the language at |index|.
std::string GetLanguageCodeAt(int index) const;
@@ -82,7 +82,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate {
// Returns true if the current infobar indicates an error (in which case it
// should get a yellow background instead of a blue one).
- bool IsError();
+ bool IsError() const { return type_ == TRANSLATION_ERROR; }
// Returns what kind of background fading effect the infobar should use when
// its is shown.
@@ -98,14 +98,6 @@ class TranslateInfoBarDelegate : public InfoBarDelegate {
// infobar or pressing the "Don't translate" button.
void TranslationDeclined();
- // InfoBarDelegate implementation:
- virtual InfoBar* CreateInfoBar();
- virtual void InfoBarDismissed();
- virtual void InfoBarClosed();
- virtual SkBitmap* GetIcon() const;
- virtual InfoBarDelegate::Type GetInfoBarType();
- virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate();
-
// Methods called by the Options menu delegate.
virtual bool IsLanguageBlacklisted();
virtual void ToggleLanguageBlacklist();
@@ -164,6 +156,14 @@ class TranslateInfoBarDelegate : public InfoBarDelegate {
private:
typedef std::pair<std::string, string16> LanguageNamePair;
+ // InfoBarDelegate implementation:
+ virtual InfoBar* CreateInfoBar();
+ virtual void InfoBarDismissed();
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual InfoBarDelegate::Type GetInfoBarType() const;
+ virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate();
+
// Gets the host of the page being translated, or an empty string if no URL is
// associated with the current page.
std::string GetPageHost();
diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc
index b948e45..16895b9 100644
--- a/chrome/browser/translate/translate_manager.cc
+++ b/chrome/browser/translate/translate_manager.cc
@@ -415,8 +415,7 @@ void TranslateManager::InitiateTranslation(TabContents* tab,
// Prompts the user if he/she wants the page translated.
tab->AddInfoBar(TranslateInfoBarDelegate::CreateDelegate(
- TranslateInfoBarDelegate::BEFORE_TRANSLATE, tab,
- page_lang, target_lang));
+ TranslateInfoBarDelegate::BEFORE_TRANSLATE, tab, page_lang, target_lang));
}
void TranslateManager::InitiateTranslationPosted(
@@ -529,9 +528,8 @@ void TranslateManager::PageTranslated(TabContents* tab,
// Create the new infobar to display.
TranslateInfoBarDelegate* infobar;
if (details->error_type != TranslateErrors::NONE) {
- infobar = TranslateInfoBarDelegate::CreateErrorDelegate(
- details->error_type, tab,
- details->source_language, details->target_language);
+ infobar = TranslateInfoBarDelegate::CreateErrorDelegate(details->error_type,
+ tab, details->source_language, details->target_language);
} else if (!IsSupportedLanguage(details->source_language)) {
// TODO(jcivelli): http://crbug.com/9390 We should change the "after
// translate" infobar to support unknown as the original
@@ -627,9 +625,7 @@ void TranslateManager::ShowInfoBar(TabContents* tab,
std::string TranslateManager::GetTargetLanguage() {
std::string target_lang =
GetLanguageCode(g_browser_process->GetApplicationLocale());
- if (IsSupportedLanguage(target_lang))
- return target_lang;
- return std::string();
+ return IsSupportedLanguage(target_lang) ? target_lang : std::string();
}
// static
diff --git a/chrome/browser/translate/translate_manager_unittest.cc b/chrome/browser/translate/translate_manager_unittest.cc
index 9ab0c76..11087f2 100644
--- a/chrome/browser/translate/translate_manager_unittest.cc
+++ b/chrome/browser/translate/translate_manager_unittest.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/renderer_host/test/test_render_view_host.h"
+#include <set>
+
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -84,15 +86,15 @@ class TranslateManagerTest : public RenderViewHostTestHarness,
// Returns the translate infobar if there is 1 infobar and it is a translate
// infobar.
TranslateInfoBarDelegate* GetTranslateInfoBar() {
- if (contents()->infobar_delegate_count() != 1)
- return NULL;
- return contents()->GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate();
+ return (contents()->infobar_delegate_count() == 1) ?
+ contents()->GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate() :
+ NULL;
}
// If there is 1 infobar and it is a translate infobar, closes it and returns
// true. Returns false otherwise.
bool CloseTranslateInfoBar() {
- TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
+ InfoBarDelegate* infobar = GetTranslateInfoBar();
if (!infobar)
return false;
infobar->InfoBarDismissed(); // Simulates closing the infobar.
@@ -102,9 +104,8 @@ class TranslateManagerTest : public RenderViewHostTestHarness,
// Checks whether |infobar| has been removed and clears the removed infobar
// list.
- bool CheckInfoBarRemovedAndReset(InfoBarDelegate* infobar) {
- bool found = std::find(removed_infobars_.begin(), removed_infobars_.end(),
- infobar) != removed_infobars_.end();
+ bool CheckInfoBarRemovedAndReset(InfoBarDelegate* delegate) {
+ bool found = removed_infobars_.count(delegate) != 0;
removed_infobars_.clear();
return found;
}
@@ -137,8 +138,8 @@ class TranslateManagerTest : public RenderViewHostTestHarness,
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK(type == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED);
- removed_infobars_.push_back(Details<InfoBarDelegate>(details).ptr());
+ DCHECK_EQ(NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, type.value);
+ removed_infobars_.insert(Details<InfoBarDelegate>(details).ptr());
}
protected:
@@ -159,8 +160,7 @@ class TranslateManagerTest : public RenderViewHostTestHarness,
RenderViewHostTestHarness::SetUp();
- notification_registrar_.Add(
- this,
+ notification_registrar_.Add(this,
NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
Source<TabContents>(contents()));
}
@@ -168,8 +168,7 @@ class TranslateManagerTest : public RenderViewHostTestHarness,
virtual void TearDown() {
process()->sink().ClearMessages();
- notification_registrar_.Remove(
- this,
+ notification_registrar_.Remove(this,
NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
Source<TabContents>(contents()));
@@ -204,9 +203,9 @@ class TranslateManagerTest : public RenderViewHostTestHarness,
NotificationRegistrar notification_registrar_;
TestURLFetcherFactory url_fetcher_factory_;
- // The list of infobars that have been removed.
- // WARNING: the pointers points to deleted objects, use only for comparison.
- std::vector<InfoBarDelegate*> removed_infobars_;
+ // The infobars that have been removed.
+ // WARNING: the pointers point to deleted objects, use only for comparison.
+ std::set<InfoBarDelegate*> removed_infobars_;
DISALLOW_COPY_AND_ASSIGN(TranslateManagerTest);
};
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index f46ee08..81fb6db 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -3284,19 +3284,16 @@ void Browser::Observe(NotificationType type,
// this extension, it means that it has been reloaded in another window
// so just remove the remaining CrashedExtensionInfoBarDelegate objects.
const Extension* extension = Details<const Extension>(details).ptr();
- CrashedExtensionInfoBarDelegate* delegate = NULL;
TabStripModel* model = tab_handler_->GetTabStripModel();
for (int m = 0; m < model->count(); ++m) {
TabContents* tab_contents = model->GetTabContentsAt(m)->tab_contents();
- for (int i = 0; i < tab_contents->infobar_delegate_count();) {
- delegate = tab_contents->GetInfoBarDelegateAt(i)->
- AsCrashedExtensionInfoBarDelegate();
- if (delegate && delegate->extension_id() == extension->id()) {
+ for (int i = 0; i < tab_contents->infobar_delegate_count(); ) {
+ CrashedExtensionInfoBarDelegate* delegate = tab_contents->
+ GetInfoBarDelegateAt(i)->AsCrashedExtensionInfoBarDelegate();
+ if (delegate && delegate->extension_id() == extension->id())
tab_contents->RemoveInfoBar(delegate);
- continue;
- }
- // Only increment |i| if we didn't remove an entry.
- ++i;
+ else
+ ++i;
}
}
break;
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 65af6db..88029d4 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -101,88 +101,53 @@
namespace {
+// SetAsDefaultBrowserTask ----------------------------------------------------
+
class SetAsDefaultBrowserTask : public Task {
public:
- SetAsDefaultBrowserTask() { }
- virtual void Run() {
- ShellIntegration::SetAsDefaultBrowser();
- }
+ SetAsDefaultBrowserTask();
+ virtual ~SetAsDefaultBrowserTask();
private:
+ virtual void Run();
+
DISALLOW_COPY_AND_ASSIGN(SetAsDefaultBrowserTask);
};
-// The delegate for the infobar shown when Chrome is not the default browser.
-class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
- public:
- explicit DefaultBrowserInfoBarDelegate(TabContents* contents)
- : ConfirmInfoBarDelegate(contents),
- profile_(contents->profile()),
- action_taken_(false),
- should_expire_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
- // We want the info-bar to stick-around for few seconds and then be hidden
- // on the next navigation after that.
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- method_factory_.NewRunnableMethod(
- &DefaultBrowserInfoBarDelegate::Expire),
- 8000); // 8 seconds.
- }
-
- virtual bool ShouldExpire(
- const NavigationController::LoadCommittedDetails& details) const {
- return should_expire_;
- }
-
- // Overridden from ConfirmInfoBarDelegate:
- virtual void InfoBarClosed() {
- if (!action_taken_)
- UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1);
- delete this;
- }
+SetAsDefaultBrowserTask::SetAsDefaultBrowserTask() {
+}
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT);
- }
+SetAsDefaultBrowserTask::~SetAsDefaultBrowserTask() {
+}
- virtual SkBitmap* GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_PRODUCT_ICON_32);
- }
+void SetAsDefaultBrowserTask::Run() {
+ ShellIntegration::SetAsDefaultBrowser();
+}
- virtual int GetButtons() const {
- return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT;
- }
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- return button == BUTTON_OK ?
- l10n_util::GetStringUTF16(IDS_SET_AS_DEFAULT_INFOBAR_BUTTON_LABEL) :
- l10n_util::GetStringUTF16(IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL);
- }
+// DefaultBrowserInfoBarDelegate ----------------------------------------------
- virtual bool NeedElevation(InfoBarButton button) const {
- return button == BUTTON_OK;
- }
+// The delegate for the infobar shown when Chrome is not the default browser.
+class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
+ public:
+ explicit DefaultBrowserInfoBarDelegate(TabContents* contents);
- virtual bool Accept() {
- action_taken_ = true;
- UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1);
- g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE,
- new SetAsDefaultBrowserTask());
- return true;
- }
+ private:
+ virtual ~DefaultBrowserInfoBarDelegate();
- virtual bool Cancel() {
- action_taken_ = true;
- UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1);
- // User clicked "Don't ask me again", remember that.
- profile_->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, false);
- return true;
- }
+ void AllowExpiry() { should_expire_ = true; }
- void Expire() {
- should_expire_ = true;
- }
+ // ConfirmInfoBarDelegate:
+ virtual bool ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const;
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool NeedElevation(InfoBarButton button) const;
+ virtual bool Accept();
+ virtual bool Cancel();
private:
// The Profile that we restore sessions from.
@@ -200,88 +165,205 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate);
};
+DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(
+ TabContents* contents)
+ : ConfirmInfoBarDelegate(contents),
+ profile_(contents->profile()),
+ action_taken_(false),
+ should_expire_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ // We want the info-bar to stick-around for few seconds and then be hidden
+ // on the next navigation after that.
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &DefaultBrowserInfoBarDelegate::AllowExpiry), 8000); // 8 seconds.
+}
+
+DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() {
+}
+
+bool DefaultBrowserInfoBarDelegate::ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const {
+ return should_expire_;
+}
+
+void DefaultBrowserInfoBarDelegate::InfoBarClosed() {
+ if (!action_taken_)
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1);
+ delete this;
+}
+
+SkBitmap* DefaultBrowserInfoBarDelegate::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_PRODUCT_ICON_32);
+}
+
+string16 DefaultBrowserInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT);
+}
+
+int DefaultBrowserInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
+
+string16 DefaultBrowserInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ return button == BUTTON_OK ?
+ l10n_util::GetStringUTF16(IDS_SET_AS_DEFAULT_INFOBAR_BUTTON_LABEL) :
+ l10n_util::GetStringUTF16(IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL);
+}
+
+bool DefaultBrowserInfoBarDelegate::NeedElevation(InfoBarButton button) const {
+ return button == BUTTON_OK;
+}
+
+bool DefaultBrowserInfoBarDelegate::Accept() {
+ action_taken_ = true;
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1);
+ g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE,
+ new SetAsDefaultBrowserTask());
+ return true;
+}
+
+bool DefaultBrowserInfoBarDelegate::Cancel() {
+ action_taken_ = true;
+ UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1);
+ // User clicked "Don't ask me again", remember that.
+ profile_->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, false);
+ return true;
+}
+
+
+// NotifyNotDefaultBrowserTask ------------------------------------------------
+
class NotifyNotDefaultBrowserTask : public Task {
public:
- NotifyNotDefaultBrowserTask() { }
-
- virtual void Run() {
- Browser* browser = BrowserList::GetLastActive();
- if (!browser) {
- // Reached during ui tests.
- return;
- }
- TabContents* tab = browser->GetSelectedTabContents();
- // Don't show the info-bar if there are already info-bars showing.
- // In ChromeBot tests, there might be a race. This line appears to get
- // called during shutdown and |tab| can be NULL.
- if (!tab || tab->infobar_delegate_count() > 0)
- return;
- tab->AddInfoBar(new DefaultBrowserInfoBarDelegate(tab));
- }
+ NotifyNotDefaultBrowserTask();
+ virtual ~NotifyNotDefaultBrowserTask();
private:
+ virtual void Run();
+
DISALLOW_COPY_AND_ASSIGN(NotifyNotDefaultBrowserTask);
};
+NotifyNotDefaultBrowserTask::NotifyNotDefaultBrowserTask() {
+}
+
+NotifyNotDefaultBrowserTask::~NotifyNotDefaultBrowserTask() {
+}
+
+void NotifyNotDefaultBrowserTask::Run() {
+ Browser* browser = BrowserList::GetLastActive();
+ if (!browser)
+ return; // Reached during ui tests.
+ // Don't show the info-bar if there are already info-bars showing.
+ // In ChromeBot tests, there might be a race. This line appears to get
+ // called during shutdown and |tab| can be NULL.
+ TabContents* tab = browser->GetSelectedTabContents();
+ if (!tab || tab->infobar_delegate_count() > 0)
+ return;
+ tab->AddInfoBar(new DefaultBrowserInfoBarDelegate(tab));
+}
+
+
+// CheckDefaultBrowserTask ----------------------------------------------------
+
class CheckDefaultBrowserTask : public Task {
public:
- CheckDefaultBrowserTask() {
- }
+ CheckDefaultBrowserTask();
+ virtual ~CheckDefaultBrowserTask();
- virtual void Run() {
- if (ShellIntegration::IsDefaultBrowser())
- return;
+ private:
+ virtual void Run();
+
+ DISALLOW_COPY_AND_ASSIGN(CheckDefaultBrowserTask);
+};
+
+CheckDefaultBrowserTask::CheckDefaultBrowserTask() {
+}
+
+CheckDefaultBrowserTask::~CheckDefaultBrowserTask() {
+}
+
+void CheckDefaultBrowserTask::Run() {
+ if (ShellIntegration::IsDefaultBrowser())
+ return;
#if defined(OS_WIN)
- if (!BrowserDistribution::GetDistribution()->CanSetAsDefault())
- return;
+ if (!BrowserDistribution::GetDistribution()->CanSetAsDefault())
+ return;
#endif
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ new NotifyNotDefaultBrowserTask());
+}
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE, new NotifyNotDefaultBrowserTask());
- }
- private:
- DISALLOW_COPY_AND_ASSIGN(CheckDefaultBrowserTask);
-};
+// SessionCrashedInfoBarDelegate ----------------------------------------------
// A delegate for the InfoBar shown when the previous session has crashed. The
// bar deletes itself automatically after it is closed.
class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- explicit SessionCrashedInfoBarDelegate(TabContents* contents)
- : ConfirmInfoBarDelegate(contents),
- profile_(contents->profile()) {
- }
-
- // Overridden from ConfirmInfoBarDelegate:
- virtual void InfoBarClosed() {
- delete this;
- }
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE);
- }
- virtual SkBitmap* GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_INFOBAR_RESTORE_SESSION);
- }
- virtual int GetButtons() const { return BUTTON_OK; }
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON);
- }
- virtual bool Accept() {
- // Restore the session.
- SessionRestore::RestoreSession(profile_, NULL, true, false,
- std::vector<GURL>());
- return true;
- }
+ explicit SessionCrashedInfoBarDelegate(TabContents* contents);
private:
+ virtual ~SessionCrashedInfoBarDelegate();
+
+ // ConfirmInfoBarDelegate:
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
+
// The Profile that we restore sessions from.
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
};
+SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
+ TabContents* contents)
+ : ConfirmInfoBarDelegate(contents),
+ profile_(contents->profile()) {
+}
+
+SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {
+}
+
+void SessionCrashedInfoBarDelegate::InfoBarClosed() {
+ delete this;
+}
+
+SkBitmap* SessionCrashedInfoBarDelegate::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_RESTORE_SESSION);
+}
+
+string16 SessionCrashedInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE);
+}
+
+int SessionCrashedInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK;
+}
+
+string16 SessionCrashedInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ DCHECK_EQ(BUTTON_OK, button);
+ return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON);
+}
+
+bool SessionCrashedInfoBarDelegate::Accept() {
+ SessionRestore::RestoreSession(profile_, NULL, true, false,
+ std::vector<GURL>());
+ return true;
+}
+
+
+// Utility functions ----------------------------------------------------------
+
SessionStartupPref GetSessionStartupPref(const CommandLine& command_line,
Profile* profile) {
SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile);
@@ -367,6 +449,9 @@ void UrlsToTabs(const std::vector<GURL>& urls,
} // namespace
+
+// BrowserInit ----------------------------------------------------------------
+
BrowserInit::BrowserInit() {}
BrowserInit::~BrowserInit() {}
@@ -472,13 +557,15 @@ bool BrowserInit::LaunchBrowser(const CommandLine& command_line,
return true;
}
-// Tab ------------------------------------------------------------------------
+
+// BrowserInit::LaunchWithProfile::Tab ----------------------------------------
BrowserInit::LaunchWithProfile::Tab::Tab() : is_app(false), is_pinned(true) {}
BrowserInit::LaunchWithProfile::Tab::~Tab() {}
-// LaunchWithProfile ----------------------------------------------------------
+
+// BrowserInit::LaunchWithProfile ---------------------------------------------
BrowserInit::LaunchWithProfile::LaunchWithProfile(
const FilePath& cur_dir,
@@ -859,10 +946,10 @@ void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary(
}
if (bad_flag) {
- tab->AddInfoBar(new SimpleAlertInfoBarDelegate(tab,
+ tab->AddInfoBar(new SimpleAlertInfoBarDelegate(tab, NULL,
l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE,
UTF8ToUTF16(std::string("--") + bad_flag)),
- NULL, false));
+ false));
}
}
diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm
index 3cb8c5f..1f980c4 100644
--- a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -130,23 +130,23 @@ TEST_VIEW(AlertInfoBarControllerTest, [controller_ view]);
TEST_F(AlertInfoBarControllerTest, ShowAndDismiss) {
// Make sure someone looked at the message and icon.
- EXPECT_TRUE(delegate_.message_text_accessed);
- EXPECT_TRUE(delegate_.icon_accessed);
+ EXPECT_TRUE(delegate_.message_text_accessed());
+ EXPECT_TRUE(delegate_.icon_accessed());
// Check to make sure the infobar message was set properly.
- EXPECT_EQ(kMockAlertInfoBarMessage,
+ EXPECT_EQ(MockAlertInfoBarDelegate::kMessage,
base::SysNSStringToUTF8([controller_.get() labelString]));
// Check that dismissing the infobar calls InfoBarClosed() on the delegate.
[controller_ dismiss:nil];
- EXPECT_TRUE(delegate_.closed);
+ EXPECT_TRUE(delegate_.closed());
}
TEST_F(AlertInfoBarControllerTest, DeallocController) {
// Test that dealloc'ing the controller does not send an
// InfoBarClosed() message to the delegate.
controller_.reset(nil);
- EXPECT_FALSE(delegate_.closed);
+ EXPECT_FALSE(delegate_.closed());
}
TEST_F(AlertInfoBarControllerTest, ResizeView) {
@@ -167,118 +167,118 @@ TEST_VIEW(LinkInfoBarControllerTest, [controller_ view]);
TEST_F(LinkInfoBarControllerTest, ShowAndDismiss) {
// Make sure someone looked at the message, link, and icon.
- EXPECT_TRUE(delegate_.message_text_accessed);
- EXPECT_TRUE(delegate_.link_text_accessed);
- EXPECT_TRUE(delegate_.icon_accessed);
+ EXPECT_TRUE(delegate_.message_text_accessed());
+ EXPECT_TRUE(delegate_.link_text_accessed());
+ EXPECT_TRUE(delegate_.icon_accessed());
// Check that dismissing the infobar calls InfoBarClosed() on the delegate.
[controller_ dismiss:nil];
- EXPECT_FALSE(delegate_.link_clicked);
- EXPECT_TRUE(delegate_.closed);
+ EXPECT_FALSE(delegate_.link_clicked());
+ EXPECT_TRUE(delegate_.closed());
}
TEST_F(LinkInfoBarControllerTest, ShowAndClickLink) {
// Check that clicking on the link calls LinkClicked() on the
// delegate. It should also close the infobar.
[controller_ linkClicked];
- EXPECT_TRUE(delegate_.link_clicked);
- EXPECT_TRUE(delegate_.closed);
+ EXPECT_TRUE(delegate_.link_clicked());
+ EXPECT_TRUE(delegate_.closed());
}
TEST_F(LinkInfoBarControllerTest, ShowAndClickLinkWithoutClosing) {
- delegate_.closes_on_action = false;
+ delegate_.set_dont_close_on_action();
// Check that clicking on the link calls LinkClicked() on the
// delegate. It should not close the infobar.
[controller_ linkClicked];
- EXPECT_TRUE(delegate_.link_clicked);
- EXPECT_FALSE(delegate_.closed);
+ EXPECT_TRUE(delegate_.link_clicked());
+ EXPECT_FALSE(delegate_.closed());
}
TEST_VIEW(ConfirmInfoBarControllerTest, [controller_ view]);
TEST_F(ConfirmInfoBarControllerTest, ShowAndDismiss) {
// Make sure someone looked at the message, link, and icon.
- EXPECT_TRUE(delegate_.message_text_accessed);
- EXPECT_TRUE(delegate_.link_text_accessed);
- EXPECT_TRUE(delegate_.icon_accessed);
+ EXPECT_TRUE(delegate_.message_text_accessed());
+ EXPECT_TRUE(delegate_.link_text_accessed());
+ EXPECT_TRUE(delegate_.icon_accessed());
// Check to make sure the infobar message was set properly.
- EXPECT_EQ(kMockConfirmInfoBarMessage,
+ EXPECT_EQ(MockConfirmInfoBarDelegate::kMessage,
base::SysNSStringToUTF8([controller_.get() labelString]));
// Check that dismissing the infobar calls InfoBarClosed() on the delegate.
[controller_ dismiss:nil];
- EXPECT_FALSE(delegate_.ok_clicked);
- EXPECT_FALSE(delegate_.cancel_clicked);
- EXPECT_FALSE(delegate_.link_clicked);
- EXPECT_TRUE(delegate_.closed);
+ EXPECT_FALSE(delegate_.ok_clicked());
+ EXPECT_FALSE(delegate_.cancel_clicked());
+ EXPECT_FALSE(delegate_.link_clicked());
+ EXPECT_TRUE(delegate_.closed());
}
TEST_F(ConfirmInfoBarControllerTest, ShowAndClickOK) {
// Check that clicking the OK button calls Accept() and then closes
// the infobar.
[controller_ ok:nil];
- EXPECT_TRUE(delegate_.ok_clicked);
- EXPECT_FALSE(delegate_.cancel_clicked);
- EXPECT_FALSE(delegate_.link_clicked);
- EXPECT_TRUE(delegate_.closed);
+ EXPECT_TRUE(delegate_.ok_clicked());
+ EXPECT_FALSE(delegate_.cancel_clicked());
+ EXPECT_FALSE(delegate_.link_clicked());
+ EXPECT_TRUE(delegate_.closed());
}
TEST_F(ConfirmInfoBarControllerTest, ShowAndClickOKWithoutClosing) {
- delegate_.closes_on_action = false;
+ delegate_.set_dont_close_on_action();
// Check that clicking the OK button calls Accept() but does not close
// the infobar.
[controller_ ok:nil];
- EXPECT_TRUE(delegate_.ok_clicked);
- EXPECT_FALSE(delegate_.cancel_clicked);
- EXPECT_FALSE(delegate_.link_clicked);
- EXPECT_FALSE(delegate_.closed);
+ EXPECT_TRUE(delegate_.ok_clicked());
+ EXPECT_FALSE(delegate_.cancel_clicked());
+ EXPECT_FALSE(delegate_.link_clicked());
+ EXPECT_FALSE(delegate_.closed());
}
TEST_F(ConfirmInfoBarControllerTest, ShowAndClickCancel) {
// Check that clicking the cancel button calls Cancel() and closes
// the infobar.
[controller_ cancel:nil];
- EXPECT_FALSE(delegate_.ok_clicked);
- EXPECT_TRUE(delegate_.cancel_clicked);
- EXPECT_FALSE(delegate_.link_clicked);
- EXPECT_TRUE(delegate_.closed);
+ EXPECT_FALSE(delegate_.ok_clicked());
+ EXPECT_TRUE(delegate_.cancel_clicked());
+ EXPECT_FALSE(delegate_.link_clicked());
+ EXPECT_TRUE(delegate_.closed());
}
TEST_F(ConfirmInfoBarControllerTest, ShowAndClickCancelWithoutClosing) {
- delegate_.closes_on_action = false;
+ delegate_.set_dont_close_on_action();
// Check that clicking the cancel button calls Cancel() but does not close
// the infobar.
[controller_ cancel:nil];
- EXPECT_FALSE(delegate_.ok_clicked);
- EXPECT_TRUE(delegate_.cancel_clicked);
- EXPECT_FALSE(delegate_.link_clicked);
- EXPECT_FALSE(delegate_.closed);
+ EXPECT_FALSE(delegate_.ok_clicked());
+ EXPECT_TRUE(delegate_.cancel_clicked());
+ EXPECT_FALSE(delegate_.link_clicked());
+ EXPECT_FALSE(delegate_.closed());
}
TEST_F(ConfirmInfoBarControllerTest, ShowAndClickLink) {
// Check that clicking on the link calls LinkClicked() on the
// delegate. It should also close the infobar.
[controller_ linkClicked];
- EXPECT_FALSE(delegate_.ok_clicked);
- EXPECT_FALSE(delegate_.cancel_clicked);
- EXPECT_TRUE(delegate_.link_clicked);
- EXPECT_TRUE(delegate_.closed);
+ EXPECT_FALSE(delegate_.ok_clicked());
+ EXPECT_FALSE(delegate_.cancel_clicked());
+ EXPECT_TRUE(delegate_.link_clicked());
+ EXPECT_TRUE(delegate_.closed());
}
TEST_F(ConfirmInfoBarControllerTest, ShowAndClickLinkWithoutClosing) {
- delegate_.closes_on_action = false;
+ delegate_.set_dont_close_on_action();
// Check that clicking on the link calls LinkClicked() on the
// delegate. It should not close the infobar.
[controller_ linkClicked];
- EXPECT_FALSE(delegate_.ok_clicked);
- EXPECT_FALSE(delegate_.cancel_clicked);
- EXPECT_TRUE(delegate_.link_clicked);
- EXPECT_FALSE(delegate_.closed);
+ EXPECT_FALSE(delegate_.ok_clicked());
+ EXPECT_FALSE(delegate_.cancel_clicked());
+ EXPECT_TRUE(delegate_.link_clicked());
+ EXPECT_FALSE(delegate_.closed());
}
} // namespace
diff --git a/chrome/browser/ui/cocoa/infobars/infobar_test_helper.h b/chrome/browser/ui/cocoa/infobars/infobar_test_helper.h
index d01a71b..7f8f497 100644
--- a/chrome/browser/ui/cocoa/infobars/infobar_test_helper.h
+++ b/chrome/browser/ui/cocoa/infobars/infobar_test_helper.h
@@ -1,165 +1,123 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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/tab_contents/infobar_delegate.h"
+#ifndef CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_TEST_HELPER_H_
+#define CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_TEST_HELPER_H_
+#pragma once
-#include "base/utf_string_conversions.h"
+#include "chrome/browser/tab_contents/infobar_delegate.h"
-namespace {
-const char kMockAlertInfoBarMessage[] = "MockAlertInfoBarMessage";
-const char kMockLinkInfoBarMessage[] = "MockLinkInfoBarMessage";
-const char kMockLinkInfoBarLink[] = "http://dev.chromium.org";
-const char kMockConfirmInfoBarMessage[] = "MockConfirmInfoBarMessage";
-}
-//////////////////////////////////////////////////////////////////////////
-// Mock InfoBarDelgates
+// MockAlertInfoBarDelegate ---------------------------------------------------
class MockAlertInfoBarDelegate : public AlertInfoBarDelegate {
public:
- explicit MockAlertInfoBarDelegate()
- : AlertInfoBarDelegate(NULL),
- message_text_accessed(false),
- icon_accessed(false),
- closed(false) {
- }
-
- virtual string16 GetMessageText() const {
- message_text_accessed = true;
- return ASCIIToUTF16(kMockAlertInfoBarMessage);
- }
-
- virtual SkBitmap* GetIcon() const {
- icon_accessed = true;
- return NULL;
- }
-
- virtual void InfoBarClosed() {
- closed = true;
- }
-
- // These are declared mutable to get around const-ness issues.
- mutable bool message_text_accessed;
- mutable bool icon_accessed;
- bool closed;
+ MockAlertInfoBarDelegate();
+ virtual ~MockAlertInfoBarDelegate();
+
+ bool icon_accessed() const { return icon_accessed_; }
+ bool message_text_accessed() const { return message_text_accessed_; }
+ bool closed() const { return closed_; }
+
+ static const char kMessage[];
+
+ private:
+ // AlertInfoBarDelegate
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual string16 GetMessageText() const;
+
+ mutable bool icon_accessed_;
+ mutable bool message_text_accessed_;
+ bool closed_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockAlertInfoBarDelegate);
};
+
+// MockLinkInfoBarDelegate ----------------------------------------------------
+
class MockLinkInfoBarDelegate : public LinkInfoBarDelegate {
public:
- explicit MockLinkInfoBarDelegate()
- : LinkInfoBarDelegate(NULL),
- message_text_accessed(false),
- link_text_accessed(false),
- icon_accessed(false),
- link_clicked(false),
- closed(false),
- closes_on_action(true) {
- }
-
- virtual string16 GetMessageTextWithOffset(size_t* link_offset) const {
- message_text_accessed = true;
- return ASCIIToUTF16(kMockLinkInfoBarMessage);
- }
-
- virtual string16 GetLinkText() const {
- link_text_accessed = true;
- return ASCIIToUTF16(kMockLinkInfoBarLink);
- }
-
- virtual SkBitmap* GetIcon() const {
- icon_accessed = true;
- return NULL;
- }
-
- virtual bool LinkClicked(WindowOpenDisposition disposition) {
- link_clicked = true;
- return closes_on_action;
- }
-
- virtual void InfoBarClosed() {
- closed = true;
- }
-
- // These are declared mutable to get around const-ness issues.
- mutable bool message_text_accessed;
- mutable bool link_text_accessed;
- mutable bool icon_accessed;
- bool link_clicked;
- bool closed;
+ MockLinkInfoBarDelegate();
+ virtual ~MockLinkInfoBarDelegate();
+
+ void set_dont_close_on_action() { closes_on_action_ = false; }
+
+ bool icon_accessed() const { return icon_accessed_; }
+ bool message_text_accessed() const { return message_text_accessed_; }
+ bool link_text_accessed() const { return link_text_accessed_; }
+ bool link_clicked() const { return link_clicked_; }
+ bool closed() const { return closed_; }
+
+ static const char kMessage[];
+ static const char kLink[];
+
+ private:
+ // LinkInfoBarDelegate
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual string16 GetMessageTextWithOffset(size_t* link_offset) const;
+ virtual string16 GetLinkText() const;
+ virtual bool LinkClicked(WindowOpenDisposition disposition);
// Determines whether the infobar closes when an action is taken or not.
- bool closes_on_action;
+ bool closes_on_action_;
+
+ mutable bool icon_accessed_;
+ mutable bool message_text_accessed_;
+ mutable bool link_text_accessed_;
+ bool link_clicked_;
+ bool closed_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockLinkInfoBarDelegate);
};
+
+// MockConfirmInfoBarDelegate -------------------------------------------------
+
class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- explicit MockConfirmInfoBarDelegate()
- : ConfirmInfoBarDelegate(NULL),
- message_text_accessed(false),
- link_text_accessed(false),
- icon_accessed(false),
- ok_clicked(false),
- cancel_clicked(false),
- link_clicked(false),
- closed(false),
- closes_on_action(true) {
- }
-
- virtual int GetButtons() const {
- return (BUTTON_OK | BUTTON_CANCEL);
- }
-
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- if (button == BUTTON_OK)
- return ASCIIToUTF16("OK");
- else
- return ASCIIToUTF16("Cancel");
- }
-
- virtual bool Accept() {
- ok_clicked = true;
- return closes_on_action;
- }
-
- virtual bool Cancel() {
- cancel_clicked = true;
- return closes_on_action;
- }
-
- virtual string16 GetMessageText() const {
- message_text_accessed = true;
- return ASCIIToUTF16(kMockConfirmInfoBarMessage);
- }
-
- virtual SkBitmap* GetIcon() const {
- icon_accessed = true;
- return NULL;
- }
-
- virtual void InfoBarClosed() {
- closed = true;
- }
-
- virtual string16 GetLinkText() {
- link_text_accessed = true;
- return string16();
- }
-
- virtual bool LinkClicked(WindowOpenDisposition disposition) {
- link_clicked = true;
- return closes_on_action;
- }
-
- // These are declared mutable to get around const-ness issues.
- mutable bool message_text_accessed;
- mutable bool link_text_accessed;
- mutable bool icon_accessed;
- bool ok_clicked;
- bool cancel_clicked;
- bool link_clicked;
- bool closed;
+ MockConfirmInfoBarDelegate();
+ virtual ~MockConfirmInfoBarDelegate();
+
+ void set_dont_close_on_action() { closes_on_action_ = false; }
+
+ bool icon_accessed() const { return icon_accessed_; }
+ bool message_text_accessed() const { return message_text_accessed_; }
+ bool link_text_accessed() const { return link_text_accessed_; }
+ bool ok_clicked() const { return ok_clicked_; }
+ bool cancel_clicked() const { return cancel_clicked_; }
+ bool link_clicked() const { return link_clicked_; }
+ bool closed() const { return closed_; }
+
+ static const char kMessage[];
+
+ private:
+ // ConfirmInfoBarDelegate
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
+ virtual bool Cancel();
+ virtual string16 GetLinkText();
+ virtual bool LinkClicked(WindowOpenDisposition disposition);
// Determines whether the infobar closes when an action is taken or not.
- bool closes_on_action;
+ bool closes_on_action_;
+
+ mutable bool icon_accessed_;
+ mutable bool message_text_accessed_;
+ mutable bool link_text_accessed_;
+ bool ok_clicked_;
+ bool cancel_clicked_;
+ bool link_clicked_;
+ bool closed_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockConfirmInfoBarDelegate);
};
+
+#endif // CHROME_BROWSER_UI_COCOA_INFOBARS_INFOBAR_TEST_HELPER_H_
diff --git a/chrome/browser/ui/cocoa/infobars/infobar_test_helper.mm b/chrome/browser/ui/cocoa/infobars/infobar_test_helper.mm
new file mode 100644
index 0000000..b5881fb
--- /dev/null
+++ b/chrome/browser/ui/cocoa/infobars/infobar_test_helper.mm
@@ -0,0 +1,144 @@
+// Copyright (c) 2011 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/infobars/infobar_test_helper.h"
+
+#include "base/utf_string_conversions.h"
+
+
+// MockAlertInfoBarDelegate ---------------------------------------------------
+
+const char MockAlertInfoBarDelegate::kMessage[] = "MockAlertInfoBarMessage";
+
+MockAlertInfoBarDelegate::MockAlertInfoBarDelegate()
+ : AlertInfoBarDelegate(NULL),
+ icon_accessed_(false),
+ message_text_accessed_(false),
+ closed_(false) {
+}
+
+MockAlertInfoBarDelegate::~MockAlertInfoBarDelegate() {
+}
+
+void MockAlertInfoBarDelegate::InfoBarClosed() {
+ closed_ = true;
+}
+
+SkBitmap* MockAlertInfoBarDelegate::GetIcon() const {
+ icon_accessed_ = true;
+ return NULL;
+}
+
+string16 MockAlertInfoBarDelegate::GetMessageText() const {
+ message_text_accessed_ = true;
+ return ASCIIToUTF16(kMessage);
+}
+
+
+// MockLinkInfoBarDelegate ----------------------------------------------------
+
+const char MockLinkInfoBarDelegate::kMessage[] = "MockLinkInfoBarMessage";
+const char MockLinkInfoBarDelegate::kLink[] = "http://dev.chromium.org";
+
+MockLinkInfoBarDelegate::MockLinkInfoBarDelegate()
+ : LinkInfoBarDelegate(NULL),
+ closes_on_action_(true),
+ icon_accessed_(false),
+ message_text_accessed_(false),
+ link_text_accessed_(false),
+ link_clicked_(false),
+ closed_(false) {
+}
+
+MockLinkInfoBarDelegate::~MockLinkInfoBarDelegate() {
+}
+
+void MockLinkInfoBarDelegate::InfoBarClosed() {
+ closed_ = true;
+}
+
+SkBitmap* MockLinkInfoBarDelegate::GetIcon() const {
+ icon_accessed_ = true;
+ return NULL;
+}
+
+string16 MockLinkInfoBarDelegate::GetMessageTextWithOffset(
+ size_t* link_offset) const {
+ message_text_accessed_ = true;
+ return ASCIIToUTF16(kMessage);
+}
+
+string16 MockLinkInfoBarDelegate::GetLinkText() const {
+ link_text_accessed_ = true;
+ return ASCIIToUTF16(kLink);
+}
+
+bool MockLinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
+ link_clicked_ = true;
+ return closes_on_action_;
+}
+
+
+// MockConfirmInfoBarDelegate -------------------------------------------------
+
+const char MockConfirmInfoBarDelegate::kMessage[] = "MockConfirmInfoBarMessage";
+
+MockConfirmInfoBarDelegate::MockConfirmInfoBarDelegate()
+ : ConfirmInfoBarDelegate(NULL),
+ closes_on_action_(true),
+ icon_accessed_(false),
+ message_text_accessed_(false),
+ link_text_accessed_(false),
+ ok_clicked_(false),
+ cancel_clicked_(false),
+ link_clicked_(false),
+ closed_(false) {
+}
+
+MockConfirmInfoBarDelegate::~MockConfirmInfoBarDelegate() {
+}
+
+void MockConfirmInfoBarDelegate::InfoBarClosed() {
+ closed_ = true;
+}
+
+SkBitmap* MockConfirmInfoBarDelegate::GetIcon() const {
+ icon_accessed_ = true;
+ return NULL;
+}
+
+string16 MockConfirmInfoBarDelegate::GetMessageText() const {
+ message_text_accessed_ = true;
+ return ASCIIToUTF16(kMessage);
+}
+
+int MockConfirmInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
+
+string16 MockConfirmInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ return ASCIIToUTF16((button == BUTTON_OK) ? "OK" : "Cancel");
+}
+
+bool MockConfirmInfoBarDelegate::Accept() {
+ ok_clicked_ = true;
+ return closes_on_action_;
+}
+
+bool MockConfirmInfoBarDelegate::Cancel() {
+ cancel_clicked_ = true;
+ return closes_on_action_;
+}
+
+string16 MockConfirmInfoBarDelegate::GetLinkText() {
+ link_text_accessed_ = true;
+ return string16();
+}
+
+bool MockConfirmInfoBarDelegate::LinkClicked(
+ WindowOpenDisposition disposition) {
+ link_clicked_ = true;
+ return closes_on_action_;
+}
diff --git a/chrome/browser/ui/cocoa/keystone_infobar.mm b/chrome/browser/ui/cocoa/keystone_infobar.mm
index 6f86576..a94aa22 100644
--- a/chrome/browser/ui/cocoa/keystone_infobar.mm
+++ b/chrome/browser/ui/cocoa/keystone_infobar.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -32,89 +32,102 @@ class SkBitmap;
namespace {
+// KeystonePromotionInfoBarDelegate -------------------------------------------
+
class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- KeystonePromotionInfoBarDelegate(TabContents* tab_contents)
- : ConfirmInfoBarDelegate(tab_contents),
- profile_(tab_contents->profile()),
- can_expire_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
- const int kCanExpireOnNavigationAfterMilliseconds = 8 * 1000;
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- method_factory_.NewRunnableMethod(
- &KeystonePromotionInfoBarDelegate::SetCanExpire),
- kCanExpireOnNavigationAfterMilliseconds);
- }
+ explicit KeystonePromotionInfoBarDelegate(TabContents* tab_contents);
- virtual ~KeystonePromotionInfoBarDelegate() {}
+ private:
+ virtual ~KeystonePromotionInfoBarDelegate();
- // Inherited from InfoBarDelegate and overridden.
+ // Sets this info bar to be able to expire. Called a predetermined amount
+ // of time after this object is created.
+ void SetCanExpire() { can_expire_ = true; }
+ // ConfirmInfoBarDelegate
virtual bool ShouldExpire(
- const NavigationController::LoadCommittedDetails& details) {
- return can_expire_;
- }
+ const NavigationController::LoadCommittedDetails& details) const;
+ virtual void InfoBarClosed();
+ virtual SkBitmap* GetIcon() const;
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+ virtual string16 GetButtonLabel(InfoBarButton button) const;
+ virtual bool Accept();
+ virtual bool Cancel();
- virtual void InfoBarClosed() {
- delete this;
- }
+ // The TabContents' profile.
+ Profile* profile_; // weak
- // Inherited from AlertInfoBarDelegate and overridden.
+ // Whether the info bar should be dismissed on the next navigation.
+ bool can_expire_;
- virtual string16 GetMessageText() const {
- return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
- }
+ // Used to delay the expiration of the info bar.
+ ScopedRunnableMethodFactory<KeystonePromotionInfoBarDelegate> method_factory_;
- virtual SkBitmap* GetIcon() const {
- return ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_PRODUCT_ICON_32);
- }
+ DISALLOW_COPY_AND_ASSIGN(KeystonePromotionInfoBarDelegate);
+};
- // Inherited from ConfirmInfoBarDelegate and overridden.
+KeystonePromotionInfoBarDelegate::KeystonePromotionInfoBarDelegate(
+ TabContents* tab_contents)
+ : ConfirmInfoBarDelegate(tab_contents),
+ profile_(tab_contents->profile()),
+ can_expire_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ const int kCanExpireOnNavigationAfterMilliseconds = 8 * 1000;
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &KeystonePromotionInfoBarDelegate::SetCanExpire),
+ kCanExpireOnNavigationAfterMilliseconds);
+}
- virtual int GetButtons() const {
- return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT;
- }
+KeystonePromotionInfoBarDelegate::~KeystonePromotionInfoBarDelegate() {
+}
- virtual string16 GetButtonLabel(InfoBarButton button) const {
- return button == BUTTON_OK ?
- l10n_util::GetStringUTF16(IDS_PROMOTE_INFOBAR_PROMOTE_BUTTON) :
- l10n_util::GetStringUTF16(IDS_PROMOTE_INFOBAR_DONT_ASK_BUTTON);
- }
+bool KeystonePromotionInfoBarDelegate::ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const {
+ return can_expire_;
+}
- virtual bool Accept() {
- [[KeystoneGlue defaultKeystoneGlue] promoteTicket];
- return true;
- }
+void KeystonePromotionInfoBarDelegate::InfoBarClosed() {
+ delete this;
+}
- virtual bool Cancel() {
- profile_->GetPrefs()->SetBoolean(prefs::kShowUpdatePromotionInfoBar, false);
- return true;
- }
+SkBitmap* KeystonePromotionInfoBarDelegate::GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_PRODUCT_ICON_32);
+}
- private:
- // Sets this info bar to be able to expire. Called a predetermined amount
- // of time after this object is created.
- void SetCanExpire() {
- can_expire_ = true;
- }
+string16 KeystonePromotionInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT,
+ l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
+}
- // The TabContents' profile.
- Profile* profile_; // weak
+int KeystonePromotionInfoBarDelegate::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
- // Whether the info bar should be dismissed on the next navigation.
- bool can_expire_;
+string16 KeystonePromotionInfoBarDelegate::GetButtonLabel(
+ InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
+ IDS_PROMOTE_INFOBAR_PROMOTE_BUTTON : IDS_PROMOTE_INFOBAR_DONT_ASK_BUTTON);
+}
- // Used to delay the expiration of the info bar.
- ScopedRunnableMethodFactory<KeystonePromotionInfoBarDelegate> method_factory_;
+bool KeystonePromotionInfoBarDelegate::Accept() {
+ [[KeystoneGlue defaultKeystoneGlue] promoteTicket];
+ return true;
+}
- DISALLOW_COPY_AND_ASSIGN(KeystonePromotionInfoBarDelegate);
-};
+bool KeystonePromotionInfoBarDelegate::Cancel() {
+ profile_->GetPrefs()->SetBoolean(prefs::kShowUpdatePromotionInfoBar, false);
+ return true;
+}
} // namespace
+
+// KeystonePromotionInfoBar ---------------------------------------------------
+
@interface KeystonePromotionInfoBar : NSObject
- (void)checkAndShowInfoBarForProfile:(Profile*)profile;
- (void)updateStatus:(NSNotification*)notification;
diff --git a/chrome/browser/ui/cocoa/translate/translate_infobar_unittest.mm b/chrome/browser/ui/cocoa/translate/translate_infobar_unittest.mm
index 7565927..9cec792 100644
--- a/chrome/browser/ui/cocoa/translate/translate_infobar_unittest.mm
+++ b/chrome/browser/ui/cocoa/translate/translate_infobar_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -97,7 +97,8 @@ class TranslationInfoBarTest : public CocoaTest {
infobar_delegate.reset(
new MockTranslateInfoBarDelegate(type, error, tab_contents.get()));
[[infobar_controller view] removeFromSuperview];
- scoped_ptr<InfoBar> infobar(infobar_delegate->CreateInfoBar());
+ scoped_ptr<InfoBar> infobar(
+ static_cast<InfoBarDelegate*>(infobar_delegate.get())->CreateInfoBar());
infobar_controller.reset(
reinterpret_cast<TranslateInfoBarControllerBase*>(
infobar->controller()));
diff --git a/chrome/browser/ui/gtk/translate/translate_infobar_base_gtk.h b/chrome/browser/ui/gtk/translate/translate_infobar_base_gtk.h
index a76ebfb..98c5791 100644
--- a/chrome/browser/ui/gtk/translate/translate_infobar_base_gtk.h
+++ b/chrome/browser/ui/gtk/translate/translate_infobar_base_gtk.h
@@ -51,7 +51,7 @@ class TranslateInfoBarBase : public TranslateInfoBarView,
// Creates a combobox that displays the languages currently available.
// |selected_language| is the language index (as used in the
- // TranslateInfoDelegate) that should be selected initially.
+ // TranslateInfoBarDelegate) that should be selected initially.
// |exclude_language| is the language index of the language that should not be
// included in the list (-1 means no language excluded).
GtkWidget* CreateLanguageCombobox(int selected_language,
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 6275760..b09fccb2 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1819,7 +1819,7 @@ AccessibilityTypes::Role BrowserView::GetAccessibleRole() {
return AccessibilityTypes::ROLE_CLIENT;
}
-void BrowserView::InfoBarSizeChanged(bool is_animating) {
+void BrowserView::InfoBarContainerSizeChanged(bool is_animating) {
SelectedTabToolbarSizeChanged(is_animating);
}
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index e292f29..7bdb7d2 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -395,7 +395,7 @@ class BrowserView : public BrowserBubbleHost,
virtual gfx::Size GetMinimumSize();
// InfoBarContainer::Delegate overrides
- virtual void InfoBarSizeChanged(bool is_animating);
+ virtual void InfoBarContainerSizeChanged(bool is_animating);
// views::SingleSplitView::Observer overrides:
virtual bool SplitHandleMoved(views::SingleSplitView* view);
diff --git a/chrome/browser/ui/views/infobars/infobar_container.cc b/chrome/browser/ui/views/infobars/infobar_container.cc
index 5f62201..270e43f 100644
--- a/chrome/browser/ui/views/infobars/infobar_container.cc
+++ b/chrome/browser/ui/views/infobars/infobar_container.cc
@@ -52,7 +52,7 @@ void InfoBarContainer::ChangeTabContents(TabContents* contents) {
void InfoBarContainer::InfoBarAnimated(bool completed) {
if (delegate_)
- delegate_->InfoBarSizeChanged(!completed);
+ delegate_->InfoBarContainerSizeChanged(!completed);
}
void InfoBarContainer::RemoveDelegate(InfoBarDelegate* delegate) {
@@ -92,7 +92,7 @@ void InfoBarContainer::ViewHierarchyChanged(bool is_add,
if (delegate_) {
// An InfoBar child was added or removed. Tell the delegate it needs to
// re-layout since our preferred size will have changed.
- delegate_->InfoBarSizeChanged(false);
+ delegate_->InfoBarContainerSizeChanged(false);
}
}
}
diff --git a/chrome/browser/ui/views/infobars/infobar_container.h b/chrome/browser/ui/views/infobars/infobar_container.h
index 0acdd4f..1461700 100644
--- a/chrome/browser/ui/views/infobars/infobar_container.h
+++ b/chrome/browser/ui/views/infobars/infobar_container.h
@@ -25,7 +25,7 @@ class InfoBarContainer : public AccessiblePaneView,
class Delegate {
public:
virtual ~Delegate() {}
- virtual void InfoBarSizeChanged(bool is_animating) = 0;
+ virtual void InfoBarContainerSizeChanged(bool is_animating) = 0;
};
explicit InfoBarContainer(Delegate* delegate);
diff --git a/chrome/browser/ui/views/infobars/infobars.cc b/chrome/browser/ui/views/infobars/infobars.cc
index 7ac5cec..d83d76e 100644
--- a/chrome/browser/ui/views/infobars/infobars.cc
+++ b/chrome/browser/ui/views/infobars/infobars.cc
@@ -471,10 +471,14 @@ ConfirmInfoBar::ConfirmInfoBar(ConfirmInfoBarDelegate* delegate)
link_(NULL),
initialized_(false) {
ok_button_ = InfoBarTextButton::Create(this,
- delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
+ (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK) ?
+ delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK) :
+ string16());
ok_button_->SetAccessibleName(WideToUTF16Hack(ok_button_->text()));
cancel_button_ = InfoBarTextButton::Create(this,
- delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
+ (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_CANCEL) ?
+ delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL) :
+ string16());
cancel_button_->SetAccessibleName(WideToUTF16Hack(cancel_button_->text()));
// Set up the link.
diff --git a/chrome/browser/ui/views/infobars/translate_infobar_base.cc b/chrome/browser/ui/views/infobars/translate_infobar_base.cc
index ecba1fe..897699f 100644
--- a/chrome/browser/ui/views/infobars/translate_infobar_base.cc
+++ b/chrome/browser/ui/views/infobars/translate_infobar_base.cc
@@ -23,7 +23,7 @@ TranslateInfoBarBase::TranslateInfoBarBase(
normal_background_(InfoBarDelegate::PAGE_ACTION_TYPE),
error_background_(InfoBarDelegate::WARNING_TYPE) {
icon_ = new views::ImageView;
- SkBitmap* image = delegate->GetIcon();
+ SkBitmap* image = static_cast<InfoBarDelegate*>(delegate)->GetIcon();
if (image)
icon_->SetImage(image);
AddChildView(icon_);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 45b09f9..dc048d7 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1971,8 +1971,8 @@
'browser/plugin_download_helper.h',
'browser/plugin_exceptions_table_model.cc',
'browser/plugin_exceptions_table_model.h',
- 'browser/plugin_installer.cc',
- 'browser/plugin_installer.h',
+ 'browser/plugin_installer_infobar_delegate.cc',
+ 'browser/plugin_installer_infobar_delegate.h',
'browser/plugin_process_host.cc',
'browser/plugin_process_host.h',
'browser/plugin_process_host_mac.cc',
@@ -2879,6 +2879,7 @@
'browser/ui/cocoa/infobars/infobar_gradient_view.h',
'browser/ui/cocoa/infobars/infobar_gradient_view.mm',
'browser/ui/cocoa/infobars/infobar_test_helper.h',
+ 'browser/ui/cocoa/infobars/infobar_test_helper.mm',
'browser/ui/cocoa/install_from_dmg.h',
'browser/ui/cocoa/install_from_dmg.mm',
'browser/ui/cocoa/instant_confirm_window_controller.h',
diff --git a/chrome/common/automation_messages_internal.h b/chrome/common/automation_messages_internal.h
index ac3fd77..a6f3275 100644
--- a/chrome/common/automation_messages_internal.h
+++ b/chrome/common/automation_messages_internal.h
@@ -764,7 +764,6 @@ IPC_SYNC_MESSAGE_CONTROL3_1(AutomationMsg_ClickInfoBarAccept,
int /* tab_handle */,
int /* info bar index */,
bool /* wait for navigation */,
-
/* navigation result */
AutomationMsg_NavigationResponseValues)
@@ -779,7 +778,6 @@ IPC_SYNC_MESSAGE_CONTROL1_1(AutomationMsg_GetLastNavigationTime,
IPC_SYNC_MESSAGE_CONTROL2_1(AutomationMsg_WaitForNavigation,
int /* tab_handle */,
int64 /* last navigation time */,
-
/* navigation result */
AutomationMsg_NavigationResponseValues)
@@ -1027,7 +1025,7 @@ IPC_SYNC_MESSAGE_CONTROL2_1(AutomationMsg_NavigateExternalTabAtIndex,
// This message requests the provider to wait until the window count
// reached the specified value.
// Request:
-// - int: target browser window count
+// - int: target browser window count
// Response:
// - bool: whether the operation was successful.
IPC_SYNC_MESSAGE_CONTROL1_1(AutomationMsg_WaitForBrowserWindowCountToBecome,