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 3c5d6ef1737bbf80b94bde1e17974ead94d115ce..b8c8b25c3bd119bf011fa557fdccf637dd7fa455 100644 |
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc |
@@ -60,6 +60,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" |
@@ -146,12 +147,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. |
Evan Stade
2012/08/10 19:36:56
(in ms)
Greg Billock
2012/08/10 19:44:17
Done.
|
+const int kWebIntentsButtonAnimationTime = 2000; |
Evan Stade
2012/08/10 19:36:56
I don't know what exactly this animation is, but u
Greg Billock
2012/08/10 19:44:17
I found it basically impossible to see at all at 2
Peter Kasting
2012/08/11 03:37:10
Whether we cap depends on the purpose of the anima
Greg Billock
2012/08/11 15:08:05
The rate is definitely slower than that. Obviously
Evan Stade
2012/08/14 00:32:32
I would copy the popup blocked duration. I don't t
Greg Billock
2012/08/15 06:34:32
Sounds good. It's easy enough to change if another
|
+ |
// 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) { |
@@ -304,7 +313,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) { |
+ DLOG(INFO) << "Web Intents button click"; |
Evan Stade
2012/08/10 19:36:56
TODO(gbillock): Implement. (?)
I don't think the
Greg Billock
2012/08/10 19:44:17
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 |
@@ -326,6 +390,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), |
@@ -358,6 +423,7 @@ LocationBarViewGtk::~LocationBarViewGtk() { |
hbox_.Destroy(); |
content_setting_hbox_.Destroy(); |
page_action_hbox_.Destroy(); |
+ web_intents_hbox_.Destroy(); |
} |
void LocationBarViewGtk::Init(bool popup_window_mode) { |
@@ -528,6 +594,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_|. |
@@ -659,6 +733,7 @@ void LocationBarViewGtk::Update(const WebContents* contents) { |
UpdateSiteTypeArea(); |
UpdateContentSettingsIcons(); |
UpdatePageActions(); |
+ UpdateWebIntentsButton(); |
location_entry_->Update(contents); |
// The security level (background color) could have changed, etc. |
if (theme_service_->UsingNativeTheme()) { |
@@ -941,6 +1016,12 @@ void LocationBarViewGtk::InvalidatePageActions() { |
} |
} |
+void LocationBarViewGtk::UpdateWebIntentsButton() { |
+ 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); |
} |
@@ -1083,6 +1164,7 @@ void LocationBarViewGtk::Observe(int type, |
UpdateChromeToMobileIcon(); |
UpdateSiteTypeArea(); |
UpdateContentSettingsIcons(); |
+ UpdateWebIntentsButton(); |
break; |
} |