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