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

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

Issue 10835020: Refactor location bar content setting image GTK classes to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/gtk/location_bar_view_gtk.h" 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // Colors used to draw the Tab to Search rounded bubble. 128 // Colors used to draw the Tab to Search rounded bubble.
129 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa); 129 const GdkColor kKeywordBackgroundColor = GDK_COLOR_RGB(0xf0, 0xf4, 0xfa);
130 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7); 130 const GdkColor kKeywordBorderColor = GDK_COLOR_RGB(0xcb, 0xde, 0xf7);
131 131
132 // Use weak gray for showing search and keyword hint text. 132 // Use weak gray for showing search and keyword hint text.
133 const GdkColor kHintTextColor = GDK_COLOR_RGB(0x75, 0x75, 0x75); 133 const GdkColor kHintTextColor = GDK_COLOR_RGB(0x75, 0x75, 0x75);
134 134
135 // Size of the rounding of the "Search site for:" box. 135 // Size of the rounding of the "Search site for:" box.
136 const int kCornerSize = 3; 136 const int kCornerSize = 3;
137 137
138 // Default page tool animation time (open and close).
139 const int kPageToolAnimationTime = 150;
140
138 // The time, in ms, that the content setting label is fully displayed, for the 141 // The time, in ms, that the content setting label is fully displayed, for the
139 // cases where we animate it into and out of view. 142 // cases where we animate it into and out of view.
140 const int kContentSettingImageDisplayTime = 3200; 143 const int kContentSettingImageDisplayTime = 3200;
141 // The time, in ms, of the animation (open and close). 144 // The time, in ms, of the animation (open and close).
142 const int kContentSettingImageAnimationTime = 150; 145 const int kContentSettingImageAnimationTime = 150;
143 146
144 // Color of border of content setting area (icon/label). 147 // Color of border of content setting area (icon/label).
145 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66); 148 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66);
146 // Colors for the background gradient. 149 // Colors for the background gradient.
147 const double kContentSettingTopColor[] = { 0xff / 255.0, 150 const GdkColor kContentSettingTopColor = GDK_COLOR_RGB(0xff, 0xf8, 0xd4);
148 0xf8 / 255.0, 151 const GdkColor kContentSettingBottomColor = GDK_COLOR_RGB(0xff, 0xe6, 0xaf);
149 0xd4 / 255.0 };
150 const double kContentSettingBottomColor[] = { 0xff / 255.0,
151 0xe6 / 255.0,
152 0xaf / 255.0 };
153 152
154 // If widget is visible, increment the int pointed to by count. 153 // If widget is visible, increment the int pointed to by count.
155 // Suitible for use with gtk_container_foreach. 154 // Suitible for use with gtk_container_foreach.
156 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { 155 void CountVisibleWidgets(GtkWidget* widget, gpointer count) {
157 if (gtk_widget_get_visible(widget)) 156 if (gtk_widget_get_visible(widget))
158 *static_cast<int*>(count) += 1; 157 *static_cast<int*>(count) += 1;
159 } 158 }
160 159
160 class ContentSettingImageViewGtk : public LocationBarViewGtk::PageToolViewGtk,
161 public BubbleDelegateGtk {
162 public:
163 ContentSettingImageViewGtk(ContentSettingsType content_type,
164 const LocationBarViewGtk* parent);
165 virtual ~ContentSettingImageViewGtk();
166
167 virtual void Update(TabContents* tab_contents) OVERRIDE;
Bernhard Bauer 2012/07/27 17:01:20 Nit: Can you add a comment that these are PageTool
Greg Billock 2012/07/27 17:18:11 Oops! Yes, added. On 2012/07/27 17:01:20, Bernhar
168
169 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
Bernhard Bauer 2012/07/27 17:01:20 And maybe one here that this is an ui::AnimationDe
Greg Billock 2012/07/27 17:18:11 Done.
170
171 private:
172 virtual GdkColor button_border_color() const OVERRIDE;
173 virtual GdkColor gradient_top_color() const OVERRIDE;
174 virtual GdkColor gradient_bottom_color() const OVERRIDE;
175 virtual void OnClick(GtkWidget* sender) OVERRIDE;
176
177 // BubbleDelegateGtk overrides:
178 virtual void BubbleClosing(BubbleGtk* bubble,
179 bool closed_by_escape) OVERRIDE;
180
181 scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
182
183 // The currently shown bubble if any.
184 ContentSettingBubbleGtk* content_setting_bubble_;
185
186 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageViewGtk);
187 };
188
189 ContentSettingImageViewGtk::ContentSettingImageViewGtk(
190 ContentSettingsType content_type,
191 const LocationBarViewGtk* parent)
192 : PageToolViewGtk(parent),
193 content_setting_image_model_(
194 ContentSettingImageModel::CreateContentSettingImageModel(
195 content_type)),
196 content_setting_bubble_(NULL) {
197 animation_.SetSlideDuration(kContentSettingImageAnimationTime);
198 }
199
200 ContentSettingImageViewGtk::~ContentSettingImageViewGtk() {
201 if (content_setting_bubble_)
202 content_setting_bubble_->Close();
203 }
204
205 void ContentSettingImageViewGtk::Update(
206 TabContents* tab_contents) {
207 if (tab_contents) {
208 content_setting_image_model_->UpdateFromWebContents(
209 tab_contents->web_contents());
210 }
211 if (!content_setting_image_model_->is_visible()) {
212 gtk_widget_hide(widget());
213 return;
214 }
215
216 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()),
217 GtkThemeService::GetFrom(parent_->browser()->profile())->GetImageNamed(
218 content_setting_image_model_->get_icon())->ToGdkPixbuf());
219
220 gtk_widget_set_tooltip_text(widget(),
221 content_setting_image_model_->get_tooltip().c_str());
222 gtk_widget_show_all(widget());
223
224 if (!tab_contents)
225 return;
226
227 TabSpecificContentSettings* content_settings =
228 tab_contents->content_settings();
229 if (!content_settings || content_settings->IsBlockageIndicated(
230 content_setting_image_model_->get_content_settings_type()))
231 return;
232
233 // The content blockage was not yet indicated to the user. Start indication
234 // animation and clear "not yet shown" flag.
235 content_settings->SetBlockageHasBeenIndicated(
236 content_setting_image_model_->get_content_settings_type());
237
238 int label_string_id =
239 content_setting_image_model_->explanatory_string_id();
240 // If there's no string for the content type, we don't animate.
241 if (!label_string_id)
242 return;
243
244 gtk_label_set_text(GTK_LABEL(label_.get()),
245 l10n_util::GetStringUTF8(label_string_id).c_str());
246 StartAnimating();
247 }
248
249 void ContentSettingImageViewGtk::AnimationEnded(
250 const ui::Animation* animation) {
251 if (animation_.IsShowing()) {
252 MessageLoop::current()->PostDelayedTask(
253 FROM_HERE,
254 base::Bind(&ContentSettingImageViewGtk::CloseAnimation,
255 weak_factory_.GetWeakPtr()),
256 base::TimeDelta::FromMilliseconds(kContentSettingImageDisplayTime));
257 } else {
258 gtk_widget_hide(label_.get());
259 gtk_util::StopActingAsRoundedWindow(event_box_.get());
260 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
261 }
262 }
263
264 GdkColor ContentSettingImageViewGtk::
265 button_border_color() const {
266 return kContentSettingBorderColor;
267 }
268
269 GdkColor ContentSettingImageViewGtk::
270 gradient_top_color() const {
271 return kContentSettingTopColor;
272 }
273
274 GdkColor ContentSettingImageViewGtk::
275 gradient_bottom_color() const {
276 return kContentSettingBottomColor;
277 }
278
279 void ContentSettingImageViewGtk::OnClick(
280 GtkWidget* sender) {
281 TabContents* tab_contents = parent_->GetTabContents();
282 if (!tab_contents)
283 return;
284 Profile* profile = parent_->browser()->profile();
285 content_setting_bubble_ = new ContentSettingBubbleGtk(
286 sender, this,
287 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
288 parent_->browser()->content_setting_bubble_model_delegate(),
289 tab_contents,
290 profile,
291 content_setting_image_model_->get_content_settings_type()),
292 profile, tab_contents->web_contents());
293 return;
294 }
295
296 void ContentSettingImageViewGtk::BubbleClosing(
297 BubbleGtk* bubble,
298 bool closed_by_escape) {
299 content_setting_bubble_ = NULL;
300 }
301
302
303
161 } // namespace 304 } // namespace
162 305
163 //////////////////////////////////////////////////////////////////////////////// 306 ////////////////////////////////////////////////////////////////////////////////
164 // LocationBarViewGtk 307 // LocationBarViewGtk
165 308
166 // static 309 // static
167 const GdkColor LocationBarViewGtk::kBackgroundColor = 310 const GdkColor LocationBarViewGtk::kBackgroundColor =
168 GDK_COLOR_RGB(255, 255, 255); 311 GDK_COLOR_RGB(255, 255, 255);
169 312
170 LocationBarViewGtk::LocationBarViewGtk(Browser* browser) 313 LocationBarViewGtk::LocationBarViewGtk(Browser* browser)
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 if (select_all) 845 if (select_all)
703 location_entry_->SelectAll(true); 846 location_entry_->SelectAll(true);
704 } 847 }
705 848
706 void LocationBarViewGtk::FocusSearch() { 849 void LocationBarViewGtk::FocusSearch() {
707 location_entry_->SetFocus(); 850 location_entry_->SetFocus();
708 location_entry_->SetForcedQuery(); 851 location_entry_->SetForcedQuery();
709 } 852 }
710 853
711 void LocationBarViewGtk::UpdateContentSettingsIcons() { 854 void LocationBarViewGtk::UpdateContentSettingsIcons() {
712 WebContents* web_contents = GetWebContents();
713 bool any_visible = false; 855 bool any_visible = false;
714 for (ScopedVector<ContentSettingImageViewGtk>::iterator i( 856 for (ScopedVector<PageToolViewGtk>::iterator i(
715 content_setting_views_.begin()); 857 content_setting_views_.begin());
716 i != content_setting_views_.end(); ++i) { 858 i != content_setting_views_.end(); ++i) {
717 (*i)->UpdateFromWebContents( 859 (*i)->Update(
718 toolbar_model_->input_in_progress() ? NULL : web_contents); 860 toolbar_model_->input_in_progress() ? NULL : GetTabContents());
719 any_visible = (*i)->IsVisible() || any_visible; 861 any_visible = (*i)->IsVisible() || any_visible;
720 } 862 }
721 863
722 // If there are no visible content things, hide the top level box so it 864 // If there are no visible content things, hide the top level box so it
723 // doesn't mess with padding. 865 // doesn't mess with padding.
724 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); 866 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible);
725 } 867 }
726 868
727 void LocationBarViewGtk::UpdatePageActions() { 869 void LocationBarViewGtk::UpdatePageActions() {
728 std::vector<ExtensionAction*> new_page_actions; 870 std::vector<ExtensionAction*> new_page_actions;
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 gtk_widget_show(tab_to_search_hint_); 1548 gtk_widget_show(tab_to_search_hint_);
1407 } else if (full_width < available_width) { 1549 } else if (full_width < available_width) {
1408 gtk_widget_show(tab_to_search_hint_leading_label_); 1550 gtk_widget_show(tab_to_search_hint_leading_label_);
1409 gtk_widget_show(tab_to_search_hint_trailing_label_); 1551 gtk_widget_show(tab_to_search_hint_trailing_label_);
1410 gtk_widget_show(tab_to_search_hint_); 1552 gtk_widget_show(tab_to_search_hint_);
1411 } 1553 }
1412 } 1554 }
1413 } 1555 }
1414 1556
1415 //////////////////////////////////////////////////////////////////////////////// 1557 ////////////////////////////////////////////////////////////////////////////////
1416 // LocationBarViewGtk::ContentSettingImageViewGtk 1558 // LocationBarViewGtk::PageToolViewGtk
1417 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( 1559
1418 ContentSettingsType content_type, 1560 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk(
1419 const LocationBarViewGtk* parent) 1561 const LocationBarViewGtk* parent)
1420 : content_setting_image_model_( 1562 : alignment_(gtk_alignment_new(0, 0, 1, 1)),
1421 ContentSettingImageModel::CreateContentSettingImageModel(
1422 content_type)),
1423 alignment_(gtk_alignment_new(0, 0, 1, 1)),
1424 event_box_(gtk_event_box_new()), 1563 event_box_(gtk_event_box_new()),
1425 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), 1564 hbox_(gtk_hbox_new(FALSE, kInnerPadding)),
1426 image_(gtk_image_new()), 1565 image_(gtk_image_new()),
1427 label_(gtk_label_new(NULL)), 1566 label_(gtk_label_new(NULL)),
1428 parent_(parent), 1567 parent_(parent),
1429 content_setting_bubble_(NULL),
1430 animation_(this), 1568 animation_(this),
1431 weak_factory_(this) { 1569 weak_factory_(this) {
1432 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); 1570 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0);
1433 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); 1571 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get());
1434 1572
1435 // Make the event box not visible so it does not paint a background. 1573 // Make the event box not visible so it does not paint a background.
1436 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); 1574 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
1437 g_signal_connect(event_box_.get(), "button-press-event", 1575 g_signal_connect(event_box_.get(), "button-press-event",
1438 G_CALLBACK(&OnButtonPressedThunk), this); 1576 G_CALLBACK(&OnButtonPressedThunk), this);
1439 g_signal_connect(event_box_.get(), "expose-event", 1577 g_signal_connect(event_box_.get(), "expose-event",
1440 G_CALLBACK(&OnExposeThunk), this); 1578 G_CALLBACK(&OnExposeThunk), this);
1441 1579
1442 gtk_widget_set_no_show_all(label_.get(), TRUE); 1580 gtk_widget_set_no_show_all(label_.get(), TRUE);
1443 gtk_label_set_line_wrap(GTK_LABEL(label_.get()), FALSE); 1581 gtk_label_set_line_wrap(GTK_LABEL(label_.get()), FALSE);
1444 1582
1445 gtk_box_pack_start(GTK_BOX(hbox_), image_.get(), FALSE, FALSE, 0); 1583 gtk_box_pack_start(GTK_BOX(hbox_), image_.get(), FALSE, FALSE, 0);
1446 gtk_box_pack_start(GTK_BOX(hbox_), label_.get(), FALSE, FALSE, 0); 1584 gtk_box_pack_start(GTK_BOX(hbox_), label_.get(), FALSE, FALSE, 0);
1447 1585
1448 gtk_container_set_border_width(GTK_CONTAINER(hbox_), kHboxBorder); 1586 gtk_container_set_border_width(GTK_CONTAINER(hbox_), kHboxBorder);
1449 1587
1450 gtk_container_add(GTK_CONTAINER(event_box_.get()), hbox_); 1588 gtk_container_add(GTK_CONTAINER(event_box_.get()), hbox_);
1451 gtk_widget_hide(widget()); 1589 gtk_widget_hide(widget());
1452 1590
1453 animation_.SetSlideDuration(kContentSettingImageAnimationTime); 1591 animation_.SetSlideDuration(kPageToolAnimationTime);
1454 } 1592 }
1455 1593
1456 LocationBarViewGtk::ContentSettingImageViewGtk::~ContentSettingImageViewGtk() { 1594 LocationBarViewGtk::PageToolViewGtk::~PageToolViewGtk() {
1457 image_.Destroy(); 1595 image_.Destroy();
1458 label_.Destroy(); 1596 label_.Destroy();
1459 event_box_.Destroy(); 1597 event_box_.Destroy();
1460 alignment_.Destroy(); 1598 alignment_.Destroy();
1461
1462 if (content_setting_bubble_)
1463 content_setting_bubble_->Close();
1464 } 1599 }
1465 1600
1466 bool LocationBarViewGtk::ContentSettingImageViewGtk::IsVisible() { 1601 GtkWidget* LocationBarViewGtk::PageToolViewGtk::widget() {
1602 return alignment_.get();
1603 }
1604
1605 bool LocationBarViewGtk::PageToolViewGtk::IsVisible() {
1467 return gtk_widget_get_visible(widget()); 1606 return gtk_widget_get_visible(widget());
1468 } 1607 }
1469 1608
1470 void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromWebContents( 1609 void LocationBarViewGtk::PageToolViewGtk::StartAnimating() {
1471 WebContents* web_contents) {
1472 content_setting_image_model_->UpdateFromWebContents(web_contents);
1473 if (!content_setting_image_model_->is_visible()) {
1474 gtk_widget_hide(widget());
1475 return;
1476 }
1477
1478 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()),
1479 GtkThemeService::GetFrom(parent_->browser()->profile())->GetImageNamed(
1480 content_setting_image_model_->get_icon())->ToGdkPixbuf());
1481
1482 gtk_widget_set_tooltip_text(widget(),
1483 content_setting_image_model_->get_tooltip().c_str());
1484 gtk_widget_show_all(widget());
1485
1486 TabSpecificContentSettings* content_settings = NULL;
1487 if (web_contents) {
1488 content_settings =
1489 TabContents::FromWebContents(web_contents)->content_settings();
1490 }
1491 if (!content_settings || content_settings->IsBlockageIndicated(
1492 content_setting_image_model_->get_content_settings_type()))
1493 return;
1494
1495 // The content blockage was not yet indicated to the user. Start indication
1496 // animation and clear "not yet shown" flag.
1497 content_settings->SetBlockageHasBeenIndicated(
1498 content_setting_image_model_->get_content_settings_type());
1499
1500 int label_string_id =
1501 content_setting_image_model_->explanatory_string_id();
1502 // If there's no string for the content type, we don't animate.
1503 if (!label_string_id)
1504 return;
1505
1506 gtk_label_set_text(GTK_LABEL(label_.get()),
1507 l10n_util::GetStringUTF8(label_string_id).c_str());
1508 StartAnimating();
1509 }
1510
1511 void LocationBarViewGtk::ContentSettingImageViewGtk::StartAnimating() {
1512 if (animation_.IsShowing() || animation_.IsClosing()) 1610 if (animation_.IsShowing() || animation_.IsClosing())
1513 return; 1611 return;
1514 1612
1515 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), TRUE); 1613 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), TRUE);
1516 gtk_util::ActAsRoundedWindow(event_box_.get(), kContentSettingBorderColor, 1614 GdkColor border_color = button_border_color();
1615 gtk_util::ActAsRoundedWindow(event_box_.get(), border_color,
1517 kCornerSize, 1616 kCornerSize,
1518 gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL); 1617 gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL);
1519 1618
1520 gtk_widget_set_size_request(label_.get(), -1, -1); 1619 gtk_widget_set_size_request(label_.get(), -1, -1);
1521 gtk_widget_size_request(label_.get(), &label_req_); 1620 gtk_widget_size_request(label_.get(), &label_req_);
1522 gtk_widget_set_size_request(label_.get(), 0, -1); 1621 gtk_widget_set_size_request(label_.get(), 0, -1);
1523 gtk_widget_show(label_.get()); 1622 gtk_widget_show(label_.get());
1524 1623
1525 animation_.Show(); 1624 animation_.Show();
1526 } 1625 }
1527 1626
1528 void LocationBarViewGtk::ContentSettingImageViewGtk::CloseAnimation() { 1627 void LocationBarViewGtk::PageToolViewGtk::CloseAnimation() {
1529 animation_.Hide(); 1628 animation_.Hide();
1530 } 1629 }
1531 1630
1532 void LocationBarViewGtk::ContentSettingImageViewGtk::AnimationProgressed( 1631 void LocationBarViewGtk::PageToolViewGtk::AnimationProgressed(
1533 const ui::Animation* animation) { 1632 const ui::Animation* animation) {
1534 gtk_widget_set_size_request( 1633 gtk_widget_set_size_request(
1535 label_.get(), 1634 label_.get(),
1536 animation->GetCurrentValue() * label_req_.width, 1635 animation->GetCurrentValue() * label_req_.width,
1537 -1); 1636 -1);
1538 } 1637 }
1539 1638
1540 void LocationBarViewGtk::ContentSettingImageViewGtk::AnimationEnded( 1639 void LocationBarViewGtk::PageToolViewGtk::AnimationEnded(
1541 const ui::Animation* animation) {
1542 if (animation_.IsShowing()) {
1543 MessageLoop::current()->PostDelayedTask(
1544 FROM_HERE,
1545 base::Bind(&ContentSettingImageViewGtk::CloseAnimation,
1546 weak_factory_.GetWeakPtr()),
1547 base::TimeDelta::FromMilliseconds(kContentSettingImageDisplayTime));
1548 } else {
1549 gtk_widget_hide(label_.get());
1550 gtk_util::StopActingAsRoundedWindow(event_box_.get());
1551 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
1552 }
1553 }
1554
1555 void LocationBarViewGtk::ContentSettingImageViewGtk::AnimationCanceled(
1556 const ui::Animation* animation) { 1640 const ui::Animation* animation) {
1557 } 1641 }
1558 1642
1559 gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnButtonPressed( 1643 void LocationBarViewGtk::PageToolViewGtk::AnimationCanceled(
1644 const ui::Animation* animation) {
1645 }
1646
1647 gboolean LocationBarViewGtk::PageToolViewGtk::OnButtonPressed(
1560 GtkWidget* sender, GdkEvent* event) { 1648 GtkWidget* sender, GdkEvent* event) {
1561 TabContents* tab_contents = parent_->GetTabContents(); 1649 OnClick(sender);
1562 if (!tab_contents)
1563 return TRUE;
1564 Profile* profile = parent_->browser()->profile();
1565 content_setting_bubble_ = new ContentSettingBubbleGtk(
1566 sender, this,
1567 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
1568 parent_->browser()->content_setting_bubble_model_delegate(),
1569 tab_contents,
1570 profile,
1571 content_setting_image_model_->get_content_settings_type()),
1572 profile, tab_contents->web_contents());
1573 return TRUE; 1650 return TRUE;
1574 } 1651 }
1575 1652
1576 gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnExpose( 1653 gboolean LocationBarViewGtk::PageToolViewGtk::OnExpose(
1577 GtkWidget* sender, GdkEventExpose* event) { 1654 GtkWidget* sender, GdkEventExpose* event) {
1578 TRACE_EVENT0("ui::gtk", 1655 TRACE_EVENT0("ui::gtk", "LocationBarViewGtk::PageToolViewGtk::OnExpose");
1579 "LocationBarViewGtk::ContentSettingImageViewGtk::OnExpose");
1580 1656
1581 if (!(animation_.IsShowing() || animation_.IsClosing())) 1657 if (!(animation_.IsShowing() || animation_.IsClosing()))
1582 return FALSE; 1658 return FALSE;
1583 1659
1584 GtkAllocation allocation; 1660 GtkAllocation allocation;
1585 gtk_widget_get_allocation(sender, &allocation); 1661 gtk_widget_get_allocation(sender, &allocation);
1586 const int height = allocation.height; 1662 const int height = allocation.height;
1587 1663
1588 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(sender)); 1664 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(sender));
1589 gdk_cairo_rectangle(cr, &event->area); 1665 gdk_cairo_rectangle(cr, &event->area);
1590 cairo_clip(cr); 1666 cairo_clip(cr);
1591 1667
1592 cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height); 1668 cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height);
1593 1669
1594 cairo_pattern_add_color_stop_rgb(pattern, 0.0, 1670 const GdkColor top_color = gradient_top_color();
1595 kContentSettingTopColor[0], 1671 const GdkColor bottom_color = gradient_bottom_color();
1596 kContentSettingTopColor[1], 1672 cairo_pattern_add_color_stop_rgb(
1597 kContentSettingTopColor[2]); 1673 pattern, 0.0,
1598 cairo_pattern_add_color_stop_rgb(pattern, 1.0, 1674 top_color.red/255.0,
1599 kContentSettingBottomColor[0], 1675 top_color.blue/255.0,
1600 kContentSettingBottomColor[1], 1676 top_color.green/255.0);
1601 kContentSettingBottomColor[2]); 1677 cairo_pattern_add_color_stop_rgb(
1678 pattern, 1.0,
1679 bottom_color.red/255.0,
1680 bottom_color.blue/255.0,
1681 bottom_color.green/255.0);
1682
1602 cairo_set_source(cr, pattern); 1683 cairo_set_source(cr, pattern);
1603 cairo_paint(cr); 1684 cairo_paint(cr);
1604 cairo_pattern_destroy(pattern); 1685 cairo_pattern_destroy(pattern);
1605 cairo_destroy(cr); 1686 cairo_destroy(cr);
1606 1687
1607 return FALSE; 1688 return FALSE;
1608 } 1689 }
1609 1690
1610 void LocationBarViewGtk::ContentSettingImageViewGtk::BubbleClosing(
1611 BubbleGtk* bubble,
1612 bool closed_by_escape) {
1613 content_setting_bubble_ = NULL;
1614 }
1615
1616 //////////////////////////////////////////////////////////////////////////////// 1691 ////////////////////////////////////////////////////////////////////////////////
1617 // LocationBarViewGtk::PageActionViewGtk 1692 // LocationBarViewGtk::PageActionViewGtk
1618 1693
1619 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( 1694 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk(
1620 LocationBarViewGtk* owner, 1695 LocationBarViewGtk* owner,
1621 ExtensionAction* page_action) 1696 ExtensionAction* page_action)
1622 : owner_(NULL), 1697 : owner_(NULL),
1623 page_action_(page_action), 1698 page_action_(page_action),
1624 last_icon_pixbuf_(NULL), 1699 last_icon_pixbuf_(NULL),
1625 tracker_(this), 1700 tracker_(this),
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 } 2047 }
1973 2048
1974 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( 2049 void LocationBarViewGtk::PageActionViewGtk::InspectPopup(
1975 ExtensionAction* action) { 2050 ExtensionAction* action) {
1976 ExtensionPopupGtk::Show( 2051 ExtensionPopupGtk::Show(
1977 action->GetPopupUrl(current_tab_id_), 2052 action->GetPopupUrl(current_tab_id_),
1978 owner_->browser_, 2053 owner_->browser_,
1979 event_box_.get(), 2054 event_box_.get(),
1980 ExtensionPopupGtk::SHOW_AND_INSPECT); 2055 ExtensionPopupGtk::SHOW_AND_INSPECT);
1981 } 2056 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698