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

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

Issue 10554010: Remove BrowserList::GetLastActive usage from WebUI pages. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 8 years, 6 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"
11 #include "chrome/browser/certificate_viewer.h" 11 #include "chrome/browser/certificate_viewer.h"
12 #include "chrome/browser/page_info_model.h" 12 #include "chrome/browser/page_info_model.h"
13 #include "chrome/browser/page_info_model_observer.h" 13 #include "chrome/browser/page_info_model_observer.h"
14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser_finder.h" 15 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" 16 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 17 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
17 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 18 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
18 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" 19 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
19 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 20 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
20 #include "chrome/browser/ui/gtk/gtk_util.h" 21 #include "chrome/browser/ui/gtk/gtk_util.h"
21 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" 22 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
24 #include "content/public/browser/web_contents.h"
23 #include "content/public/common/ssl_status.h" 25 #include "content/public/common/ssl_status.h"
24 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
25 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
26 #include "grit/locale_settings.h" 28 #include "grit/locale_settings.h"
27 #include "ui/base/gtk/gtk_hig_constants.h" 29 #include "ui/base/gtk/gtk_hig_constants.h"
28 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
29 31
30 using content::OpenURLParams; 32 using content::OpenURLParams;
31
32 using content::SSLStatus; 33 using content::SSLStatus;
34 using content::WebContents;
33 35
34 namespace { 36 namespace {
35 37
36 class PageInfoBubbleGtk : public PageInfoModelObserver, 38 class PageInfoBubbleGtk : public PageInfoModelObserver,
37 public BubbleDelegateGtk { 39 public BubbleDelegateGtk {
38 public: 40 public:
39 PageInfoBubbleGtk(gfx::NativeWindow parent, 41 PageInfoBubbleGtk(gfx::NativeWindow parent,
40 Profile* profile, 42 WebContents* web_contents,
41 const GURL& url, 43 const GURL& url,
42 const SSLStatus& ssl, 44 const SSLStatus& ssl,
43 bool show_history, 45 bool show_history,
44 content::PageNavigator* navigator); 46 content::PageNavigator* navigator);
45 virtual ~PageInfoBubbleGtk(); 47 virtual ~PageInfoBubbleGtk();
46 48
47 // PageInfoModelObserver implementation. 49 // PageInfoModelObserver implementation.
48 virtual void OnPageInfoModelChanged() OVERRIDE; 50 virtual void OnPageInfoModelChanged() OVERRIDE;
49 51
50 // BubbleDelegateGtk implementation. 52 // BubbleDelegateGtk implementation.
(...skipping 26 matching lines...) Expand all
77 GtkWidget* contents_; 79 GtkWidget* contents_;
78 80
79 // The widget relative to which we are positioned. 81 // The widget relative to which we are positioned.
80 GtkWidget* anchor_; 82 GtkWidget* anchor_;
81 83
82 // Provides colors and stuff. 84 // Provides colors and stuff.
83 GtkThemeService* theme_service_; 85 GtkThemeService* theme_service_;
84 86
85 BubbleGtk* bubble_; 87 BubbleGtk* bubble_;
86 88
87 Profile* profile_; 89 WebContents* web_contents_;
88 90
89 // Used for loading pages. 91 // Used for loading pages.
90 content::PageNavigator* navigator_; 92 content::PageNavigator* navigator_;
91 93
92 DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleGtk); 94 DISALLOW_COPY_AND_ASSIGN(PageInfoBubbleGtk);
93 }; 95 };
94 96
95 PageInfoBubbleGtk::PageInfoBubbleGtk(gfx::NativeWindow parent, 97 PageInfoBubbleGtk::PageInfoBubbleGtk(gfx::NativeWindow parent,
96 Profile* profile, 98 WebContents* web_contents,
97 const GURL& url, 99 const GURL& url,
98 const SSLStatus& ssl, 100 const SSLStatus& ssl,
99 bool show_history, 101 bool show_history,
100 content::PageNavigator* navigator) 102 content::PageNavigator* navigator)
101 : ALLOW_THIS_IN_INITIALIZER_LIST(model_(profile, url, ssl, 103 : ALLOW_THIS_IN_INITIALIZER_LIST(model_(
102 show_history, this)), 104 Profile::FromBrowserContext(web_contents->GetBrowserContext()), url,
105 ssl, show_history, this)),
103 url_(url), 106 url_(url),
104 cert_id_(ssl.cert_id), 107 cert_id_(ssl.cert_id),
105 parent_(parent), 108 parent_(parent),
106 contents_(NULL), 109 contents_(NULL),
107 theme_service_(GtkThemeService::GetFrom(profile)), 110 theme_service_(GtkThemeService::GetFrom(
108 profile_(profile), 111 Profile::FromBrowserContext(web_contents->GetBrowserContext()))),
112 web_contents_(web_contents),
109 navigator_(navigator) { 113 navigator_(navigator) {
110 BrowserWindowGtk* browser_window = 114 BrowserWindowGtk* browser_window =
111 BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent); 115 BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent);
112 116
113 anchor_ = browser_window-> 117 anchor_ = browser_window->
114 GetToolbar()->GetLocationBarView()->location_icon_widget(); 118 GetToolbar()->GetLocationBarView()->location_icon_widget();
115 119
116 InitContents(); 120 InitContents();
117 121
118 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ? 122 BubbleGtk::ArrowLocationGtk arrow_location = base::i18n::IsRTL() ?
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 FALSE, FALSE, 0); 226 FALSE, FALSE, 0);
223 gtk_box_pack_start(GTK_BOX(vbox), cert_link_hbox, FALSE, FALSE, 0); 227 gtk_box_pack_start(GTK_BOX(vbox), cert_link_hbox, FALSE, FALSE, 0);
224 g_signal_connect(view_cert_link, "clicked", 228 g_signal_connect(view_cert_link, "clicked",
225 G_CALLBACK(OnViewCertLinkClickedThunk), this); 229 G_CALLBACK(OnViewCertLinkClickedThunk), this);
226 } 230 }
227 231
228 return section_box; 232 return section_box;
229 } 233 }
230 234
231 void PageInfoBubbleGtk::OnViewCertLinkClicked(GtkWidget* widget) { 235 void PageInfoBubbleGtk::OnViewCertLinkClicked(GtkWidget* widget) {
232 ShowCertificateViewerByID(GTK_WINDOW(parent_), cert_id_); 236 ShowCertificateViewerByID(web_contents_, GTK_WINDOW(parent_), cert_id_);
233 bubble_->Close(); 237 bubble_->Close();
234 } 238 }
235 239
236 void PageInfoBubbleGtk::OnHelpLinkClicked(GtkWidget* widget) { 240 void PageInfoBubbleGtk::OnHelpLinkClicked(GtkWidget* widget) {
237 navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL), 241 navigator_->OpenURL(OpenURLParams(GURL(chrome::kPageInfoHelpCenterURL),
238 content::Referrer(), 242 content::Referrer(),
239 NEW_FOREGROUND_TAB, 243 NEW_FOREGROUND_TAB,
240 content::PAGE_TRANSITION_LINK, 244 content::PAGE_TRANSITION_LINK,
241 false)); 245 false));
242 bubble_->Close(); 246 bubble_->Close();
243 } 247 }
244 248
245 } // namespace 249 } // namespace
246 250
247 namespace browser { 251 namespace browser {
248 252
249 void ShowPageInfoBubble(gfx::NativeWindow parent, 253 void ShowPageInfoBubble(gfx::NativeWindow parent,
250 Profile* profile, 254 WebContents* web_contents,
251 const GURL& url, 255 const GURL& url,
252 const SSLStatus& ssl, 256 const SSLStatus& ssl,
253 bool show_history, 257 bool show_history,
254 content::PageNavigator* navigator) { 258 content::PageNavigator* navigator) {
255 new PageInfoBubbleGtk(parent, profile, url, ssl, show_history, navigator); 259 new PageInfoBubbleGtk(
260 parent, web_contents, url, ssl, show_history, navigator);
256 } 261 }
257 262
258 } // namespace browser 263 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/certificate_viewer_gtk.cc ('k') | chrome/browser/ui/gtk/ssl_client_certificate_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698