Inform user to reload page after chagning cookie settings from in-page dialog.

NOTE: the png file is not final yet, waiting for chrome ui folks to provide
final vesion.  However, this does not change the code, so please review.
Thanks.

BUG=63645
TEST=Block all cookies and load a page that uses cookies.  Click on the broken
cookie icon in the omnibox and open the in-page cookie dialog.  Change a
blocked to allow, or block an allowed cookie.  After clicking the Close button
an infobar appears with a warning.  Make sure the reload button works.
Review URL: http://codereview.chromium.org/6676041

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78829 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 3430c446..e9d84ad 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7326,6 +7326,12 @@
       <message name="IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL" desc="The label in a tabbed pane that holds the UI controls for the cookies blocked while loading the page.">
         Blocked
       </message>
+      <message name="IDS_COLLECTED_COOKIES_INFOBAR_MESSAGE" desc="The string shown in the infobar after the user has changed the allowed/blocked state of a cookie, reminding them to reload the page in order for the new cookies to take effect.">
+        New cookie settings will take effect after reloading the page.
+      </message>
+      <message name="IDS_COLLECTED_COOKIES_INFOBAR_BUTTON" desc="The string used in the infobar button allowing the user to reload the page directly from the infobar.">
+        Reload
+      </message>
 
       <!-- Cookies Window -->
       <message name="IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE" desc="The title of the redesigned Cookies Window that lets you manage cookies, storage quota for websites and other permissions per-website">
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 69361d7..050edee 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -202,6 +202,7 @@
       <include name="IDR_INFOBAR_SAVE_PASSWORD" file="infobar_savepassword.png" type="BINDATA" />
       <include name="IDR_INFOBAR_SSL_WARNING" file="infobar_insecure.png" type="BINDATA" />
       <include name="IDR_INFOBAR_THEME" file="infobar_theme.png" type="BINDATA" />
+      <include name="IDR_INFOBAR_COOKIE" file="infobar_cookie.png" type="BINDATA" />
       <if expr="pp_ifdef('_google_chrome')">
         <include name="IDR_INFOBAR_TRANSLATE" file="google_chrome/infobar_translate.png" type="BINDATA" />
       </if>
diff --git a/chrome/browser/ui/collected_cookies_infobar_delegate.cc b/chrome/browser/ui/collected_cookies_infobar_delegate.cc
new file mode 100644
index 0000000..0f1d279
--- /dev/null
+++ b/chrome/browser/ui/collected_cookies_infobar_delegate.cc
@@ -0,0 +1,45 @@
+// 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/collected_cookies_infobar_delegate.h"
+
+#include "base/logging.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+
+CollectedCookiesInfoBarDelegate::CollectedCookiesInfoBarDelegate(
+    TabContents* tab_contents)
+    : ConfirmInfoBarDelegate(tab_contents),
+      tab_contents_(tab_contents) {
+}
+
+SkBitmap* CollectedCookiesInfoBarDelegate::GetIcon() const {
+  return ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_INFOBAR_COOKIE);
+}
+
+InfoBarDelegate::Type CollectedCookiesInfoBarDelegate::GetInfoBarType() const {
+  return PAGE_ACTION_TYPE;
+}
+
+string16 CollectedCookiesInfoBarDelegate::GetMessageText() const {
+  return l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_INFOBAR_MESSAGE);
+}
+
+int CollectedCookiesInfoBarDelegate::GetButtons() const {
+  return BUTTON_OK;
+}
+
+string16 CollectedCookiesInfoBarDelegate::GetButtonLabel(InfoBarButton button)
+    const {
+  DCHECK_EQ(BUTTON_OK, button);
+  return l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_INFOBAR_BUTTON);
+}
+
+bool CollectedCookiesInfoBarDelegate::Accept() {
+  tab_contents_->controller().Reload(true);
+  return true;
+}
diff --git a/chrome/browser/ui/collected_cookies_infobar_delegate.h b/chrome/browser/ui/collected_cookies_infobar_delegate.h
new file mode 100644
index 0000000..8e76221
--- /dev/null
+++ b/chrome/browser/ui/collected_cookies_infobar_delegate.h
@@ -0,0 +1,33 @@
+// 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_UI_COLLECTED_COOKIES_INFOBAR_DELEGATE_H_
+#define CHROME_BROWSER_UI_COLLECTED_COOKIES_INFOBAR_DELEGATE_H_
+
+#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
+
+// This class configures an infobar shown when the collected cookies dialog
+// is closed and the settings for one or more cookies have been changed.  The
+// user is shown a message indicating that a reload of the page is
+// required for the changes to take effect, and presented a button to perform
+// the reload right from the infobar.
+class CollectedCookiesInfoBarDelegate : public ConfirmInfoBarDelegate {
+ public:
+  explicit CollectedCookiesInfoBarDelegate(TabContents* tab_contents);
+
+ private:
+  // ConfirmInfoBarDelegate overrides.
+  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();
+
+  TabContents* tab_contents_;
+
+  DISALLOW_COPY_AND_ASSIGN(CollectedCookiesInfoBarDelegate);
+};
+
+#endif  // CHROME_BROWSER_UI_COLLECTED_COOKIES_INFOBAR_DELEGATE_H_
diff --git a/chrome/browser/ui/views/collected_cookies_win.cc b/chrome/browser/ui/views/collected_cookies_win.cc
index 316db23..ef1ac91 100644
--- a/chrome/browser/ui/views/collected_cookies_win.cc
+++ b/chrome/browser/ui/views/collected_cookies_win.cc
@@ -6,6 +6,7 @@
 
 #include "chrome/browser/cookies_tree_model.h"
 #include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
 #include "chrome/browser/ui/views/cookie_info_view.h"
 #include "content/browser/tab_contents/tab_contents.h"
 #include "content/common/notification_details.h"
@@ -169,7 +170,8 @@
       block_allowed_button_(NULL),
       allow_blocked_button_(NULL),
       for_session_blocked_button_(NULL),
-      infobar_(NULL) {
+      infobar_(NULL),
+      status_changed_(false) {
   TabSpecificContentSettings* content_settings =
       tab_contents->GetTabSpecificContentSettings();
   registrar_.Add(this, NotificationType::COLLECTED_COOKIES_SHOWN,
@@ -370,6 +372,11 @@
 }
 
 bool CollectedCookiesWin::Cancel() {
+  if (status_changed_) {
+    tab_contents_->AddInfoBar(
+        new CollectedCookiesInfoBarDelegate(tab_contents_));
+  }
+
   return true;
 }
 
@@ -476,6 +483,7 @@
   gfx::Size size = GetRootView()->GetPreferredSize();
   bounds.SetRect(topleft.x, topleft.y, size.width(), size.height());
   GetWidget()->SetBounds(bounds);
+  status_changed_ = true;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ui/views/collected_cookies_win.h b/chrome/browser/ui/views/collected_cookies_win.h
index a578d45..8e6e61b 100644
--- a/chrome/browser/ui/views/collected_cookies_win.h
+++ b/chrome/browser/ui/views/collected_cookies_win.h
@@ -106,6 +106,8 @@
 
   InfobarView* infobar_;
 
+  bool status_changed_;
+
   DISALLOW_COPY_AND_ASSIGN(CollectedCookiesWin);
 };
 
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 8e63d6e..5c13b5e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2472,6 +2472,8 @@
         'browser/ui/cocoa/wrench_menu/wrench_menu_button_cell.mm',
         'browser/ui/cocoa/wrench_menu/wrench_menu_controller.h',
         'browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm',
+        'browser/ui/collected_cookies_infobar_delegate.h',
+        'browser/ui/collected_cookies_infobar_delegate.cc',
         'browser/ui/crypto_module_password_dialog.h',
         'browser/ui/crypto_module_password_dialog_nss.cc',
         'browser/ui/crypto_module_password_dialog_openssl.cc',