Index: chrome/browser/ui/gtk/location_bar_view_gtk.cc |
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
index be414627b8f49b3fa9ce06b7ddd96d2a082ff54f..bbcd293515a0fc73f39c8909583b7411b7beaf47 100644 |
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
@@ -59,6 +59,7 @@ |
#include "chrome/browser/ui/gtk/rounded_window.h" |
#include "chrome/browser/ui/gtk/view_id_util.h" |
#include "chrome/browser/ui/gtk/zoom_bubble_gtk.h" |
+#include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
#include "chrome/browser/ui/omnibox/location_bar_util.h" |
#include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
@@ -144,12 +145,20 @@ const int kContentSettingImageDisplayTime = 3200; |
// The time, in ms, of the animation (open and close). |
const int kContentSettingImageAnimationTime = 150; |
+// Animation opening time for web intents button. |
+const int kWebIntentsButtonAnimationTime = 1000; |
+ |
// Color of border of content setting area (icon/label). |
const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66); |
// Colors for the background gradient. |
const GdkColor kContentSettingTopColor = GDK_COLOR_RGB(0xff, 0xf8, 0xd4); |
const GdkColor kContentSettingBottomColor = GDK_COLOR_RGB(0xff, 0xe6, 0xaf); |
+// Styling for gray button. |
+const GdkColor kGrayBorderColor = GDK_COLOR_RGB(0xa0, 0xa0, 0xa0); |
+const GdkColor kTopColorGray = GDK_COLOR_RGB(0xe5, 0xe5, 0xe5); |
+const GdkColor kBottomColorGray = GDK_COLOR_RGB(0xd0, 0xd0, 0xd0); |
+ |
// If widget is visible, increment the int pointed to by count. |
// Suitible for use with gtk_container_foreach. |
void CountVisibleWidgets(GtkWidget* widget, gpointer count) { |
@@ -302,7 +311,62 @@ void ContentSettingImageViewGtk::BubbleClosing( |
content_setting_bubble_ = NULL; |
} |
+class WebIntentsButtonViewGtk : public LocationBarViewGtk::PageToolViewGtk { |
+ public: |
+ explicit WebIntentsButtonViewGtk(const LocationBarViewGtk* parent) |
+ : LocationBarViewGtk::PageToolViewGtk(parent) { |
+ animation_.SetSlideDuration(kWebIntentsButtonAnimationTime); |
+ } |
+ virtual ~WebIntentsButtonViewGtk() {} |
+ |
+ // PageToolViewGtk |
+ virtual void Update(TabContents* tab_contents) OVERRIDE; |
+ |
+ private: |
+ // PageToolViewGtk |
+ virtual GdkColor button_border_color() const OVERRIDE; |
+ virtual GdkColor gradient_top_color() const OVERRIDE; |
+ virtual GdkColor gradient_bottom_color() const OVERRIDE; |
+ virtual void OnClick(GtkWidget* sender) OVERRIDE; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebIntentsButtonViewGtk); |
+}; |
+ |
+void WebIntentsButtonViewGtk::Update( |
+ TabContents* tab_contents) { |
+ if (!tab_contents || |
+ !tab_contents->web_intent_picker_controller() || |
+ !tab_contents->web_intent_picker_controller()-> |
+ ShowLocationBarPickerTool()) { |
+ gtk_widget_hide(widget()); |
+ return; |
+ } |
+ |
+ gtk_widget_set_tooltip_text(widget(), |
+ l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str()); |
+ gtk_widget_show_all(widget()); |
+ |
+ gtk_label_set_text(GTK_LABEL(label_.get()), |
+ l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str()); |
+ |
+ StartAnimating(); |
+} |
+ |
+void WebIntentsButtonViewGtk::OnClick(GtkWidget* sender) { |
+ LOG(INFO) << "Web Intents button click"; |
Bernhard Bauer
2012/07/31 23:29:15
Nit: Could you make this a DLOG? That way we don't
Greg Billock
2012/08/07 01:12:40
Done.
|
+} |
+ |
+GdkColor WebIntentsButtonViewGtk::button_border_color() const { |
+ return kGrayBorderColor; |
+} |
+ |
+GdkColor WebIntentsButtonViewGtk::gradient_top_color() const { |
+ return kTopColorGray; |
+} |
+GdkColor WebIntentsButtonViewGtk::gradient_bottom_color() const { |
+ return kBottomColorGray; |
+} |
} // namespace |
@@ -324,6 +388,7 @@ LocationBarViewGtk::LocationBarViewGtk(Browser* browser) |
drag_icon_(NULL), |
enable_location_drag_(false), |
security_info_label_(NULL), |
+ web_intents_button_view_(new WebIntentsButtonViewGtk(this)), |
tab_to_search_alignment_(NULL), |
tab_to_search_box_(NULL), |
tab_to_search_full_label_(NULL), |
@@ -356,6 +421,7 @@ LocationBarViewGtk::~LocationBarViewGtk() { |
hbox_.Destroy(); |
content_setting_hbox_.Destroy(); |
page_action_hbox_.Destroy(); |
+ web_intents_hbox_.Destroy(); |
} |
void LocationBarViewGtk::Init(bool popup_window_mode) { |
@@ -511,6 +577,14 @@ void LocationBarViewGtk::Init(bool popup_window_mode) { |
gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), |
FALSE, FALSE, 0); |
+ web_intents_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); |
+ gtk_widget_set_name(web_intents_hbox_.get(), |
+ "chrome-web-intents-hbox"); |
+ gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(), |
+ FALSE, FALSE, 0); |
+ gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()), |
+ web_intents_button_view_->widget(), FALSE, FALSE, 0); |
+ |
// Now that we've created the widget hierarchy, connect to the main |hbox_|'s |
// size-allocate so we can do proper resizing and eliding on |
// |security_info_label_|. |
@@ -642,6 +716,7 @@ void LocationBarViewGtk::Update(const WebContents* contents) { |
UpdateSiteTypeArea(); |
UpdateContentSettingsIcons(); |
UpdatePageActions(); |
+ UpdateWebIntentsTool(); |
location_entry_->Update(contents); |
// The security level (background color) could have changed, etc. |
if (theme_service_->UsingNativeTheme()) { |
@@ -924,6 +999,12 @@ void LocationBarViewGtk::InvalidatePageActions() { |
} |
} |
+void LocationBarViewGtk::UpdateWebIntentsTool() { |
+ web_intents_button_view_->Update(GetTabContents()); |
+ gtk_widget_set_visible(web_intents_hbox_.get(), |
+ web_intents_button_view_->IsVisible()); |
+} |
+ |
void LocationBarViewGtk::SaveStateToContents(WebContents* contents) { |
location_entry_->SaveStateToTab(contents); |
} |
@@ -1066,6 +1147,7 @@ void LocationBarViewGtk::Observe(int type, |
UpdateChromeToMobileIcon(); |
UpdateSiteTypeArea(); |
UpdateContentSettingsIcons(); |
+ UpdateWebIntentsTool(); |
break; |
} |