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

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: Merge to head 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 // PageToolViewGtk
168 virtual void Update(TabContents* tab_contents) OVERRIDE;
169
170 // ui::AnimationDelegate
171 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
172
173 private:
174 // PageToolViewGtk
175 virtual GdkColor button_border_color() const OVERRIDE;
176 virtual GdkColor gradient_top_color() const OVERRIDE;
177 virtual GdkColor gradient_bottom_color() const OVERRIDE;
178 virtual void OnClick(GtkWidget* sender) OVERRIDE;
179
180 // BubbleDelegateGtk
181 virtual void BubbleClosing(BubbleGtk* bubble,
182 bool closed_by_escape) OVERRIDE;
183
184 scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
185
186 // The currently shown bubble if any.
187 ContentSettingBubbleGtk* content_setting_bubble_;
188
189 DISALLOW_COPY_AND_ASSIGN(ContentSettingImageViewGtk);
190 };
191
192 ContentSettingImageViewGtk::ContentSettingImageViewGtk(
193 ContentSettingsType content_type,
194 const LocationBarViewGtk* parent)
195 : PageToolViewGtk(parent),
196 content_setting_image_model_(
197 ContentSettingImageModel::CreateContentSettingImageModel(
198 content_type)),
199 content_setting_bubble_(NULL) {
200 animation_.SetSlideDuration(kContentSettingImageAnimationTime);
201 }
202
203 ContentSettingImageViewGtk::~ContentSettingImageViewGtk() {
204 if (content_setting_bubble_)
205 content_setting_bubble_->Close();
206 }
207
208 void ContentSettingImageViewGtk::Update(
209 TabContents* tab_contents) {
210 if (tab_contents) {
211 content_setting_image_model_->UpdateFromWebContents(
212 tab_contents->web_contents());
213 }
214 if (!content_setting_image_model_->is_visible()) {
215 gtk_widget_hide(widget());
216 return;
217 }
218
219 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()),
220 GtkThemeService::GetFrom(parent_->browser()->profile())->GetImageNamed(
221 content_setting_image_model_->get_icon())->ToGdkPixbuf());
222
223 gtk_widget_set_tooltip_text(widget(),
224 content_setting_image_model_->get_tooltip().c_str());
225 gtk_widget_show_all(widget());
226
227 if (!tab_contents)
228 return;
229
230 TabSpecificContentSettings* content_settings =
231 tab_contents->content_settings();
232 if (!content_settings || content_settings->IsBlockageIndicated(
233 content_setting_image_model_->get_content_settings_type()))
234 return;
235
236 // The content blockage was not yet indicated to the user. Start indication
237 // animation and clear "not yet shown" flag.
238 content_settings->SetBlockageHasBeenIndicated(
239 content_setting_image_model_->get_content_settings_type());
240
241 int label_string_id =
242 content_setting_image_model_->explanatory_string_id();
243 // If there's no string for the content type, we don't animate.
244 if (!label_string_id)
245 return;
246
247 gtk_label_set_text(GTK_LABEL(label_.get()),
248 l10n_util::GetStringUTF8(label_string_id).c_str());
249 StartAnimating();
250 }
251
252 void ContentSettingImageViewGtk::AnimationEnded(
253 const ui::Animation* animation) {
254 if (animation_.IsShowing()) {
255 MessageLoop::current()->PostDelayedTask(
256 FROM_HERE,
257 base::Bind(&ContentSettingImageViewGtk::CloseAnimation,
258 weak_factory_.GetWeakPtr()),
259 base::TimeDelta::FromMilliseconds(kContentSettingImageDisplayTime));
260 } else {
261 gtk_widget_hide(label_.get());
262 gtk_util::StopActingAsRoundedWindow(event_box_.get());
263 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
264 }
265 }
266
267 GdkColor ContentSettingImageViewGtk::
268 button_border_color() const {
269 return kContentSettingBorderColor;
270 }
271
272 GdkColor ContentSettingImageViewGtk::
273 gradient_top_color() const {
274 return kContentSettingTopColor;
275 }
276
277 GdkColor ContentSettingImageViewGtk::
278 gradient_bottom_color() const {
279 return kContentSettingBottomColor;
280 }
281
282 void ContentSettingImageViewGtk::OnClick(
283 GtkWidget* sender) {
284 TabContents* tab_contents = parent_->GetTabContents();
285 if (!tab_contents)
286 return;
287 Profile* profile = parent_->browser()->profile();
288 content_setting_bubble_ = new ContentSettingBubbleGtk(
289 sender, this,
290 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
291 parent_->browser()->content_setting_bubble_model_delegate(),
292 tab_contents,
293 profile,
294 content_setting_image_model_->get_content_settings_type()),
295 profile, tab_contents->web_contents());
296 return;
297 }
298
299 void ContentSettingImageViewGtk::BubbleClosing(
300 BubbleGtk* bubble,
301 bool closed_by_escape) {
302 content_setting_bubble_ = NULL;
303 }
304
305
306
161 } // namespace 307 } // namespace
162 308
163 //////////////////////////////////////////////////////////////////////////////// 309 ////////////////////////////////////////////////////////////////////////////////
164 // LocationBarViewGtk 310 // LocationBarViewGtk
165 311
166 // static 312 // static
167 const GdkColor LocationBarViewGtk::kBackgroundColor = 313 const GdkColor LocationBarViewGtk::kBackgroundColor =
168 GDK_COLOR_RGB(255, 255, 255); 314 GDK_COLOR_RGB(255, 255, 255);
169 315
170 LocationBarViewGtk::LocationBarViewGtk(Browser* browser) 316 LocationBarViewGtk::LocationBarViewGtk(Browser* browser)
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 if (select_all) 848 if (select_all)
703 location_entry_->SelectAll(true); 849 location_entry_->SelectAll(true);
704 } 850 }
705 851
706 void LocationBarViewGtk::FocusSearch() { 852 void LocationBarViewGtk::FocusSearch() {
707 location_entry_->SetFocus(); 853 location_entry_->SetFocus();
708 location_entry_->SetForcedQuery(); 854 location_entry_->SetForcedQuery();
709 } 855 }
710 856
711 void LocationBarViewGtk::UpdateContentSettingsIcons() { 857 void LocationBarViewGtk::UpdateContentSettingsIcons() {
712 WebContents* web_contents = GetWebContents();
713 bool any_visible = false; 858 bool any_visible = false;
714 for (ScopedVector<ContentSettingImageViewGtk>::iterator i( 859 for (ScopedVector<PageToolViewGtk>::iterator i(
715 content_setting_views_.begin()); 860 content_setting_views_.begin());
716 i != content_setting_views_.end(); ++i) { 861 i != content_setting_views_.end(); ++i) {
717 (*i)->UpdateFromWebContents( 862 (*i)->Update(
718 toolbar_model_->input_in_progress() ? NULL : web_contents); 863 toolbar_model_->input_in_progress() ? NULL : GetTabContents());
719 any_visible = (*i)->IsVisible() || any_visible; 864 any_visible = (*i)->IsVisible() || any_visible;
720 } 865 }
721 866
722 // If there are no visible content things, hide the top level box so it 867 // If there are no visible content things, hide the top level box so it
723 // doesn't mess with padding. 868 // doesn't mess with padding.
724 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); 869 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible);
725 } 870 }
726 871
727 void LocationBarViewGtk::UpdatePageActions() { 872 void LocationBarViewGtk::UpdatePageActions() {
728 std::vector<ExtensionAction*> new_page_actions; 873 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_); 1551 gtk_widget_show(tab_to_search_hint_);
1407 } else if (full_width < available_width) { 1552 } else if (full_width < available_width) {
1408 gtk_widget_show(tab_to_search_hint_leading_label_); 1553 gtk_widget_show(tab_to_search_hint_leading_label_);
1409 gtk_widget_show(tab_to_search_hint_trailing_label_); 1554 gtk_widget_show(tab_to_search_hint_trailing_label_);
1410 gtk_widget_show(tab_to_search_hint_); 1555 gtk_widget_show(tab_to_search_hint_);
1411 } 1556 }
1412 } 1557 }
1413 } 1558 }
1414 1559
1415 //////////////////////////////////////////////////////////////////////////////// 1560 ////////////////////////////////////////////////////////////////////////////////
1416 // LocationBarViewGtk::ContentSettingImageViewGtk 1561 // LocationBarViewGtk::PageToolViewGtk
1417 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( 1562
1418 ContentSettingsType content_type, 1563 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk(
1419 const LocationBarViewGtk* parent) 1564 const LocationBarViewGtk* parent)
1420 : content_setting_image_model_( 1565 : 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()), 1566 event_box_(gtk_event_box_new()),
1425 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), 1567 hbox_(gtk_hbox_new(FALSE, kInnerPadding)),
1426 image_(gtk_image_new()), 1568 image_(gtk_image_new()),
1427 label_(gtk_label_new(NULL)), 1569 label_(gtk_label_new(NULL)),
1428 parent_(parent), 1570 parent_(parent),
1429 content_setting_bubble_(NULL),
1430 animation_(this), 1571 animation_(this),
1431 weak_factory_(this) { 1572 weak_factory_(this) {
1432 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); 1573 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0);
1433 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); 1574 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get());
1434 1575
1435 // Make the event box not visible so it does not paint a background. 1576 // 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); 1577 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE);
1437 g_signal_connect(event_box_.get(), "button-press-event", 1578 g_signal_connect(event_box_.get(), "button-press-event",
1438 G_CALLBACK(&OnButtonPressedThunk), this); 1579 G_CALLBACK(&OnButtonPressedThunk), this);
1439 g_signal_connect(event_box_.get(), "expose-event", 1580 g_signal_connect(event_box_.get(), "expose-event",
1440 G_CALLBACK(&OnExposeThunk), this); 1581 G_CALLBACK(&OnExposeThunk), this);
1441 1582
1442 gtk_widget_set_no_show_all(label_.get(), TRUE); 1583 gtk_widget_set_no_show_all(label_.get(), TRUE);
1443 gtk_label_set_line_wrap(GTK_LABEL(label_.get()), FALSE); 1584 gtk_label_set_line_wrap(GTK_LABEL(label_.get()), FALSE);
1444 1585
1445 gtk_box_pack_start(GTK_BOX(hbox_), image_.get(), FALSE, FALSE, 0); 1586 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); 1587 gtk_box_pack_start(GTK_BOX(hbox_), label_.get(), FALSE, FALSE, 0);
1447 1588
1448 gtk_container_set_border_width(GTK_CONTAINER(hbox_), kHboxBorder); 1589 gtk_container_set_border_width(GTK_CONTAINER(hbox_), kHboxBorder);
1449 1590
1450 gtk_container_add(GTK_CONTAINER(event_box_.get()), hbox_); 1591 gtk_container_add(GTK_CONTAINER(event_box_.get()), hbox_);
1451 gtk_widget_hide(widget()); 1592 gtk_widget_hide(widget());
1452 1593
1453 animation_.SetSlideDuration(kContentSettingImageAnimationTime); 1594 animation_.SetSlideDuration(kPageToolAnimationTime);
1454 } 1595 }
1455 1596
1456 LocationBarViewGtk::ContentSettingImageViewGtk::~ContentSettingImageViewGtk() { 1597 LocationBarViewGtk::PageToolViewGtk::~PageToolViewGtk() {
1457 image_.Destroy(); 1598 image_.Destroy();
1458 label_.Destroy(); 1599 label_.Destroy();
1459 event_box_.Destroy(); 1600 event_box_.Destroy();
1460 alignment_.Destroy(); 1601 alignment_.Destroy();
1461
1462 if (content_setting_bubble_)
1463 content_setting_bubble_->Close();
1464 } 1602 }
1465 1603
1466 bool LocationBarViewGtk::ContentSettingImageViewGtk::IsVisible() { 1604 GtkWidget* LocationBarViewGtk::PageToolViewGtk::widget() {
1605 return alignment_.get();
1606 }
1607
1608 bool LocationBarViewGtk::PageToolViewGtk::IsVisible() {
1467 return gtk_widget_get_visible(widget()); 1609 return gtk_widget_get_visible(widget());
1468 } 1610 }
1469 1611
1470 void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromWebContents( 1612 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()) 1613 if (animation_.IsShowing() || animation_.IsClosing())
1513 return; 1614 return;
1514 1615
1515 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), TRUE); 1616 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), TRUE);
1516 gtk_util::ActAsRoundedWindow(event_box_.get(), kContentSettingBorderColor, 1617 GdkColor border_color = button_border_color();
1618 gtk_util::ActAsRoundedWindow(event_box_.get(), border_color,
1517 kCornerSize, 1619 kCornerSize,
1518 gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL); 1620 gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL);
1519 1621
1520 gtk_widget_set_size_request(label_.get(), -1, -1); 1622 gtk_widget_set_size_request(label_.get(), -1, -1);
1521 gtk_widget_size_request(label_.get(), &label_req_); 1623 gtk_widget_size_request(label_.get(), &label_req_);
1522 gtk_widget_set_size_request(label_.get(), 0, -1); 1624 gtk_widget_set_size_request(label_.get(), 0, -1);
1523 gtk_widget_show(label_.get()); 1625 gtk_widget_show(label_.get());
1524 1626
1525 animation_.Show(); 1627 animation_.Show();
1526 } 1628 }
1527 1629
1528 void LocationBarViewGtk::ContentSettingImageViewGtk::CloseAnimation() { 1630 void LocationBarViewGtk::PageToolViewGtk::CloseAnimation() {
1529 animation_.Hide(); 1631 animation_.Hide();
1530 } 1632 }
1531 1633
1532 void LocationBarViewGtk::ContentSettingImageViewGtk::AnimationProgressed( 1634 void LocationBarViewGtk::PageToolViewGtk::AnimationProgressed(
1533 const ui::Animation* animation) { 1635 const ui::Animation* animation) {
1534 gtk_widget_set_size_request( 1636 gtk_widget_set_size_request(
1535 label_.get(), 1637 label_.get(),
1536 animation->GetCurrentValue() * label_req_.width, 1638 animation->GetCurrentValue() * label_req_.width,
1537 -1); 1639 -1);
1538 } 1640 }
1539 1641
1540 void LocationBarViewGtk::ContentSettingImageViewGtk::AnimationEnded( 1642 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) { 1643 const ui::Animation* animation) {
1557 } 1644 }
1558 1645
1559 gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnButtonPressed( 1646 void LocationBarViewGtk::PageToolViewGtk::AnimationCanceled(
1647 const ui::Animation* animation) {
1648 }
1649
1650 gboolean LocationBarViewGtk::PageToolViewGtk::OnButtonPressed(
1560 GtkWidget* sender, GdkEvent* event) { 1651 GtkWidget* sender, GdkEvent* event) {
1561 TabContents* tab_contents = parent_->GetTabContents(); 1652 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; 1653 return TRUE;
1574 } 1654 }
1575 1655
1576 gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnExpose( 1656 gboolean LocationBarViewGtk::PageToolViewGtk::OnExpose(
1577 GtkWidget* sender, GdkEventExpose* event) { 1657 GtkWidget* sender, GdkEventExpose* event) {
1578 TRACE_EVENT0("ui::gtk", 1658 TRACE_EVENT0("ui::gtk", "LocationBarViewGtk::PageToolViewGtk::OnExpose");
1579 "LocationBarViewGtk::ContentSettingImageViewGtk::OnExpose");
1580 1659
1581 if (!(animation_.IsShowing() || animation_.IsClosing())) 1660 if (!(animation_.IsShowing() || animation_.IsClosing()))
1582 return FALSE; 1661 return FALSE;
1583 1662
1584 GtkAllocation allocation; 1663 GtkAllocation allocation;
1585 gtk_widget_get_allocation(sender, &allocation); 1664 gtk_widget_get_allocation(sender, &allocation);
1586 const int height = allocation.height; 1665 const int height = allocation.height;
1587 1666
1588 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(sender)); 1667 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(sender));
1589 gdk_cairo_rectangle(cr, &event->area); 1668 gdk_cairo_rectangle(cr, &event->area);
1590 cairo_clip(cr); 1669 cairo_clip(cr);
1591 1670
1592 cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height); 1671 cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height);
1593 1672
1594 cairo_pattern_add_color_stop_rgb(pattern, 0.0, 1673 const GdkColor top_color = gradient_top_color();
1595 kContentSettingTopColor[0], 1674 const GdkColor bottom_color = gradient_bottom_color();
1596 kContentSettingTopColor[1], 1675 cairo_pattern_add_color_stop_rgb(
1597 kContentSettingTopColor[2]); 1676 pattern, 0.0,
1598 cairo_pattern_add_color_stop_rgb(pattern, 1.0, 1677 top_color.red/255.0,
1599 kContentSettingBottomColor[0], 1678 top_color.blue/255.0,
1600 kContentSettingBottomColor[1], 1679 top_color.green/255.0);
1601 kContentSettingBottomColor[2]); 1680 cairo_pattern_add_color_stop_rgb(
1681 pattern, 1.0,
1682 bottom_color.red/255.0,
1683 bottom_color.blue/255.0,
1684 bottom_color.green/255.0);
1685
1602 cairo_set_source(cr, pattern); 1686 cairo_set_source(cr, pattern);
1603 cairo_paint(cr); 1687 cairo_paint(cr);
1604 cairo_pattern_destroy(pattern); 1688 cairo_pattern_destroy(pattern);
1605 cairo_destroy(cr); 1689 cairo_destroy(cr);
1606 1690
1607 return FALSE; 1691 return FALSE;
1608 } 1692 }
1609 1693
1610 void LocationBarViewGtk::ContentSettingImageViewGtk::BubbleClosing(
1611 BubbleGtk* bubble,
1612 bool closed_by_escape) {
1613 content_setting_bubble_ = NULL;
1614 }
1615
1616 //////////////////////////////////////////////////////////////////////////////// 1694 ////////////////////////////////////////////////////////////////////////////////
1617 // LocationBarViewGtk::PageActionViewGtk 1695 // LocationBarViewGtk::PageActionViewGtk
1618 1696
1619 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( 1697 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk(
1620 LocationBarViewGtk* owner, 1698 LocationBarViewGtk* owner,
1621 ExtensionAction* page_action) 1699 ExtensionAction* page_action)
1622 : owner_(NULL), 1700 : owner_(NULL),
1623 page_action_(page_action), 1701 page_action_(page_action),
1624 last_icon_pixbuf_(NULL), 1702 last_icon_pixbuf_(NULL),
1625 tracker_(this), 1703 tracker_(this),
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 } 2050 }
1973 2051
1974 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( 2052 void LocationBarViewGtk::PageActionViewGtk::InspectPopup(
1975 ExtensionAction* action) { 2053 ExtensionAction* action) {
1976 ExtensionPopupGtk::Show( 2054 ExtensionPopupGtk::Show(
1977 action->GetPopupUrl(current_tab_id_), 2055 action->GetPopupUrl(current_tab_id_),
1978 owner_->browser_, 2056 owner_->browser_,
1979 event_box_.get(), 2057 event_box_.get(),
1980 ExtensionPopupGtk::SHOW_AND_INSPECT); 2058 ExtensionPopupGtk::SHOW_AND_INSPECT);
1981 } 2059 }
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