Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/ui/gtk/page_info_bubble_gtk.cc

Issue 10413061: Make PageInfoBubble not use BrowserList::GetLastActive and instead obtain a navigator at creation t… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <gtk/gtk.h> 5 #include <gtk/gtk.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 22 matching lines...) Expand all
33 33
34 namespace { 34 namespace {
35 35
36 class PageInfoBubbleGtk : public PageInfoModelObserver, 36 class PageInfoBubbleGtk : public PageInfoModelObserver,
37 public BubbleDelegateGtk { 37 public BubbleDelegateGtk {
38 public: 38 public:
39 PageInfoBubbleGtk(gfx::NativeWindow parent, 39 PageInfoBubbleGtk(gfx::NativeWindow parent,
40 Profile* profile, 40 Profile* profile,
41 const GURL& url, 41 const GURL& url,
42 const SSLStatus& ssl, 42 const SSLStatus& ssl,
43 bool show_history); 43 bool show_history,
44 content::PageNavigator* navigator);
44 virtual ~PageInfoBubbleGtk(); 45 virtual ~PageInfoBubbleGtk();
45 46
46 // PageInfoModelObserver implementation. 47 // PageInfoModelObserver implementation.
47 virtual void OnPageInfoModelChanged() OVERRIDE; 48 virtual void OnPageInfoModelChanged() OVERRIDE;
48 49
49 // BubbleDelegateGtk implementation. 50 // BubbleDelegateGtk implementation.
50 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; 51 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;
51 52
52 private: 53 private:
53 // Layouts the different sections retrieved from the model. 54 // Layouts the different sections retrieved from the model.
(...skipping 24 matching lines...) Expand all
78 // The widget relative to which we are positioned. 79 // The widget relative to which we are positioned.
79 GtkWidget* anchor_; 80 GtkWidget* anchor_;
80 81
81 // Provides colors and stuff. 82 // Provides colors and stuff.
82 GtkThemeService* theme_service_; 83 GtkThemeService* theme_service_;
83 84
84 BubbleGtk* bubble_; 85 BubbleGtk* bubble_;
85 86
86 Profile* profile_; 87 Profile* profile_;
87 88
89 // Used for loading pages.
90 content::PageNavigator* navigator_;
91
88 DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleGtk); 92 DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleGtk);
89 }; 93 };
90 94
91 PageInfoBubbleGtk::PageInfoBubbleGtk(gfx::NativeWindow parent, 95 PageInfoBubbleGtk::PageInfoBubbleGtk(gfx::NativeWindow parent,
92 Profile* profile, 96 Profile* profile,
93 const GURL& url, 97 const GURL& url,
94 const SSLStatus& ssl, 98 const SSLStatus& ssl,
95 bool show_history) 99 bool show_history,
100 content::PageNavigator* navigator)
96 : ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, 101 : ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl,
97 show_history, this)), 102 show_history, this)),
98 url_(url), 103 url_(url),
99 cert_id_(ssl.cert_id), 104 cert_id_(ssl.cert_id),
100 parent_(parent), 105 parent_(parent),
101 contents_(NULL), 106 contents_(NULL),
102 theme_service_(GtkThemeService::GetFrom(profile)), 107 theme_service_(GtkThemeService::GetFrom(profile)),
103 profile_(profile) { 108 profile_(profile),
109 navigator_(navigator) {
104 BrowserWindowGtk* browser_window = 110 BrowserWindowGtk* browser_window =
105 BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent); 111 BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent);
106 112
107 anchor_ = browser_window-> 113 anchor_ = browser_window->
108 GetToolbar()->GetLocationBarView()->location_icon_widget(); 114 GetToolbar()->GetLocationBarView()->location_icon_widget();
109 115
110 InitContents(); 116 InitContents();
111 117
112 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ? 118 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ?
113 BubbleGtk::ARROW_LOCATION_TOP_RIGHT : 119 BubbleGtk::ARROW_LOCATION_TOP_RIGHT :
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 226
221 return section_box; 227 return section_box;
222 } 228 }
223 229
224 void PageInfoBubbleGtk::OnViewCertLinkClicked(GtkWidget* widget) { 230 void PageInfoBubbleGtk::OnViewCertLinkClicked(GtkWidget* widget) {
225 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_); 231 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_);
226 bubble_->Close(); 232 bubble_->Close();
227 } 233 }
228 234
229 void PageInfoBubbleGtk::OnHelpLinkClicked(GtkWidget* widget) { 235 void PageInfoBubbleGtk::OnHelpLinkClicked(GtkWidget* widget) {
230 Browser* browser = browser::FindLastActiveWithProfile(profile_); 236 navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL),
231 browser->OpenURL(OpenURLParams( 237 content::Referrer(),
232 GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), 238 NEW_FOREGROUND_TAB,
233 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); 239 content::PAGE_TRANSITION_LINK,
240 false));
234 bubble_->Close(); 241 bubble_->Close();
235 } 242 }
236 243
237 } // namespace 244 } // namespace
238 245
239 namespace browser { 246 namespace browser {
240 247
241 void ShowPageInfoBubble(gfx::NativeWindow parent, 248 void ShowPageInfoBubble(gfx::NativeWindow parent,
242 Profile* profile, 249 Profile* profile,
243 const GURL& url, 250 const GURL& url,
244 const SSLStatus& ssl, 251 const SSLStatus& ssl,
245 bool show_history) { 252 bool show_history,
246 new PageInfoBubbleGtk(parent, profile, url, ssl, show_history); 253 content::PageNavigator* navigator) {
254 new PageInfoBubbleGtk(parent, profile, url, ssl, show_history, navigator);
247 } 255 }
248 256
249 } // namespace browser 257 } // namespace browser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698