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

Side by Side Diff: chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.cc

Issue 10910064: Extension Commands: Add [Manage Shortcuts] link to the Extension Install Bubble (Views and GTK only) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
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/extensions/extension_installed_bubble_gtk.h" 5 #include "chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/extensions/api/commands/command_service.h" 14 #include "chrome/browser/extensions/api/commands/command_service.h"
15 #include "chrome/browser/extensions/api/commands/command_service_factory.h" 15 #include "chrome/browser/extensions/api/commands/command_service_factory.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_dialogs.h" 17 #include "chrome/browser/ui/browser_dialogs.h"
18 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" 18 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h"
19 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" 19 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
20 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 20 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
21 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 21 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
22 #include "chrome/browser/ui/gtk/gtk_util.h" 22 #include "chrome/browser/ui/gtk/gtk_util.h"
23 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" 23 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
24 #include "chrome/browser/ui/singleton_tabs.h"
24 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/extensions/extension.h" 26 #include "chrome/common/extensions/extension.h"
26 #include "chrome/common/extensions/extension_action.h" 27 #include "chrome/common/extensions/extension_action.h"
28 #include "chrome/common/url_constants.h"
27 #include "content/public/browser/notification_details.h" 29 #include "content/public/browser/notification_details.h"
28 #include "content/public/browser/notification_source.h" 30 #include "content/public/browser/notification_source.h"
29 #include "grit/chromium_strings.h" 31 #include "grit/chromium_strings.h"
30 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
31 #include "grit/theme_resources.h" 33 #include "grit/theme_resources.h"
32 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
34 #include "ui/gfx/gtk_util.h" 36 #include "ui/gfx/gtk_util.h"
35 37
36 using extensions::Extension; 38 using extensions::Extension;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // Omnibox keyword label. 287 // Omnibox keyword label.
286 if (type_ == OMNIBOX_KEYWORD) { 288 if (type_ == OMNIBOX_KEYWORD) {
287 GtkWidget* info_label = gtk_label_new(l10n_util::GetStringFUTF8( 289 GtkWidget* info_label = gtk_label_new(l10n_util::GetStringFUTF8(
288 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, 290 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO,
289 UTF8ToUTF16(extension_->omnibox_keyword())).c_str()); 291 UTF8ToUTF16(extension_->omnibox_keyword())).c_str());
290 gtk_util::SetLabelWidth(info_label, kTextColumnWidth); 292 gtk_util::SetLabelWidth(info_label, kTextColumnWidth);
291 gtk_box_pack_start(GTK_BOX(text_column), info_label, FALSE, FALSE, 0); 293 gtk_box_pack_start(GTK_BOX(text_column), info_label, FALSE, FALSE, 0);
292 } 294 }
293 295
294 if (has_keybinding) { 296 if (has_keybinding) {
295 // TODO(finnur): Show the shortcut link. 297 GtkWidget* manage_link = theme_provider->BuildChromeLinkButton(
298 l10n_util::GetStringUTF8(IDS_EXTENSION_INSTALLED_MANAGE_SHORTCUTS));
299 GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0);
300 // Stick it in an hbox so it doesn't expand to the whole width.
301 gtk_box_pack_end(GTK_BOX(link_hbox), manage_link, FALSE, FALSE, 0);
302 gtk_box_pack_start(GTK_BOX(text_column), link_hbox, FALSE, FALSE, 0);
303 g_signal_connect(manage_link, "clicked",
304 G_CALLBACK(OnLinkClickedThunk), this);
296 } else { 305 } else {
297 // Manage label. 306 // Manage label.
298 GtkWidget* manage_label = gtk_label_new( 307 GtkWidget* manage_label = gtk_label_new(
299 l10n_util::GetStringUTF8(IDS_EXTENSION_INSTALLED_MANAGE_INFO).c_str()); 308 l10n_util::GetStringUTF8(IDS_EXTENSION_INSTALLED_MANAGE_INFO).c_str());
300 gtk_util::SetLabelWidth(manage_label, kTextColumnWidth); 309 gtk_util::SetLabelWidth(manage_label, kTextColumnWidth);
301 gtk_box_pack_start(GTK_BOX(text_column), manage_label, FALSE, FALSE, 0); 310 gtk_box_pack_start(GTK_BOX(text_column), manage_label, FALSE, FALSE, 0);
302 } 311 }
303 312
304 // Create and pack the close button. 313 // Create and pack the close button.
305 GtkWidget* close_column = gtk_vbox_new(FALSE, 0); 314 GtkWidget* close_column = gtk_vbox_new(FALSE, 0);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 351
343 // static 352 // static
344 void ExtensionInstalledBubbleGtk::OnButtonClick(GtkWidget* button, 353 void ExtensionInstalledBubbleGtk::OnButtonClick(GtkWidget* button,
345 ExtensionInstalledBubbleGtk* bubble) { 354 ExtensionInstalledBubbleGtk* bubble) {
346 if (button == bubble->close_button_->widget()) { 355 if (button == bubble->close_button_->widget()) {
347 bubble->bubble_->Close(); 356 bubble->bubble_->Close();
348 } else { 357 } else {
349 NOTREACHED(); 358 NOTREACHED();
350 } 359 }
351 } 360 }
361
362 void ExtensionInstalledBubbleGtk::OnLinkClicked(GtkWidget* widget) {
363 bubble_->Close();
364
365 std::string configure_url = chrome::kChromeUIExtensionsURL;
366 configure_url += chrome::kExtensionConfigureCommandsSubPage;
367 chrome::NavigateParams params(
368 chrome::GetSingletonTabNavigateParams(
369 browser_, GURL(configure_url.c_str())));
370 chrome::Navigate(&params);
371 }
372
352 void ExtensionInstalledBubbleGtk::BubbleClosing(BubbleGtk* bubble, 373 void ExtensionInstalledBubbleGtk::BubbleClosing(BubbleGtk* bubble,
353 bool closed_by_escape) { 374 bool closed_by_escape) {
354 if (extension_ && type_ == PAGE_ACTION) { 375 if (extension_ && type_ == PAGE_ACTION) {
355 // Turn the page action preview off. 376 // Turn the page action preview off.
356 BrowserWindowGtk* browser_window = 377 BrowserWindowGtk* browser_window =
357 BrowserWindowGtk::GetBrowserWindowForNativeWindow( 378 BrowserWindowGtk::GetBrowserWindowForNativeWindow(
358 browser_->window()->GetNativeWindow()); 379 browser_->window()->GetNativeWindow());
359 LocationBarViewGtk* location_bar_view = 380 LocationBarViewGtk* location_bar_view =
360 browser_window->GetToolbar()->GetLocationBarView(); 381 browser_window->GetToolbar()->GetLocationBarView();
361 location_bar_view->SetPreviewEnabledPageAction(extension_->page_action(), 382 location_bar_view->SetPreviewEnabledPageAction(extension_->page_action(),
362 false); // preview_enabled 383 false); // preview_enabled
363 } 384 }
364 385
365 // We need to allow the bubble to close and remove the widgets from 386 // We need to allow the bubble to close and remove the widgets from
366 // the window before we call Release() because close_button_ depends 387 // the window before we call Release() because close_button_ depends
367 // on all references being cleared before it is destroyed. 388 // on all references being cleared before it is destroyed.
368 MessageLoopForUI::current()->PostTask( 389 MessageLoopForUI::current()->PostTask(
369 FROM_HERE, 390 FROM_HERE,
370 base::Bind(&ExtensionInstalledBubbleGtk::Close, this)); 391 base::Bind(&ExtensionInstalledBubbleGtk::Close, this));
371 } 392 }
372 393
373 void ExtensionInstalledBubbleGtk::Close() { 394 void ExtensionInstalledBubbleGtk::Close() {
374 Release(); // Balanced in ctor. 395 Release(); // Balanced in ctor.
375 bubble_ = NULL; 396 bubble_ = NULL;
376 } 397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698