diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 16:19:34 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 16:19:34 +0000 |
commit | 77a91c7f104222394a9b942cb1623b8a7dc07163 (patch) | |
tree | 5789fc71dab20cf0710bc34b0c2aca6f08f1581b /chrome/browser/tab_contents | |
parent | 01b3b9d5148f9b2934d33e5069ae916589179059 (diff) | |
download | chromium_src-77a91c7f104222394a9b942cb1623b8a7dc07163.zip chromium_src-77a91c7f104222394a9b942cb1623b8a7dc07163.tar.gz chromium_src-77a91c7f104222394a9b942cb1623b8a7dc07163.tar.bz2 |
Create chrome/browser/api directory. Move infobar delegates used by Autofill to the directory.
Also, consolidate infobar delegate interfaces under infobars/ rather than some under infobars/ and some under tab_contents/, as the ones under tab_contents/ were not coupled with tab_contents/ in any way.
Remove feedback/proto/extension.pb.h from Autofill's DEPS file simply by dropping the include, it was not being used.
BUG=140037,138280
Review URL: https://chromiumcodereview.appspot.com/10843071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
9 files changed, 2 insertions, 429 deletions
diff --git a/chrome/browser/tab_contents/confirm_infobar_delegate.cc b/chrome/browser/tab_contents/confirm_infobar_delegate.cc deleted file mode 100644 index 226bd64..0000000 --- a/chrome/browser/tab_contents/confirm_infobar_delegate.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2012 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/confirm_infobar_delegate.h" - -#include "content/public/browser/navigation_details.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -InfoBarDelegate::InfoBarAutomationType - ConfirmInfoBarDelegate::GetInfoBarAutomationType() const { - return CONFIRM_INFOBAR; -} - -int ConfirmInfoBarDelegate::GetButtons() const { - return BUTTON_OK | BUTTON_CANCEL; -} - -string16 ConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const { - return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL); -} - -bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const { - return false; -} - -bool ConfirmInfoBarDelegate::Accept() { - return true; -} - -bool ConfirmInfoBarDelegate::Cancel() { - return true; -} - -string16 ConfirmInfoBarDelegate::GetLinkText() const { - return string16(); -} - -bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { - return true; -} - -ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(InfoBarTabHelper* infobar_helper) - : InfoBarDelegate(infobar_helper) { -} - -ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() { -} - -bool ConfirmInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { - ConfirmInfoBarDelegate* confirm_delegate = - delegate->AsConfirmInfoBarDelegate(); - return confirm_delegate && - (confirm_delegate->GetMessageText() == GetMessageText()); -} - -bool ConfirmInfoBarDelegate::ShouldExpireInternal( - const content::LoadCommittedDetails& details) const { - return !details.did_replace_entry && - InfoBarDelegate::ShouldExpireInternal(details); -} - -ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() { - return this; -} diff --git a/chrome/browser/tab_contents/confirm_infobar_delegate.h b/chrome/browser/tab_contents/confirm_infobar_delegate.h deleted file mode 100644 index cf95bcc..0000000 --- a/chrome/browser/tab_contents/confirm_infobar_delegate.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2012 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_TAB_CONTENTS_CONFIRM_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_TAB_CONTENTS_CONFIRM_INFOBAR_DELEGATE_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/string16.h" -#include "chrome/browser/infobars/infobar_delegate.h" - -// An interface derived from InfoBarDelegate implemented by objects wishing to -// control a ConfirmInfoBar. -class ConfirmInfoBarDelegate : public InfoBarDelegate { - public: - enum InfoBarButton { - BUTTON_NONE = 0, - BUTTON_OK = 1 << 0, - BUTTON_CANCEL = 1 << 1, - }; - - // Returns the InfoBar type to be displayed for the InfoBar. - virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; - - // Returns the message string to be displayed for the InfoBar. - virtual string16 GetMessageText() const = 0; - - // Return the buttons to be shown for this InfoBar. - virtual int GetButtons() const; - - // Return the label for the specified button. The default implementation - // returns "OK" for the OK button and "Cancel" for the Cancel button. - virtual string16 GetButtonLabel(InfoBarButton button) const; - - // Return whether or not the specified button needs elevation. - virtual bool NeedElevation(InfoBarButton button) const; - - // Called when the OK button is pressed. If this function returns true, the - // infobar is then immediately closed. Subclasses MUST NOT return true if in - // handling this call something triggers the infobar to begin closing. - virtual bool Accept(); - - // Called when the Cancel button is pressed. If this function returns true, - // the infobar is then immediately closed. Subclasses MUST NOT return true if - // in handling this call something triggers the infobar to begin closing. - virtual bool Cancel(); - - // Returns the text of the link to be displayed, if any. Otherwise returns - // and empty string. - virtual string16 GetLinkText() const; - - // Called when the Link (if any) is clicked. The |disposition| specifies how - // the resulting document should be loaded (based on the event flags present - // when the link was clicked). If this function returns true, the infobar is - // then immediately closed. Subclasses MUST NOT return true if in handling - // this call something triggers the infobar to begin closing. - virtual bool LinkClicked(WindowOpenDisposition disposition); - - protected: - explicit ConfirmInfoBarDelegate(InfoBarTabHelper* infobar_helper); - virtual ~ConfirmInfoBarDelegate(); - - virtual bool ShouldExpireInternal( - const content::LoadCommittedDetails& details) const OVERRIDE; - - private: - // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; - virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; - virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate); -}; - -#endif // CHROME_BROWSER_TAB_CONTENTS_CONFIRM_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc b/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc deleted file mode 100644 index 8f82474..0000000 --- a/chrome/browser/tab_contents/insecure_content_infobar_delegate.cc +++ /dev/null @@ -1,90 +0,0 @@ -// 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/insecure_content_infobar_delegate.h" - -#include "base/metrics/histogram.h" -#include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" -#include "chrome/common/render_messages.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/page_transition_types.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -using content::OpenURLParams; - -InsecureContentInfoBarDelegate::InsecureContentInfoBarDelegate( - InfoBarTabHelper* infobar_helper, - InfoBarType type) - : ConfirmInfoBarDelegate(infobar_helper), - type_(type) { - UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", - (type_ == DISPLAY) ? DISPLAY_INFOBAR_SHOWN : RUN_INFOBAR_SHOWN, - NUM_EVENTS); -} - -InsecureContentInfoBarDelegate::~InsecureContentInfoBarDelegate() { -} - -void InsecureContentInfoBarDelegate::InfoBarDismissed() { - UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", - (type_ == DISPLAY) ? DISPLAY_INFOBAR_DISMISSED : RUN_INFOBAR_DISMISSED, - NUM_EVENTS); - ConfirmInfoBarDelegate::InfoBarDismissed(); -} - -InsecureContentInfoBarDelegate* - InsecureContentInfoBarDelegate::AsInsecureContentInfoBarDelegate() { - return this; -} - -string16 InsecureContentInfoBarDelegate::GetMessageText() const { - return l10n_util::GetStringUTF16(IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT); -} - -string16 InsecureContentInfoBarDelegate::GetButtonLabel( - InfoBarButton button) const { - return l10n_util::GetStringUTF16(button == BUTTON_OK ? - IDS_BLOCK_INSECURE_CONTENT_BUTTON : IDS_ALLOW_INSECURE_CONTENT_BUTTON); -} - -// OK button is labelled "don't load". It triggers Accept(), but really -// means stay secure, so do nothing but count the event and dismiss. -bool InsecureContentInfoBarDelegate::Accept() { - UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", - (type_ == DISPLAY) ? DISPLAY_USER_DID_NOT_LOAD : RUN_USER_DID_NOT_LOAD, - NUM_EVENTS); - return true; -} - - -// Cancel button is labelled "load anyways". It triggers Cancel(), but really -// means become insecure, so do the work of reloading the page. -bool InsecureContentInfoBarDelegate::Cancel() { - UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", - (type_ == DISPLAY) ? DISPLAY_USER_OVERRIDE : RUN_USER_OVERRIDE, - NUM_EVENTS); - - int32 routing_id = owner()->routing_id(); - owner()->Send((type_ == DISPLAY) ? static_cast<IPC::Message*>( - new ChromeViewMsg_SetAllowDisplayingInsecureContent(routing_id, true)) : - new ChromeViewMsg_SetAllowRunningInsecureContent(routing_id, true)); - return true; -} - -string16 InsecureContentInfoBarDelegate::GetLinkText() const { - return l10n_util::GetStringUTF16(IDS_LEARN_MORE); -} - -bool InsecureContentInfoBarDelegate::LinkClicked( - WindowOpenDisposition disposition) { - owner()->web_contents()->OpenURL(OpenURLParams( - google_util::AppendGoogleLocaleParam(GURL( - "https://www.google.com/support/chrome/bin/answer.py?answer=1342714")), - content::Referrer(), - (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, - content::PAGE_TRANSITION_LINK, false)); - return false; -} diff --git a/chrome/browser/tab_contents/insecure_content_infobar_delegate.h b/chrome/browser/tab_contents/insecure_content_infobar_delegate.h deleted file mode 100644 index 0e7557b..0000000 --- a/chrome/browser/tab_contents/insecure_content_infobar_delegate.h +++ /dev/null @@ -1,55 +0,0 @@ -// 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_TAB_CONTENTS_INSECURE_CONTENT_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_TAB_CONTENTS_INSECURE_CONTENT_INFOBAR_DELEGATE_H_ - -#include "chrome/browser/tab_contents/confirm_infobar_delegate.h" - -// Base class for delegates that show warnings on HTTPS pages which try to -// display or run insecure content. -class InsecureContentInfoBarDelegate : public ConfirmInfoBarDelegate { - public: - enum InfoBarType { - DISPLAY, // Shown when "inactive" content (e.g. images) has been blocked. - RUN, // Shown when "active" content (e.g. script) has been blocked. - }; - - InsecureContentInfoBarDelegate(InfoBarTabHelper* infobar_helper, - InfoBarType type); - virtual ~InsecureContentInfoBarDelegate(); - - InfoBarType type() const { return type_; } - - private: - enum HistogramEvents { - DISPLAY_INFOBAR_SHOWN = 0, // Infobar was displayed. - DISPLAY_USER_OVERRIDE, // User clicked allow anyway button. - DISPLAY_USER_DID_NOT_LOAD, // User clicked the don't load button. - DISPLAY_INFOBAR_DISMISSED, // User clicked close button. - RUN_INFOBAR_SHOWN, - RUN_USER_OVERRIDE, - RUN_USER_DID_NOT_LOAD, - RUN_INFOBAR_DISMISSED, - NUM_EVENTS - }; - - // ConfirmInfoBarDelegate: - virtual void InfoBarDismissed() OVERRIDE; - virtual InsecureContentInfoBarDelegate* - AsInsecureContentInfoBarDelegate() OVERRIDE; - virtual string16 GetMessageText() const OVERRIDE; - virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; - virtual bool Accept() OVERRIDE; - virtual bool Cancel() OVERRIDE; - virtual string16 GetLinkText() const OVERRIDE; - virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - - InfoBarType type_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(InsecureContentInfoBarDelegate); -}; - -#endif // CHROME_BROWSER_TAB_CONTENTS_INSECURE_CONTENT_INFOBAR_DELEGATE_H_ - diff --git a/chrome/browser/tab_contents/link_infobar_delegate.cc b/chrome/browser/tab_contents/link_infobar_delegate.cc deleted file mode 100644 index 02c2c2e..0000000 --- a/chrome/browser/tab_contents/link_infobar_delegate.cc +++ /dev/null @@ -1,20 +0,0 @@ -// 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/link_infobar_delegate.h" - -bool LinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { - return true; -} - -LinkInfoBarDelegate::LinkInfoBarDelegate(InfoBarTabHelper* infobar_helper) - : InfoBarDelegate(infobar_helper) { -} - -LinkInfoBarDelegate::~LinkInfoBarDelegate() { -} - -LinkInfoBarDelegate* LinkInfoBarDelegate::AsLinkInfoBarDelegate() { - return this; -} diff --git a/chrome/browser/tab_contents/link_infobar_delegate.h b/chrome/browser/tab_contents/link_infobar_delegate.h deleted file mode 100644 index ab7cbf6..0000000 --- a/chrome/browser/tab_contents/link_infobar_delegate.h +++ /dev/null @@ -1,45 +0,0 @@ -// 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_TAB_CONTENTS_LINK_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_TAB_CONTENTS_LINK_INFOBAR_DELEGATE_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/string16.h" -#include "chrome/browser/infobars/infobar_delegate.h" - -class InfoBarTabHelper; - -// An interface derived from InfoBarDelegate implemented by objects wishing to -// control a LinkInfoBar. -class LinkInfoBarDelegate : public InfoBarDelegate { - public: - // Returns the message string to be displayed in the InfoBar. |link_offset| - // is the position where the link should be inserted. - virtual string16 GetMessageTextWithOffset(size_t* link_offset) const = 0; - - // Returns the text of the link to be displayed. - virtual string16 GetLinkText() const = 0; - - // 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). If this function returns true, the infobar is then - // immediately closed. Subclasses MUST NOT return true if in handling this - // call something triggers the infobar to begin closing. - virtual bool LinkClicked(WindowOpenDisposition disposition); - - protected: - explicit LinkInfoBarDelegate(InfoBarTabHelper* infobar_helper); - virtual ~LinkInfoBarDelegate(); - - private: - // InfoBarDelegate: - virtual InfoBar* CreateInfoBar(InfoBarTabHelper* infobar_helper) OVERRIDE; - virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate() OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(LinkInfoBarDelegate); -}; - -#endif // CHROME_BROWSER_TAB_CONTENTS_LINK_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/tab_contents/simple_alert_infobar_delegate.cc b/chrome/browser/tab_contents/simple_alert_infobar_delegate.cc deleted file mode 100644 index bc7008e..0000000 --- a/chrome/browser/tab_contents/simple_alert_infobar_delegate.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012 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/simple_alert_infobar_delegate.h" - -#include "third_party/skia/include/core/SkBitmap.h" - -SimpleAlertInfoBarDelegate::SimpleAlertInfoBarDelegate( - InfoBarTabHelper* infobar_helper, - gfx::Image* icon, - const string16& message, - bool auto_expire) - : ConfirmInfoBarDelegate(infobar_helper), - icon_(icon), - message_(message), - auto_expire_(auto_expire) { -} - -SimpleAlertInfoBarDelegate::~SimpleAlertInfoBarDelegate() { -} - -gfx::Image* SimpleAlertInfoBarDelegate::GetIcon() const { - return icon_; -} - -string16 SimpleAlertInfoBarDelegate::GetMessageText() const { - return message_; -} - -int SimpleAlertInfoBarDelegate::GetButtons() const { - return BUTTON_NONE; -} - -bool SimpleAlertInfoBarDelegate::ShouldExpireInternal( - const content::LoadCommittedDetails& details) const { - return auto_expire_ && ConfirmInfoBarDelegate::ShouldExpireInternal(details); -} diff --git a/chrome/browser/tab_contents/simple_alert_infobar_delegate.h b/chrome/browser/tab_contents/simple_alert_infobar_delegate.h deleted file mode 100644 index b025753..0000000 --- a/chrome/browser/tab_contents/simple_alert_infobar_delegate.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2012 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_TAB_CONTENTS_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ -#define CHROME_BROWSER_TAB_CONTENTS_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/string16.h" -#include "chrome/browser/tab_contents/confirm_infobar_delegate.h" - -class SimpleAlertInfoBarDelegate : public ConfirmInfoBarDelegate { - public: - SimpleAlertInfoBarDelegate(InfoBarTabHelper* infobar_helper, - gfx::Image* icon, // May be NULL. - const string16& message, - bool auto_expire); - - private: - virtual ~SimpleAlertInfoBarDelegate(); - - // ConfirmInfoBarDelegate: - virtual gfx::Image* GetIcon() const OVERRIDE; - virtual string16 GetMessageText() const OVERRIDE; - virtual int GetButtons() const OVERRIDE; - virtual bool ShouldExpireInternal( - const content::LoadCommittedDetails& details) const OVERRIDE; - - gfx::Image* icon_; - string16 message_; - bool auto_expire_; // Should it expire automatically on navigation? - - DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate); -}; - -#endif // CHROME_BROWSER_TAB_CONTENTS_SIMPLE_ALERT_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc index 6bbab3f..56d80c4 100644 --- a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc +++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc @@ -12,6 +12,8 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" +#include "chrome/browser/api/infobars/confirm_infobar_delegate.h" +#include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" #include "chrome/browser/certificate_viewer.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/infobars/infobar.h" @@ -19,8 +21,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ssl/ssl_add_cert_handler.h" #include "chrome/browser/ssl_client_certificate_selector.h" -#include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -#include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" |