| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 enable_location_drag_(false), | 154 enable_location_drag_(false), |
| 155 security_info_label_(NULL), | 155 security_info_label_(NULL), |
| 156 tab_to_search_alignment_(NULL), | 156 tab_to_search_alignment_(NULL), |
| 157 tab_to_search_box_(NULL), | 157 tab_to_search_box_(NULL), |
| 158 tab_to_search_full_label_(NULL), | 158 tab_to_search_full_label_(NULL), |
| 159 tab_to_search_partial_label_(NULL), | 159 tab_to_search_partial_label_(NULL), |
| 160 tab_to_search_hint_(NULL), | 160 tab_to_search_hint_(NULL), |
| 161 tab_to_search_hint_leading_label_(NULL), | 161 tab_to_search_hint_leading_label_(NULL), |
| 162 tab_to_search_hint_icon_(NULL), | 162 tab_to_search_hint_icon_(NULL), |
| 163 tab_to_search_hint_trailing_label_(NULL), | 163 tab_to_search_hint_trailing_label_(NULL), |
| 164 profile_(NULL), | |
| 165 command_updater_(browser->command_updater()), | 164 command_updater_(browser->command_updater()), |
| 166 toolbar_model_(browser->toolbar_model()), | 165 toolbar_model_(browser->toolbar_model()), |
| 167 browser_(browser), | 166 browser_(browser), |
| 168 disposition_(CURRENT_TAB), | 167 disposition_(CURRENT_TAB), |
| 169 transition_(PageTransition::TYPED), | 168 transition_(PageTransition::TYPED), |
| 170 first_run_bubble_(this), | 169 first_run_bubble_(this), |
| 171 popup_window_mode_(false), | 170 popup_window_mode_(false), |
| 172 theme_service_(NULL), | 171 theme_service_(NULL), |
| 173 hbox_width_(0), | 172 hbox_width_(0), |
| 174 entry_box_width_(0), | 173 entry_box_width_(0), |
| 175 show_selected_keyword_(false), | 174 show_selected_keyword_(false), |
| 176 show_keyword_hint_(false) { | 175 show_keyword_hint_(false) { |
| 177 } | 176 } |
| 178 | 177 |
| 179 LocationBarViewGtk::~LocationBarViewGtk() { | 178 LocationBarViewGtk::~LocationBarViewGtk() { |
| 180 // All of our widgets should have be children of / owned by the alignment. | 179 // All of our widgets should have be children of / owned by the alignment. |
| 181 star_.Destroy(); | 180 star_.Destroy(); |
| 182 hbox_.Destroy(); | 181 hbox_.Destroy(); |
| 183 content_setting_hbox_.Destroy(); | 182 content_setting_hbox_.Destroy(); |
| 184 page_action_hbox_.Destroy(); | 183 page_action_hbox_.Destroy(); |
| 185 } | 184 } |
| 186 | 185 |
| 187 void LocationBarViewGtk::Init(bool popup_window_mode) { | 186 void LocationBarViewGtk::Init(bool popup_window_mode) { |
| 188 popup_window_mode_ = popup_window_mode; | 187 popup_window_mode_ = popup_window_mode; |
| 189 | 188 |
| 190 theme_service_ = GtkThemeService::GetFrom(profile_); | 189 Profile* profile = browser_->profile(); |
| 190 theme_service_ = GtkThemeService::GetFrom(profile); |
| 191 | 191 |
| 192 // Create the widget first, so we can pass it to the OmniboxViewGtk. | 192 // Create the widget first, so we can pass it to the OmniboxViewGtk. |
| 193 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 193 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); |
| 194 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); | 194 gtk_container_set_border_width(GTK_CONTAINER(hbox_.get()), kHboxBorder); |
| 195 // We will paint for the alignment, to paint the background and border. | 195 // We will paint for the alignment, to paint the background and border. |
| 196 gtk_widget_set_app_paintable(hbox_.get(), TRUE); | 196 gtk_widget_set_app_paintable(hbox_.get(), TRUE); |
| 197 // Redraw the whole location bar when it changes size (e.g., when toggling | 197 // Redraw the whole location bar when it changes size (e.g., when toggling |
| 198 // the home button on/off. | 198 // the home button on/off. |
| 199 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); | 199 gtk_widget_set_redraw_on_allocate(hbox_.get(), TRUE); |
| 200 | 200 |
| 201 // Now initialize the OmniboxViewGtk. | 201 // Now initialize the OmniboxViewGtk. |
| 202 location_entry_.reset(new OmniboxViewGtk(this, | 202 location_entry_.reset(new OmniboxViewGtk(this, toolbar_model_, profile, |
| 203 toolbar_model_, | 203 command_updater_, popup_window_mode_, hbox_.get())); |
| 204 profile_, | |
| 205 command_updater_, | |
| 206 popup_window_mode_, | |
| 207 hbox_.get())); | |
| 208 location_entry_->Init(); | 204 location_entry_->Init(); |
| 209 | 205 |
| 210 g_signal_connect(hbox_.get(), "expose-event", | 206 g_signal_connect(hbox_.get(), "expose-event", |
| 211 G_CALLBACK(&HandleExposeThunk), this); | 207 G_CALLBACK(&HandleExposeThunk), this); |
| 212 | 208 |
| 213 BuildSiteTypeArea(); | 209 BuildSiteTypeArea(); |
| 214 | 210 |
| 215 // Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into | 211 // Put |tab_to_search_box_|, |location_entry_|, and |tab_to_search_hint_| into |
| 216 // a sub hbox, so that we can make this part horizontally shrinkable without | 212 // a sub hbox, so that we can make this part horizontally shrinkable without |
| 217 // affecting other elements in the location bar. | 213 // affecting other elements in the location bar. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 302 |
| 307 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); | 303 content_setting_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding + 1)); |
| 308 gtk_widget_set_name(content_setting_hbox_.get(), | 304 gtk_widget_set_name(content_setting_hbox_.get(), |
| 309 "chrome-content-setting-hbox"); | 305 "chrome-content-setting-hbox"); |
| 310 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), | 306 gtk_box_pack_end(GTK_BOX(hbox_.get()), content_setting_hbox_.get(), |
| 311 FALSE, FALSE, 1); | 307 FALSE, FALSE, 1); |
| 312 | 308 |
| 313 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 309 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 314 ContentSettingImageViewGtk* content_setting_view = | 310 ContentSettingImageViewGtk* content_setting_view = |
| 315 new ContentSettingImageViewGtk( | 311 new ContentSettingImageViewGtk( |
| 316 static_cast<ContentSettingsType>(i), this, profile_); | 312 static_cast<ContentSettingsType>(i), this); |
| 317 content_setting_views_.push_back(content_setting_view); | 313 content_setting_views_.push_back(content_setting_view); |
| 318 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), | 314 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), |
| 319 content_setting_view->widget(), FALSE, FALSE, 0); | 315 content_setting_view->widget(), FALSE, FALSE, 0); |
| 320 } | 316 } |
| 321 | 317 |
| 322 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 318 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); |
| 323 gtk_widget_set_name(page_action_hbox_.get(), | 319 gtk_widget_set_name(page_action_hbox_.get(), |
| 324 "chrome-page-action-hbox"); | 320 "chrome-page-action-hbox"); |
| 325 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), | 321 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), |
| 326 FALSE, FALSE, 0); | 322 FALSE, FALSE, 0); |
| 327 | 323 |
| 328 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s | 324 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s |
| 329 // size-allocate so we can do proper resizing and eliding on | 325 // size-allocate so we can do proper resizing and eliding on |
| 330 // |security_info_label_|. | 326 // |security_info_label_|. |
| 331 g_signal_connect(hbox_.get(), "size-allocate", | 327 g_signal_connect(hbox_.get(), "size-allocate", |
| 332 G_CALLBACK(&OnHboxSizeAllocateThunk), this); | 328 G_CALLBACK(&OnHboxSizeAllocateThunk), this); |
| 333 | 329 |
| 334 registrar_.Add(this, | 330 registrar_.Add(this, |
| 335 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 331 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 336 Source<ThemeService>(theme_service_)); | 332 Source<ThemeService>(theme_service_)); |
| 337 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 333 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
| 338 profile_->GetPrefs(), this); | 334 profile->GetPrefs(), this); |
| 339 | 335 |
| 340 theme_service_->InitThemesFor(this); | 336 theme_service_->InitThemesFor(this); |
| 341 } | 337 } |
| 342 | 338 |
| 343 void LocationBarViewGtk::BuildSiteTypeArea() { | 339 void LocationBarViewGtk::BuildSiteTypeArea() { |
| 344 location_icon_image_ = gtk_image_new(); | 340 location_icon_image_ = gtk_image_new(); |
| 345 gtk_widget_set_name(location_icon_image_, "chrome-location-icon"); | 341 gtk_widget_set_name(location_icon_image_, "chrome-location-icon"); |
| 346 | 342 |
| 347 GtkWidget* icon_alignment = gtk_alignment_new(0, 0, 1, 1); | 343 GtkWidget* icon_alignment = gtk_alignment_new(0, 0, 1, 1); |
| 348 gtk_alignment_set_padding(GTK_ALIGNMENT(icon_alignment), 0, 0, 2, 0); | 344 gtk_alignment_set_padding(GTK_ALIGNMENT(icon_alignment), 0, 0, 2, 0); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 } | 403 } |
| 408 | 404 |
| 409 gtk_drag_source_set(site_type_event_box_, GDK_BUTTON1_MASK, | 405 gtk_drag_source_set(site_type_event_box_, GDK_BUTTON1_MASK, |
| 410 NULL, 0, GDK_ACTION_COPY); | 406 NULL, 0, GDK_ACTION_COPY); |
| 411 ui::SetSourceTargetListFromCodeMask(site_type_event_box_, | 407 ui::SetSourceTargetListFromCodeMask(site_type_event_box_, |
| 412 ui::TEXT_PLAIN | | 408 ui::TEXT_PLAIN | |
| 413 ui::TEXT_URI_LIST | | 409 ui::TEXT_URI_LIST | |
| 414 ui::CHROME_NAMED_URL); | 410 ui::CHROME_NAMED_URL); |
| 415 } | 411 } |
| 416 | 412 |
| 417 void LocationBarViewGtk::SetProfile(Profile* profile) { | |
| 418 profile_ = profile; | |
| 419 } | |
| 420 | |
| 421 TabContents* LocationBarViewGtk::GetTabContents() const { | 413 TabContents* LocationBarViewGtk::GetTabContents() const { |
| 422 return browser_->GetSelectedTabContents(); | 414 return browser_->GetSelectedTabContents(); |
| 423 } | 415 } |
| 424 | 416 |
| 425 void LocationBarViewGtk::SetPreviewEnabledPageAction( | 417 void LocationBarViewGtk::SetPreviewEnabledPageAction( |
| 426 ExtensionAction *page_action, | 418 ExtensionAction *page_action, |
| 427 bool preview_enabled) { | 419 bool preview_enabled) { |
| 428 DCHECK(page_action); | 420 DCHECK(page_action); |
| 429 UpdatePageActions(); | 421 UpdatePageActions(); |
| 430 for (ScopedVector<PageActionViewGtk>::iterator iter = | 422 for (ScopedVector<PageActionViewGtk>::iterator iter = |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 DCHECK(toolbar_model_->input_in_progress() != in_progress); | 539 DCHECK(toolbar_model_->input_in_progress() != in_progress); |
| 548 | 540 |
| 549 toolbar_model_->set_input_in_progress(in_progress); | 541 toolbar_model_->set_input_in_progress(in_progress); |
| 550 Update(NULL); | 542 Update(NULL); |
| 551 } | 543 } |
| 552 | 544 |
| 553 void LocationBarViewGtk::OnKillFocus() { | 545 void LocationBarViewGtk::OnKillFocus() { |
| 554 } | 546 } |
| 555 | 547 |
| 556 void LocationBarViewGtk::OnSetFocus() { | 548 void LocationBarViewGtk::OnSetFocus() { |
| 557 AccessibilityTextBoxInfo info( | 549 Profile* profile = browser_->profile(); |
| 558 profile_, | 550 AccessibilityTextBoxInfo info(profile, |
| 559 l10n_util::GetStringUTF8(IDS_ACCNAME_LOCATION).c_str(), | 551 l10n_util::GetStringUTF8(IDS_ACCNAME_LOCATION), false); |
| 560 false); | |
| 561 NotificationService::current()->Notify( | 552 NotificationService::current()->Notify( |
| 562 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, | 553 chrome::NOTIFICATION_ACCESSIBILITY_CONTROL_FOCUSED, |
| 563 Source<Profile>(profile_), | 554 Source<Profile>(profile), Details<AccessibilityTextBoxInfo>(&info)); |
| 564 Details<AccessibilityTextBoxInfo>(&info)); | |
| 565 | 555 |
| 566 // Update the keyword and search hint states. | 556 // Update the keyword and search hint states. |
| 567 OnChanged(); | 557 OnChanged(); |
| 568 } | 558 } |
| 569 | 559 |
| 570 SkBitmap LocationBarViewGtk::GetFavicon() const { | 560 SkBitmap LocationBarViewGtk::GetFavicon() const { |
| 571 return GetTabContentsWrapper()->favicon_tab_helper()->GetFavicon(); | 561 return GetTabContentsWrapper()->favicon_tab_helper()->GetFavicon(); |
| 572 } | 562 } |
| 573 | 563 |
| 574 string16 LocationBarViewGtk::GetTitle() const { | 564 string16 LocationBarViewGtk::GetTitle() const { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 any_visible = (*i)->IsVisible() || any_visible; | 624 any_visible = (*i)->IsVisible() || any_visible; |
| 635 } | 625 } |
| 636 | 626 |
| 637 // If there are no visible content things, hide the top level box so it | 627 // If there are no visible content things, hide the top level box so it |
| 638 // doesn't mess with padding. | 628 // doesn't mess with padding. |
| 639 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); | 629 gtk_widget_set_visible(content_setting_hbox_.get(), any_visible); |
| 640 } | 630 } |
| 641 | 631 |
| 642 void LocationBarViewGtk::UpdatePageActions() { | 632 void LocationBarViewGtk::UpdatePageActions() { |
| 643 std::vector<ExtensionAction*> page_actions; | 633 std::vector<ExtensionAction*> page_actions; |
| 644 ExtensionService* service = profile_->GetExtensionService(); | 634 ExtensionService* service = browser_->profile()->GetExtensionService(); |
| 645 if (!service) | 635 if (!service) |
| 646 return; | 636 return; |
| 647 | 637 |
| 648 // Find all the page actions. | 638 // Find all the page actions. |
| 649 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 639 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
| 650 if (service->extensions()->at(i)->page_action()) | 640 if (service->extensions()->at(i)->page_action()) |
| 651 page_actions.push_back(service->extensions()->at(i)->page_action()); | 641 page_actions.push_back(service->extensions()->at(i)->page_action()); |
| 652 } | 642 } |
| 653 | 643 |
| 654 // Initialize on the first call, or re-inialize if more extensions have been | 644 // Initialize on the first call, or re-inialize if more extensions have been |
| 655 // loaded or added after startup. | 645 // loaded or added after startup. |
| 656 if (page_actions.size() != page_action_views_.size()) { | 646 if (page_actions.size() != page_action_views_.size()) { |
| 657 page_action_views_.reset(); // Delete the old views (if any). | 647 page_action_views_.reset(); // Delete the old views (if any). |
| 658 | 648 |
| 659 for (size_t i = 0; i < page_actions.size(); ++i) { | 649 for (size_t i = 0; i < page_actions.size(); ++i) { |
| 660 page_action_views_.push_back( | 650 page_action_views_.push_back( |
| 661 new PageActionViewGtk(this, profile_, page_actions[i])); | 651 new PageActionViewGtk(this, page_actions[i])); |
| 662 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), | 652 gtk_box_pack_end(GTK_BOX(page_action_hbox_.get()), |
| 663 page_action_views_[i]->widget(), FALSE, FALSE, 0); | 653 page_action_views_[i]->widget(), FALSE, FALSE, 0); |
| 664 } | 654 } |
| 665 NotificationService::current()->Notify( | 655 NotificationService::current()->Notify( |
| 666 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 656 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 667 Source<LocationBar>(this), | 657 Source<LocationBar>(this), |
| 668 NotificationService::NoDetails()); | 658 NotificationService::NoDetails()); |
| 669 } | 659 } |
| 670 | 660 |
| 671 TabContents* contents = GetTabContents(); | 661 TabContents* contents = GetTabContents(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 807 |
| 818 UpdateStarIcon(); | 808 UpdateStarIcon(); |
| 819 UpdateSiteTypeArea(); | 809 UpdateSiteTypeArea(); |
| 820 UpdateContentSettingsIcons(); | 810 UpdateContentSettingsIcons(); |
| 821 } | 811 } |
| 822 | 812 |
| 823 gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget, | 813 gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget, |
| 824 GdkEventExpose* event) { | 814 GdkEventExpose* event) { |
| 825 // If we're not using GTK theming, draw our own border over the edge pixels | 815 // If we're not using GTK theming, draw our own border over the edge pixels |
| 826 // of the background. | 816 // of the background. |
| 827 if (!profile_ || | 817 if (!GtkThemeService::GetFrom(browser_->profile())->UsingNativeTheme()) { |
| 828 !GtkThemeService::GetFrom(profile_)->UsingNativeTheme()) { | |
| 829 int left, center, right; | 818 int left, center, right; |
| 830 if (popup_window_mode_) { | 819 if (popup_window_mode_) { |
| 831 left = right = IDR_LOCATIONBG_POPUPMODE_EDGE; | 820 left = right = IDR_LOCATIONBG_POPUPMODE_EDGE; |
| 832 center = IDR_LOCATIONBG_POPUPMODE_CENTER; | 821 center = IDR_LOCATIONBG_POPUPMODE_CENTER; |
| 833 } else { | 822 } else { |
| 834 left = IDR_LOCATIONBG_L; | 823 left = IDR_LOCATIONBG_L; |
| 835 center = IDR_LOCATIONBG_C; | 824 center = IDR_LOCATIONBG_C; |
| 836 right = IDR_LOCATIONBG_R; | 825 right = IDR_LOCATIONBG_R; |
| 837 } | 826 } |
| 838 | 827 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 gtk_label_set_max_width_chars(GTK_LABEL(security_info_label_), | 917 gtk_label_set_max_width_chars(GTK_LABEL(security_info_label_), |
| 929 std::max(10, max_chars)); | 918 std::max(10, max_chars)); |
| 930 | 919 |
| 931 pango_font_metrics_unref(metrics); | 920 pango_font_metrics_unref(metrics); |
| 932 } | 921 } |
| 933 | 922 |
| 934 void LocationBarViewGtk::SetKeywordLabel(const string16& keyword) { | 923 void LocationBarViewGtk::SetKeywordLabel(const string16& keyword) { |
| 935 if (keyword.empty()) | 924 if (keyword.empty()) |
| 936 return; | 925 return; |
| 937 | 926 |
| 938 DCHECK(profile_); | 927 Profile* profile = browser_->profile(); |
| 939 TemplateURLService* template_url_service = | 928 TemplateURLService* template_url_service = |
| 940 TemplateURLServiceFactory::GetForProfile(profile_); | 929 TemplateURLServiceFactory::GetForProfile(profile); |
| 941 if (!template_url_service) | 930 if (!template_url_service) |
| 942 return; | 931 return; |
| 943 | 932 |
| 944 bool is_extension_keyword; | 933 bool is_extension_keyword; |
| 945 const string16 short_name = template_url_service-> | 934 const string16 short_name = template_url_service-> |
| 946 GetKeywordShortName(keyword, &is_extension_keyword); | 935 GetKeywordShortName(keyword, &is_extension_keyword); |
| 947 int message_id = is_extension_keyword ? | 936 int message_id = is_extension_keyword ? |
| 948 IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT; | 937 IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT; |
| 949 string16 full_name = l10n_util::GetStringFUTF16(message_id, | 938 string16 full_name = l10n_util::GetStringFUTF16(message_id, |
| 950 short_name); | 939 short_name); |
| 951 string16 partial_name = l10n_util::GetStringFUTF16( | 940 string16 partial_name = l10n_util::GetStringFUTF16( |
| 952 message_id, | 941 message_id, |
| 953 WideToUTF16Hack( | 942 WideToUTF16Hack( |
| 954 location_bar_util::CalculateMinString(UTF16ToWideHack(short_name)))); | 943 location_bar_util::CalculateMinString(UTF16ToWideHack(short_name)))); |
| 955 gtk_label_set_text(GTK_LABEL(tab_to_search_full_label_), | 944 gtk_label_set_text(GTK_LABEL(tab_to_search_full_label_), |
| 956 UTF16ToUTF8(full_name).c_str()); | 945 UTF16ToUTF8(full_name).c_str()); |
| 957 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_), | 946 gtk_label_set_text(GTK_LABEL(tab_to_search_partial_label_), |
| 958 UTF16ToUTF8(partial_name).c_str()); | 947 UTF16ToUTF8(partial_name).c_str()); |
| 959 | 948 |
| 960 if (last_keyword_ != keyword) { | 949 if (last_keyword_ != keyword) { |
| 961 last_keyword_ = keyword; | 950 last_keyword_ = keyword; |
| 962 | 951 |
| 963 if (is_extension_keyword) { | 952 if (is_extension_keyword) { |
| 964 const TemplateURL* template_url = | 953 const TemplateURL* template_url = |
| 965 template_url_service->GetTemplateURLForKeyword(keyword); | 954 template_url_service->GetTemplateURLForKeyword(keyword); |
| 966 const SkBitmap& bitmap = profile_->GetExtensionService()-> | 955 const SkBitmap& bitmap = profile->GetExtensionService()-> |
| 967 GetOmniboxIcon(template_url->GetExtensionId()); | 956 GetOmniboxIcon(template_url->GetExtensionId()); |
| 968 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); | 957 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); |
| 969 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); | 958 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); |
| 970 g_object_unref(pixbuf); | 959 g_object_unref(pixbuf); |
| 971 } else { | 960 } else { |
| 972 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 961 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 973 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), | 962 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), |
| 974 rb.GetNativeImageNamed(IDR_OMNIBOX_SEARCH)); | 963 rb.GetNativeImageNamed(IDR_OMNIBOX_SEARCH)); |
| 975 } | 964 } |
| 976 } | 965 } |
| 977 } | 966 } |
| 978 | 967 |
| 979 void LocationBarViewGtk::SetKeywordHintLabel(const string16& keyword) { | 968 void LocationBarViewGtk::SetKeywordHintLabel(const string16& keyword) { |
| 980 if (keyword.empty()) | 969 if (keyword.empty()) |
| 981 return; | 970 return; |
| 982 | 971 |
| 983 DCHECK(profile_); | |
| 984 TemplateURLService* template_url_service = | 972 TemplateURLService* template_url_service = |
| 985 TemplateURLServiceFactory::GetForProfile(profile_); | 973 TemplateURLServiceFactory::GetForProfile(browser_->profile()); |
| 986 if (!template_url_service) | 974 if (!template_url_service) |
| 987 return; | 975 return; |
| 988 | 976 |
| 989 bool is_extension_keyword; | 977 bool is_extension_keyword; |
| 990 const string16 short_name = template_url_service-> | 978 const string16 short_name = template_url_service-> |
| 991 GetKeywordShortName(keyword, &is_extension_keyword); | 979 GetKeywordShortName(keyword, &is_extension_keyword); |
| 992 int message_id = is_extension_keyword ? | 980 int message_id = is_extension_keyword ? |
| 993 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; | 981 IDS_OMNIBOX_EXTENSION_KEYWORD_HINT : IDS_OMNIBOX_KEYWORD_HINT; |
| 994 std::vector<size_t> content_param_offsets; | 982 std::vector<size_t> content_param_offsets; |
| 995 const string16 keyword_hint = l10n_util::GetStringFUTF16( | 983 const string16 keyword_hint = l10n_util::GetStringFUTF16( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1014 } | 1002 } |
| 1015 | 1003 |
| 1016 void LocationBarViewGtk::ShowFirstRunBubbleInternal( | 1004 void LocationBarViewGtk::ShowFirstRunBubbleInternal( |
| 1017 FirstRun::BubbleType bubble_type) { | 1005 FirstRun::BubbleType bubble_type) { |
| 1018 if (!location_entry_.get() || !widget()->window) | 1006 if (!location_entry_.get() || !widget()->window) |
| 1019 return; | 1007 return; |
| 1020 | 1008 |
| 1021 gfx::Rect bounds = gtk_util::WidgetBounds(location_icon_image_); | 1009 gfx::Rect bounds = gtk_util::WidgetBounds(location_icon_image_); |
| 1022 bounds.set_x(bounds.x() + kFirstRunBubbleLeftSpacing); | 1010 bounds.set_x(bounds.x() + kFirstRunBubbleLeftSpacing); |
| 1023 | 1011 |
| 1024 FirstRunBubble::Show(profile_, location_icon_image_, bounds, bubble_type); | 1012 FirstRunBubble::Show(browser_->profile(), location_icon_image_, bounds, |
| 1013 bubble_type); |
| 1025 } | 1014 } |
| 1026 | 1015 |
| 1027 gboolean LocationBarViewGtk::OnIconReleased(GtkWidget* sender, | 1016 gboolean LocationBarViewGtk::OnIconReleased(GtkWidget* sender, |
| 1028 GdkEventButton* event) { | 1017 GdkEventButton* event) { |
| 1029 TabContents* tab = GetTabContents(); | 1018 TabContents* tab = GetTabContents(); |
| 1030 | 1019 |
| 1031 if (event->button == 1) { | 1020 if (event->button == 1) { |
| 1032 // Do not show page info if the user has been editing the location | 1021 // Do not show page info if the user has been editing the location |
| 1033 // bar, or the location bar is at the NTP. | 1022 // bar, or the location bar is at the NTP. |
| 1034 if (location_entry()->IsEditingOrEmpty()) | 1023 if (location_entry()->IsEditingOrEmpty()) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1049 } else if (event->button == 2) { | 1038 } else if (event->button == 2) { |
| 1050 // When the user middle clicks on the location icon, try to open the | 1039 // When the user middle clicks on the location icon, try to open the |
| 1051 // contents of the PRIMARY selection in the current tab. | 1040 // contents of the PRIMARY selection in the current tab. |
| 1052 // If the click was outside our bounds, do nothing. | 1041 // If the click was outside our bounds, do nothing. |
| 1053 if (!gtk_util::WidgetBounds(sender).Contains( | 1042 if (!gtk_util::WidgetBounds(sender).Contains( |
| 1054 gfx::Point(event->x, event->y))) { | 1043 gfx::Point(event->x, event->y))) { |
| 1055 return FALSE; | 1044 return FALSE; |
| 1056 } | 1045 } |
| 1057 | 1046 |
| 1058 GURL url; | 1047 GURL url; |
| 1059 if (!gtk_util::URLFromPrimarySelection(profile_, &url)) | 1048 if (!gtk_util::URLFromPrimarySelection(browser_->profile(), &url)) |
| 1060 return FALSE; | 1049 return FALSE; |
| 1061 | 1050 |
| 1062 tab->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 1051 tab->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); |
| 1063 return TRUE; | 1052 return TRUE; |
| 1064 } | 1053 } |
| 1065 | 1054 |
| 1066 return FALSE; | 1055 return FALSE; |
| 1067 } | 1056 } |
| 1068 | 1057 |
| 1069 void LocationBarViewGtk::OnIconDragData(GtkWidget* sender, | 1058 void LocationBarViewGtk::OnIconDragData(GtkWidget* sender, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 return FALSE; | 1107 return FALSE; |
| 1119 } | 1108 } |
| 1120 return TRUE; | 1109 return TRUE; |
| 1121 } | 1110 } |
| 1122 | 1111 |
| 1123 void LocationBarViewGtk::ShowStarBubble(const GURL& url, | 1112 void LocationBarViewGtk::ShowStarBubble(const GURL& url, |
| 1124 bool newly_bookmarked) { | 1113 bool newly_bookmarked) { |
| 1125 if (!star_.get()) | 1114 if (!star_.get()) |
| 1126 return; | 1115 return; |
| 1127 | 1116 |
| 1128 BookmarkBubbleGtk::Show(star_.get(), profile_, url, newly_bookmarked); | 1117 BookmarkBubbleGtk::Show(star_.get(), browser_->profile(), url, |
| 1118 newly_bookmarked); |
| 1129 } | 1119 } |
| 1130 | 1120 |
| 1131 void LocationBarViewGtk::SetStarred(bool starred) { | 1121 void LocationBarViewGtk::SetStarred(bool starred) { |
| 1132 if (starred == starred_) | 1122 if (starred == starred_) |
| 1133 return; | 1123 return; |
| 1134 | 1124 |
| 1135 starred_ = starred; | 1125 starred_ = starred; |
| 1136 UpdateStarIcon(); | 1126 UpdateStarIcon(); |
| 1137 } | 1127 } |
| 1138 | 1128 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 gtk_widget_show(tab_to_search_hint_trailing_label_); | 1205 gtk_widget_show(tab_to_search_hint_trailing_label_); |
| 1216 gtk_widget_show(tab_to_search_hint_); | 1206 gtk_widget_show(tab_to_search_hint_); |
| 1217 } | 1207 } |
| 1218 } | 1208 } |
| 1219 } | 1209 } |
| 1220 | 1210 |
| 1221 //////////////////////////////////////////////////////////////////////////////// | 1211 //////////////////////////////////////////////////////////////////////////////// |
| 1222 // LocationBarViewGtk::ContentSettingImageViewGtk | 1212 // LocationBarViewGtk::ContentSettingImageViewGtk |
| 1223 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( | 1213 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( |
| 1224 ContentSettingsType content_type, | 1214 ContentSettingsType content_type, |
| 1225 const LocationBarViewGtk* parent, | 1215 const LocationBarViewGtk* parent) |
| 1226 Profile* profile) | |
| 1227 : content_setting_image_model_( | 1216 : content_setting_image_model_( |
| 1228 ContentSettingImageModel::CreateContentSettingImageModel( | 1217 ContentSettingImageModel::CreateContentSettingImageModel( |
| 1229 content_type)), | 1218 content_type)), |
| 1230 alignment_(gtk_alignment_new(0, 0, 1, 1)), | 1219 alignment_(gtk_alignment_new(0, 0, 1, 1)), |
| 1231 event_box_(gtk_event_box_new()), | 1220 event_box_(gtk_event_box_new()), |
| 1232 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), | 1221 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), |
| 1233 image_(gtk_image_new()), | 1222 image_(gtk_image_new()), |
| 1234 label_(gtk_label_new(NULL)), | 1223 label_(gtk_label_new(NULL)), |
| 1235 parent_(parent), | 1224 parent_(parent), |
| 1236 profile_(profile), | |
| 1237 content_setting_bubble_(NULL), | 1225 content_setting_bubble_(NULL), |
| 1238 animation_(this), | 1226 animation_(this), |
| 1239 method_factory_(this) { | 1227 method_factory_(this) { |
| 1240 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); | 1228 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); |
| 1241 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); | 1229 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); |
| 1242 | 1230 |
| 1243 // Make the event box not visible so it does not paint a background. | 1231 // Make the event box not visible so it does not paint a background. |
| 1244 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | 1232 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); |
| 1245 g_signal_connect(event_box_.get(), "button-press-event", | 1233 g_signal_connect(event_box_.get(), "button-press-event", |
| 1246 G_CALLBACK(&OnButtonPressedThunk), this); | 1234 G_CALLBACK(&OnButtonPressedThunk), this); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1277 | 1265 |
| 1278 void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents( | 1266 void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents( |
| 1279 TabContents* tab_contents) { | 1267 TabContents* tab_contents) { |
| 1280 content_setting_image_model_->UpdateFromTabContents(tab_contents); | 1268 content_setting_image_model_->UpdateFromTabContents(tab_contents); |
| 1281 if (!content_setting_image_model_->is_visible()) { | 1269 if (!content_setting_image_model_->is_visible()) { |
| 1282 gtk_widget_hide(widget()); | 1270 gtk_widget_hide(widget()); |
| 1283 return; | 1271 return; |
| 1284 } | 1272 } |
| 1285 | 1273 |
| 1286 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), | 1274 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), |
| 1287 GtkThemeService::GetFrom(profile_)->GetPixbufNamed( | 1275 GtkThemeService::GetFrom(parent_->browser()->profile())->GetPixbufNamed( |
| 1288 content_setting_image_model_->get_icon())); | 1276 content_setting_image_model_->get_icon())); |
| 1289 | 1277 |
| 1290 gtk_widget_set_tooltip_text(widget(), | 1278 gtk_widget_set_tooltip_text(widget(), |
| 1291 content_setting_image_model_->get_tooltip().c_str()); | 1279 content_setting_image_model_->get_tooltip().c_str()); |
| 1292 gtk_widget_show_all(widget()); | 1280 gtk_widget_show_all(widget()); |
| 1293 | 1281 |
| 1294 TabSpecificContentSettings* content_settings = NULL; | 1282 TabSpecificContentSettings* content_settings = NULL; |
| 1295 if (tab_contents) { | 1283 if (tab_contents) { |
| 1296 content_settings = TabContentsWrapper::GetCurrentWrapperForContents( | 1284 content_settings = TabContentsWrapper::GetCurrentWrapperForContents( |
| 1297 tab_contents)->content_settings(); | 1285 tab_contents)->content_settings(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 | 1349 |
| 1362 void LocationBarViewGtk::ContentSettingImageViewGtk::AnimationCanceled( | 1350 void LocationBarViewGtk::ContentSettingImageViewGtk::AnimationCanceled( |
| 1363 const ui::Animation* animation) { | 1351 const ui::Animation* animation) { |
| 1364 } | 1352 } |
| 1365 | 1353 |
| 1366 gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnButtonPressed( | 1354 gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnButtonPressed( |
| 1367 GtkWidget* sender, GdkEvent* event) { | 1355 GtkWidget* sender, GdkEvent* event) { |
| 1368 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); | 1356 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); |
| 1369 if (!tab_contents) | 1357 if (!tab_contents) |
| 1370 return TRUE; | 1358 return TRUE; |
| 1359 Profile* profile = parent_->browser()->profile(); |
| 1371 content_setting_bubble_ = new ContentSettingBubbleGtk( | 1360 content_setting_bubble_ = new ContentSettingBubbleGtk( |
| 1372 sender, this, | 1361 sender, this, |
| 1373 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 1362 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 1374 parent_->browser(), tab_contents, profile_, | 1363 parent_->browser(), tab_contents, profile, |
| 1375 content_setting_image_model_->get_content_settings_type()), | 1364 content_setting_image_model_->get_content_settings_type()), |
| 1376 profile_, tab_contents->tab_contents()); | 1365 profile, tab_contents->tab_contents()); |
| 1377 return TRUE; | 1366 return TRUE; |
| 1378 } | 1367 } |
| 1379 | 1368 |
| 1380 gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnExpose( | 1369 gboolean LocationBarViewGtk::ContentSettingImageViewGtk::OnExpose( |
| 1381 GtkWidget* sender, GdkEventExpose* event) { | 1370 GtkWidget* sender, GdkEventExpose* event) { |
| 1382 if (!(animation_.IsShowing() || animation_.IsClosing())) | 1371 if (!(animation_.IsShowing() || animation_.IsClosing())) |
| 1383 return FALSE; | 1372 return FALSE; |
| 1384 | 1373 |
| 1385 const int height = sender->allocation.height; | 1374 const int height = sender->allocation.height; |
| 1386 | 1375 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1409 void LocationBarViewGtk::ContentSettingImageViewGtk::BubbleClosing( | 1398 void LocationBarViewGtk::ContentSettingImageViewGtk::BubbleClosing( |
| 1410 BubbleGtk* bubble, | 1399 BubbleGtk* bubble, |
| 1411 bool closed_by_escape) { | 1400 bool closed_by_escape) { |
| 1412 content_setting_bubble_ = NULL; | 1401 content_setting_bubble_ = NULL; |
| 1413 } | 1402 } |
| 1414 | 1403 |
| 1415 //////////////////////////////////////////////////////////////////////////////// | 1404 //////////////////////////////////////////////////////////////////////////////// |
| 1416 // LocationBarViewGtk::PageActionViewGtk | 1405 // LocationBarViewGtk::PageActionViewGtk |
| 1417 | 1406 |
| 1418 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( | 1407 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( |
| 1419 LocationBarViewGtk* owner, Profile* profile, | 1408 LocationBarViewGtk* owner, |
| 1420 ExtensionAction* page_action) | 1409 ExtensionAction* page_action) |
| 1421 : owner_(NULL), | 1410 : owner_(NULL), |
| 1422 profile_(profile), | |
| 1423 page_action_(page_action), | 1411 page_action_(page_action), |
| 1424 last_icon_pixbuf_(NULL), | 1412 last_icon_pixbuf_(NULL), |
| 1425 tracker_(this), | 1413 tracker_(this), |
| 1426 preview_enabled_(false) { | 1414 preview_enabled_(false) { |
| 1427 event_box_.Own(gtk_event_box_new()); | 1415 event_box_.Own(gtk_event_box_new()); |
| 1428 gtk_widget_set_size_request(event_box_.get(), | 1416 gtk_widget_set_size_request(event_box_.get(), |
| 1429 Extension::kPageActionIconMaxSize, | 1417 Extension::kPageActionIconMaxSize, |
| 1430 Extension::kPageActionIconMaxSize); | 1418 Extension::kPageActionIconMaxSize); |
| 1431 | 1419 |
| 1432 // Make the event box not visible so it does not paint a background. | 1420 // Make the event box not visible so it does not paint a background. |
| 1433 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | 1421 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); |
| 1434 g_signal_connect(event_box_.get(), "button-press-event", | 1422 g_signal_connect(event_box_.get(), "button-press-event", |
| 1435 G_CALLBACK(&OnButtonPressedThunk), this); | 1423 G_CALLBACK(&OnButtonPressedThunk), this); |
| 1436 g_signal_connect_after(event_box_.get(), "expose-event", | 1424 g_signal_connect_after(event_box_.get(), "expose-event", |
| 1437 G_CALLBACK(OnExposeEventThunk), this); | 1425 G_CALLBACK(OnExposeEventThunk), this); |
| 1438 | 1426 |
| 1439 image_.Own(gtk_image_new()); | 1427 image_.Own(gtk_image_new()); |
| 1440 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); | 1428 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); |
| 1441 | 1429 |
| 1442 const Extension* extension = profile->GetExtensionService()-> | 1430 const Extension* extension = owner->browser()->profile()-> |
| 1443 GetExtensionById(page_action->extension_id(), false); | 1431 GetExtensionService()->GetExtensionById(page_action->extension_id(), |
| 1432 false); |
| 1444 DCHECK(extension); | 1433 DCHECK(extension); |
| 1445 | 1434 |
| 1446 // Load all the icons declared in the manifest. This is the contents of the | 1435 // Load all the icons declared in the manifest. This is the contents of the |
| 1447 // icons array, plus the default_icon property, if any. | 1436 // icons array, plus the default_icon property, if any. |
| 1448 std::vector<std::string> icon_paths(*page_action->icon_paths()); | 1437 std::vector<std::string> icon_paths(*page_action->icon_paths()); |
| 1449 if (!page_action_->default_icon_path().empty()) | 1438 if (!page_action_->default_icon_path().empty()) |
| 1450 icon_paths.push_back(page_action_->default_icon_path()); | 1439 icon_paths.push_back(page_action_->default_icon_path()); |
| 1451 | 1440 |
| 1452 for (std::vector<std::string>::iterator iter = icon_paths.begin(); | 1441 for (std::vector<std::string>::iterator iter = icon_paths.begin(); |
| 1453 iter != icon_paths.end(); ++iter) { | 1442 iter != icon_paths.end(); ++iter) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 page_action_->GetPopupUrl(current_tab_id_), | 1578 page_action_->GetPopupUrl(current_tab_id_), |
| 1590 owner_->browser_, | 1579 owner_->browser_, |
| 1591 event_box_.get(), | 1580 event_box_.get(), |
| 1592 devtools); | 1581 devtools); |
| 1593 return true; | 1582 return true; |
| 1594 } | 1583 } |
| 1595 | 1584 |
| 1596 gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed( | 1585 gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed( |
| 1597 GtkWidget* sender, | 1586 GtkWidget* sender, |
| 1598 GdkEventButton* event) { | 1587 GdkEventButton* event) { |
| 1588 Profile* profile = owner_->browser()->profile(); |
| 1599 if (event->button != 3) { | 1589 if (event->button != 3) { |
| 1600 if (!ShowPopup(false)) { | 1590 if (!ShowPopup(false)) { |
| 1601 ExtensionService* service = profile_->GetExtensionService(); | 1591 ExtensionService* service = profile->GetExtensionService(); |
| 1602 service->browser_event_router()->PageActionExecuted( | 1592 service->browser_event_router()->PageActionExecuted(profile, |
| 1603 profile_, | 1593 page_action_->extension_id(), page_action_->id(), current_tab_id_, |
| 1604 page_action_->extension_id(), | 1594 current_url_.spec(), event->button); |
| 1605 page_action_->id(), | |
| 1606 current_tab_id_, | |
| 1607 current_url_.spec(), | |
| 1608 event->button); | |
| 1609 } | 1595 } |
| 1610 } else { | 1596 } else { |
| 1611 const Extension* extension = profile_->GetExtensionService()-> | 1597 const Extension* extension = profile->GetExtensionService()-> |
| 1612 GetExtensionById(page_action()->extension_id(), false); | 1598 GetExtensionById(page_action()->extension_id(), false); |
| 1613 | 1599 |
| 1614 if (extension->ShowConfigureContextMenus()) { | 1600 if (extension->ShowConfigureContextMenus()) { |
| 1615 context_menu_model_ = | 1601 context_menu_model_ = |
| 1616 new ExtensionContextMenuModel(extension, owner_->browser_, this); | 1602 new ExtensionContextMenuModel(extension, owner_->browser_, this); |
| 1617 context_menu_.reset( | 1603 context_menu_.reset( |
| 1618 new MenuGtk(NULL, context_menu_model_.get())); | 1604 new MenuGtk(NULL, context_menu_model_.get())); |
| 1619 context_menu_->PopupForWidget(sender, event->button, event->time); | 1605 context_menu_->PopupForWidget(sender, event->button, event->time); |
| 1620 } | 1606 } |
| 1621 } | 1607 } |
| 1622 | 1608 |
| 1623 return TRUE; | 1609 return TRUE; |
| 1624 } | 1610 } |
| 1625 | 1611 |
| 1626 gboolean LocationBarViewGtk::PageActionViewGtk::OnExposeEvent( | 1612 gboolean LocationBarViewGtk::PageActionViewGtk::OnExposeEvent( |
| 1627 GtkWidget* widget, GdkEventExpose* event) { | 1613 GtkWidget* widget, |
| 1614 GdkEventExpose* event) { |
| 1628 TabContents* contents = owner_->GetTabContents(); | 1615 TabContents* contents = owner_->GetTabContents(); |
| 1629 if (!contents) | 1616 if (!contents) |
| 1630 return FALSE; | 1617 return FALSE; |
| 1631 | 1618 |
| 1632 int tab_id = ExtensionTabUtil::GetTabId(contents); | 1619 int tab_id = ExtensionTabUtil::GetTabId(contents); |
| 1633 if (tab_id < 0) | 1620 if (tab_id < 0) |
| 1634 return FALSE; | 1621 return FALSE; |
| 1635 | 1622 |
| 1636 std::string badge_text = page_action_->GetBadgeText(tab_id); | 1623 std::string badge_text = page_action_->GetBadgeText(tab_id); |
| 1637 if (badge_text.empty()) | 1624 if (badge_text.empty()) |
| 1638 return FALSE; | 1625 return FALSE; |
| 1639 | 1626 |
| 1640 gfx::CanvasSkiaPaint canvas(event, false); | 1627 gfx::CanvasSkiaPaint canvas(event, false); |
| 1641 gfx::Rect bounding_rect(widget->allocation); | 1628 gfx::Rect bounding_rect(widget->allocation); |
| 1642 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); | 1629 page_action_->PaintBadge(&canvas, bounding_rect, tab_id); |
| 1643 return FALSE; | 1630 return FALSE; |
| 1644 } | 1631 } |
| OLD | NEW |