summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-24 03:32:52 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-24 03:32:52 +0000
commitd7267e2272240ec3367db98b996d0a481827021c (patch)
treeb82e201a831704d32234ade8d9ec243b2ca8ca88
parent244e00b71216d60f691500c849b5bd1ab33d250d (diff)
downloadchromium_src-d7267e2272240ec3367db98b996d0a481827021c.zip
chromium_src-d7267e2272240ec3367db98b996d0a481827021c.tar.gz
chromium_src-d7267e2272240ec3367db98b996d0a481827021c.tar.bz2
Make PageInfoBubble not use BrowserList::GetLastActive and instead obtain a navigator at creation time.
http://crbug.com/129187 TEST=none Review URL: https://chromiumcodereview.appspot.com/10413061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138724 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/simple_web_view_dialog.cc11
-rw-r--r--chrome/browser/chromeos/login/simple_web_view_dialog.h6
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm3
-rw-r--r--chrome/browser/ui/cocoa/page_info_bubble_controller.h11
-rw-r--r--chrome/browser/ui/cocoa/page_info_bubble_controller.mm21
-rw-r--r--chrome/browser/ui/cocoa/page_info_bubble_controller_unittest.mm8
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc3
-rw-r--r--chrome/browser/ui/gtk/page_info_bubble_gtk.cc26
-rw-r--r--chrome/browser/ui/page_info_bubble.h4
-rw-r--r--chrome/browser/ui/views/browser_dialogs.h4
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc2
-rw-r--r--chrome/browser/ui/views/page_info_bubble_view.cc26
-rw-r--r--chrome/browser/ui/views/page_info_bubble_view.h7
13 files changed, 95 insertions, 37 deletions
diff --git a/chrome/browser/chromeos/login/simple_web_view_dialog.cc b/chrome/browser/chromeos/login/simple_web_view_dialog.cc
index 7058f59..8f6f35e 100644
--- a/chrome/browser/chromeos/login/simple_web_view_dialog.cc
+++ b/chrome/browser/chromeos/login/simple_web_view_dialog.cc
@@ -254,6 +254,13 @@ void SimpleWebViewDialog::NavigationStateChanged(
}
}
+content::WebContents* SimpleWebViewDialog::OpenURL(
+ const content::OpenURLParams& params) {
+ // As there are no Browsers right now, this could not actually ever work.
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
void SimpleWebViewDialog::LoadingStateChanged(WebContents* source) {
bool is_loading = source->IsLoading();
UpdateReload(is_loading, false);
@@ -286,7 +293,9 @@ void SimpleWebViewDialog::ShowPageInfo(content::WebContents* web_contents,
new PageInfoBubbleView(
location_bar_->location_icon_view(),
location_bar_->profile(),
- url, ssl, true);
+ url, ssl,
+ true,
+ this);
page_info_bubble->set_parent_window(
ash::Shell::GetInstance()->GetContainer(
ash::internal::kShellWindowId_LockSystemModalContainer));
diff --git a/chrome/browser/chromeos/login/simple_web_view_dialog.h b/chrome/browser/chromeos/login/simple_web_view_dialog.h
index 96b4d43..60a0d55 100644
--- a/chrome/browser/chromeos/login/simple_web_view_dialog.h
+++ b/chrome/browser/chromeos/login/simple_web_view_dialog.h
@@ -11,6 +11,7 @@
#include "chrome/browser/command_updater.h"
#include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
+#include "content/public/browser/page_navigator.h"
#include "content/public/browser/web_contents_delegate.h"
#include "googleurl/src/gurl.h"
#include "ui/views/controls/button/image_button.h"
@@ -40,6 +41,7 @@ class SimpleWebViewDialog : public views::ButtonListener,
public LocationBarView::Delegate,
public ToolbarModelDelegate,
public CommandUpdater::CommandUpdaterDelegate,
+ public content::PageNavigator,
public content::WebContentsDelegate {
public:
explicit SimpleWebViewDialog(Profile* profile);
@@ -59,6 +61,10 @@ class SimpleWebViewDialog : public views::ButtonListener,
virtual void ButtonPressed(views::Button* sender,
const views::Event& event) OVERRIDE;
+ // Implements content::PageNavigator:
+ virtual content::WebContents* OpenURL(
+ const content::OpenURLParams& params) OVERRIDE;
+
// Implements content::WebContentsDelegate:
virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index c0bf3ce..344aadc 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -501,7 +501,8 @@ void BrowserWindowCocoa::ShowPageInfo(Profile* profile,
const GURL& url,
const SSLStatus& ssl,
bool show_history) {
- browser::ShowPageInfoBubble(window(), profile, url, ssl, show_history);
+ browser::ShowPageInfoBubble(window(), profile, url, ssl, show_history,
+ browser_);
}
void BrowserWindowCocoa::ShowWebsiteSettings(
diff --git a/chrome/browser/ui/cocoa/page_info_bubble_controller.h b/chrome/browser/ui/cocoa/page_info_bubble_controller.h
index 6af903b..42bfe21 100644
--- a/chrome/browser/ui/cocoa/page_info_bubble_controller.h
+++ b/chrome/browser/ui/cocoa/page_info_bubble_controller.h
@@ -11,6 +11,10 @@
class PageInfoModel;
class PageInfoModelObserver;
+namespace content {
+class PageNavigator;
+}
+
// This NSWindowController subclass manages the InfoBubbleWindow and view that
// are displayed when the user clicks the security lock icon.
@interface PageInfoBubbleController : BaseBubbleController {
@@ -23,6 +27,9 @@ class PageInfoModelObserver;
// The certificate ID for the page, 0 if the page is not over HTTPS.
int certID_;
+
+ // Used for loading pages.
+ content::PageNavigator* navigator_;
}
@property(nonatomic, assign) int certID;
@@ -33,7 +40,9 @@ class PageInfoModelObserver;
// cannot be nil.
- (id)initWithPageInfoModel:(PageInfoModel*)model
modelObserver:(PageInfoModelObserver*)bridge
- parentWindow:(NSWindow*)parentWindow;
+ parentWindow:(NSWindow*)parentWindow
+ navigator:(content::PageNavigator*)navigator;
+
// Shows the certificate display window. Note that this will implicitly close
// the bubble because the certificate window will become key. The certificate
diff --git a/chrome/browser/ui/cocoa/page_info_bubble_controller.mm b/chrome/browser/ui/cocoa/page_info_bubble_controller.mm
index 3771869..24f6493 100644
--- a/chrome/browser/ui/cocoa/page_info_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/page_info_bubble_controller.mm
@@ -21,6 +21,7 @@
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/cert_store.h"
+#include "content/public/browser/page_navigator.h"
#include "content/public/common/ssl_status.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -158,14 +159,16 @@ void ShowPageInfoBubble(gfx::NativeWindow parent,
Profile* profile,
const GURL& url,
const SSLStatus& ssl,
- bool show_history) {
+ bool show_history,
+ content::PageNavigator* navigator) {
PageInfoModelBubbleBridge* bridge = new PageInfoModelBubbleBridge();
PageInfoModel* model =
new PageInfoModel(profile, url, ssl, show_history, bridge);
PageInfoBubbleController* controller =
[[PageInfoBubbleController alloc] initWithPageInfoModel:model
modelObserver:bridge
- parentWindow:parent];
+ parentWindow:parent
+ navigator:navigator];
bridge->set_controller(controller);
[controller setCertID:ssl.cert_id];
[controller showWindow:nil];
@@ -179,7 +182,8 @@ void ShowPageInfoBubble(gfx::NativeWindow parent,
- (id)initWithPageInfoModel:(PageInfoModel*)model
modelObserver:(PageInfoModelObserver*)bridge
- parentWindow:(NSWindow*)parentWindow {
+ parentWindow:(NSWindow*)parentWindow
+ navigator:(content::PageNavigator*)navigator {
DCHECK(parentWindow);
// Use an arbitrary height because it will be changed by the bridge.
@@ -196,6 +200,7 @@ void ShowPageInfoBubble(gfx::NativeWindow parent,
anchoredAt:NSZeroPoint])) {
model_.reset(model);
bridge_.reset(bridge);
+ navigator_ = navigator;
[[self bubble] setArrowLocation:info_bubble::kTopLeft];
[self performLayout];
}
@@ -212,11 +217,11 @@ void ShowPageInfoBubble(gfx::NativeWindow parent,
}
- (IBAction)showHelpPage:(id)sender {
- Browser* browser = BrowserList::GetLastActive();
- OpenURLParams params(
- GURL(chrome::kPageInfoHelpCenterURL), Referrer(), NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_LINK, false);
- browser->OpenURL(params);
+ navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL),
+ Referrer(),
+ NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_LINK,
+ false));
}
// This will create the subviews for the page info window. The general layout
diff --git a/chrome/browser/ui/cocoa/page_info_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/page_info_bubble_controller_unittest.mm
index e3b42c9..8e05e4b 100644
--- a/chrome/browser/ui/cocoa/page_info_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/page_info_bubble_controller_unittest.mm
@@ -51,9 +51,11 @@ class PageInfoBubbleControllerTest : public CocoaTest {
void CreateBubble() {
// The controller cleans up after itself when the window closes.
controller_ =
- [[PageInfoBubbleController alloc] initWithPageInfoModel:model_
- modelObserver:NULL
- parentWindow:test_window()];
+ [[PageInfoBubbleController alloc]
+ initWithPageInfoModel:model_
+ modelObserver:NULL
+ parentWindow:test_window()
+ navigator:NULL];
window_ = [controller_ window];
[controller_ showWindow:nil];
}
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index b355ad1..fba3756 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -1131,7 +1131,8 @@ void BrowserWindowGtk::ShowPageInfo(Profile* profile,
const GURL& url,
const SSLStatus& ssl,
bool show_history) {
- browser::ShowPageInfoBubble(window_, profile, url, ssl, show_history);
+ browser::ShowPageInfoBubble(window_, profile, url, ssl, show_history,
+ browser_.get());
}
void BrowserWindowGtk::ShowWebsiteSettings(
diff --git a/chrome/browser/ui/gtk/page_info_bubble_gtk.cc b/chrome/browser/ui/gtk/page_info_bubble_gtk.cc
index 6460c16..7f748ec 100644
--- a/chrome/browser/ui/gtk/page_info_bubble_gtk.cc
+++ b/chrome/browser/ui/gtk/page_info_bubble_gtk.cc
@@ -40,7 +40,8 @@ class PageInfoBubbleGtk : public PageInfoModelObserver,
Profile* profile,
const GURL& url,
const SSLStatus& ssl,
- bool show_history);
+ bool show_history,
+ content::PageNavigator* navigator);
virtual ~PageInfoBubbleGtk();
// PageInfoModelObserver implementation.
@@ -85,6 +86,9 @@ class PageInfoBubbleGtk : public PageInfoModelObserver,
Profile* profile_;
+ // Used for loading pages.
+ content::PageNavigator* navigator_;
+
DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleGtk);
};
@@ -92,7 +96,8 @@ PageInfoBubbleGtk::PageInfoBubbleGtk(gfx::NativeWindow parent,
Profile* profile,
const GURL& url,
const SSLStatus& ssl,
- bool show_history)
+ bool show_history,
+ content::PageNavigator* navigator)
: ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl,
show_history, this)),
url_(url),
@@ -100,7 +105,8 @@ PageInfoBubbleGtk::PageInfoBubbleGtk(gfx::NativeWindow parent,
parent_(parent),
contents_(NULL),
theme_service_(GtkThemeService::GetFrom(profile)),
- profile_(profile) {
+ profile_(profile),
+ navigator_(navigator) {
BrowserWindowGtk* browser_window =
BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent);
@@ -228,10 +234,11 @@ void PageInfoBubbleGtk::OnViewCertLinkClicked(GtkWidget* widget) {
}
void PageInfoBubbleGtk::OnHelpLinkClicked(GtkWidget* widget) {
- Browser* browser = browser::FindLastActiveWithProfile(profile_);
- browser->OpenURL(OpenURLParams(
- GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(),
- NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false));
+ navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL),
+ content::Referrer(),
+ NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_LINK,
+ false));
bubble_->Close();
}
@@ -243,8 +250,9 @@ void ShowPageInfoBubble(gfx::NativeWindow parent,
Profile* profile,
const GURL& url,
const SSLStatus& ssl,
- bool show_history) {
- new PageInfoBubbleGtk(parent, profile, url, ssl, show_history);
+ bool show_history,
+ content::PageNavigator* navigator) {
+ new PageInfoBubbleGtk(parent, profile, url, ssl, show_history, navigator);
}
} // namespace browser
diff --git a/chrome/browser/ui/page_info_bubble.h b/chrome/browser/ui/page_info_bubble.h
index fe23408..dc11f0f 100644
--- a/chrome/browser/ui/page_info_bubble.h
+++ b/chrome/browser/ui/page_info_bubble.h
@@ -12,6 +12,7 @@ class Profile;
class GURL;
namespace content {
+class PageNavigator;
struct SSLStatus;
}
@@ -21,7 +22,8 @@ void ShowPageInfoBubble(gfx::NativeWindow parent,
Profile* profile,
const GURL& url,
const content::SSLStatus& ssl,
- bool show_history);
+ bool show_history,
+ content::PageNavigator* navigator);
} // namespace browser
diff --git a/chrome/browser/ui/views/browser_dialogs.h b/chrome/browser/ui/views/browser_dialogs.h
index 3a0a464..f178371 100644
--- a/chrome/browser/ui/views/browser_dialogs.h
+++ b/chrome/browser/ui/views/browser_dialogs.h
@@ -26,6 +26,7 @@ class TabContentsWrapper;
class TemplateURL;
namespace content {
+class PageNavigator;
struct SSLStatus;
}
@@ -62,7 +63,8 @@ void ShowPageInfoBubble(views::View* anchor_view,
Profile* profile,
const GURL& url,
const content::SSLStatus& ssl,
- bool show_history);
+ bool show_history,
+ content::PageNavigator* navigator);
// Shows the about dialog. See AboutChromeView.
views::Widget* ShowAboutChromeView(gfx::NativeWindow parent,
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 7d5a2ba..6822c7d 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1138,7 +1138,7 @@ void BrowserView::ShowPageInfo(Profile* profile,
const SSLStatus& ssl,
bool show_history) {
browser::ShowPageInfoBubble(GetLocationBarView()->location_icon_view(),
- profile, url, ssl, show_history);
+ profile, url, ssl, show_history, browser_.get());
}
void BrowserView::ShowWebsiteSettings(Profile* profile,
diff --git a/chrome/browser/ui/views/page_info_bubble_view.cc b/chrome/browser/ui/views/page_info_bubble_view.cc
index 86c5c59..5456668 100644
--- a/chrome/browser/ui/views/page_info_bubble_view.cc
+++ b/chrome/browser/ui/views/page_info_bubble_view.cc
@@ -105,14 +105,16 @@ PageInfoBubbleView::PageInfoBubbleView(views::View* anchor_view,
Profile* profile,
const GURL& url,
const SSLStatus& ssl,
- bool show_history)
+ bool show_history,
+ content::PageNavigator* navigator)
: BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl,
show_history, this)),
cert_id_(ssl.cert_id),
help_center_link_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(resize_animation_(this)),
- animation_start_height_(0) {
+ animation_start_height_(0),
+ navigator_(navigator) {
if (cert_id_ > 0) {
scoped_refptr<net::X509Certificate> cert;
@@ -282,11 +284,11 @@ gfx::Rect PageInfoBubbleView::GetAnchorRect() {
}
void PageInfoBubbleView::LinkClicked(views::Link* source, int event_flags) {
- Browser* browser = BrowserList::GetLastActive();
- OpenURLParams params(
- GURL(chrome::kPageInfoHelpCenterURL), Referrer(), NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_LINK, false);
- browser->OpenURL(params);
+ navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL),
+ Referrer(),
+ NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_LINK,
+ false));
// NOTE: The bubble closes automatically on deactivation as the link opens.
}
@@ -452,9 +454,15 @@ void ShowPageInfoBubble(views::View* anchor_view,
Profile* profile,
const GURL& url,
const SSLStatus& ssl,
- bool show_history) {
+ bool show_history,
+ content::PageNavigator* navigator) {
PageInfoBubbleView* page_info_bubble =
- new PageInfoBubbleView(anchor_view, profile, url, ssl, show_history);
+ new PageInfoBubbleView(anchor_view,
+ profile,
+ url,
+ ssl,
+ show_history,
+ navigator);
views::BubbleDelegateView::CreateBubble(page_info_bubble);
page_info_bubble->Show();
}
diff --git a/chrome/browser/ui/views/page_info_bubble_view.h b/chrome/browser/ui/views/page_info_bubble_view.h
index d84d404..12788fc 100644
--- a/chrome/browser/ui/views/page_info_bubble_view.h
+++ b/chrome/browser/ui/views/page_info_bubble_view.h
@@ -14,6 +14,7 @@
#include "ui/views/controls/link_listener.h"
namespace content {
+class PageNavigator;
struct SSLStatus;
}
@@ -25,7 +26,8 @@ class PageInfoBubbleView : public views::BubbleDelegateView,
Profile* profile,
const GURL& url,
const content::SSLStatus& ssl,
- bool show_history);
+ bool show_history,
+ content::PageNavigator* navigator);
virtual ~PageInfoBubbleView();
// Show the certificate dialog.
@@ -75,6 +77,9 @@ class PageInfoBubbleView : public views::BubbleDelegateView,
// The height of the info bubble at the start of the resize animation.
int animation_start_height_;
+ // Used for loading pages.
+ content::PageNavigator* navigator_;
+
DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleView);
};