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

Side by Side Diff: chrome/browser/ui/views/toolbar_view.cc

Issue 11189094: Implement sideload wipeout for Extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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/views/toolbar_view.h" 5 #include "chrome/browser/ui/views/toolbar_view.h"
6 6
7 #include "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/command_updater.h" 10 #include "chrome/browser/command_updater.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/ui/omnibox/omnibox_view.h" 25 #include "chrome/browser/ui/omnibox/omnibox_view.h"
26 #include "chrome/browser/ui/search/search.h" 26 #include "chrome/browser/ui/search/search.h"
27 #include "chrome/browser/ui/search/search_model.h" 27 #include "chrome/browser/ui/search/search_model.h"
28 #include "chrome/browser/ui/search/search_tab_helper.h" 28 #include "chrome/browser/ui/search/search_tab_helper.h"
29 #include "chrome/browser/ui/search/search_types.h" 29 #include "chrome/browser/ui/search/search_types.h"
30 #include "chrome/browser/ui/search/search_ui.h" 30 #include "chrome/browser/ui/search/search_ui.h"
31 #include "chrome/browser/ui/tab_contents/tab_contents.h" 31 #include "chrome/browser/ui/tab_contents/tab_contents.h"
32 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 32 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
33 #include "chrome/browser/ui/view_ids.h" 33 #include "chrome/browser/ui/view_ids.h"
34 #include "chrome/browser/ui/views/browser_actions_container.h" 34 #include "chrome/browser/ui/views/browser_actions_container.h"
35 #include "chrome/browser/ui/views/extensions/disabled_extensions_view.h"
35 #include "chrome/browser/ui/views/location_bar/location_bar_container.h" 36 #include "chrome/browser/ui/views/location_bar/location_bar_container.h"
36 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 37 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
37 #include "chrome/browser/ui/views/wrench_menu.h" 38 #include "chrome/browser/ui/views/wrench_menu.h"
38 #include "chrome/browser/upgrade_detector.h" 39 #include "chrome/browser/upgrade_detector.h"
39 #include "chrome/common/chrome_notification_types.h" 40 #include "chrome/common/chrome_notification_types.h"
40 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
41 #include "content/public/browser/browser_accessibility_state.h" 42 #include "content/public/browser/browser_accessibility_state.h"
42 #include "content/public/browser/notification_service.h" 43 #include "content/public/browser/notification_service.h"
43 #include "content/public/browser/render_view_host.h" 44 #include "content/public/browser/render_view_host.h"
44 #include "content/public/browser/user_metrics.h" 45 #include "content/public/browser/user_metrics.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 104
104 // Top margin for the wrench menu badges (badge is placed in the upper right 105 // Top margin for the wrench menu badges (badge is placed in the upper right
105 // corner of the wrench menu). 106 // corner of the wrench menu).
106 const int kBadgeTopMargin = 2; 107 const int kBadgeTopMargin = 2;
107 108
108 // Added padding for search toolbar. 109 // Added padding for search toolbar.
109 const int kSearchTopButtonSpacing = 3; 110 const int kSearchTopButtonSpacing = 3;
110 const int kSearchTopLocationBarSpacing = 2; 111 const int kSearchTopLocationBarSpacing = 2;
111 const int kSearchToolbarSpacing = 5; 112 const int kSearchToolbarSpacing = 5;
112 113
114 // How often to show the disabled extension (sideload wipeout) bubble.
115 const int kShowSideloadWipeoutBubbleMax = 3;
116
113 gfx::ImageSkia* kPopupBackgroundEdge = NULL; 117 gfx::ImageSkia* kPopupBackgroundEdge = NULL;
114 118
115 // The omnibox border has some additional shadow, so we use less vertical 119 // The omnibox border has some additional shadow, so we use less vertical
116 // spacing than ToolbarView::kVertSpacing. 120 // spacing than ToolbarView::kVertSpacing.
117 int location_bar_vert_spacing() { 121 int location_bar_vert_spacing() {
118 static int value = -1; 122 static int value = -1;
119 if (value == -1) { 123 if (value == -1) {
120 switch (ui::GetDisplayLayout()) { 124 switch (ui::GetDisplayLayout()) {
121 case ui::LAYOUT_ASH: 125 case ui::LAYOUT_ASH:
122 case ui::LAYOUT_DESKTOP: 126 case ui::LAYOUT_DESKTOP:
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 #endif 291 #endif
288 app_menu_->set_border(NULL); 292 app_menu_->set_border(NULL);
289 app_menu_->EnableCanvasFlippingForRTLUI(true); 293 app_menu_->EnableCanvasFlippingForRTLUI(true);
290 app_menu_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_APP)); 294 app_menu_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_APP));
291 app_menu_->SetTooltipText(l10n_util::GetStringFUTF16( 295 app_menu_->SetTooltipText(l10n_util::GetStringFUTF16(
292 IDS_APPMENU_TOOLTIP, 296 IDS_APPMENU_TOOLTIP,
293 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 297 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
294 app_menu_->set_id(VIEW_ID_APP_MENU); 298 app_menu_->set_id(VIEW_ID_APP_MENU);
295 299
296 // Add any necessary badges to the menu item based on the system state. 300 // Add any necessary badges to the menu item based on the system state.
297 if (ShouldShowUpgradeRecommended() || ShouldShowIncompatibilityWarning()) { 301 if (ShouldShowUpgradeRecommended() || ShouldShowIncompatibilityWarning())
298 UpdateAppMenuState(); 302 UpdateAppMenuState();
299 }
300 LoadImages(); 303 LoadImages();
301 304
302 // Always add children in order from left to right, for accessibility. 305 // Always add children in order from left to right, for accessibility.
303 AddChildView(back_); 306 AddChildView(back_);
304 AddChildView(forward_); 307 AddChildView(forward_);
305 AddChildView(reload_); 308 AddChildView(reload_);
306 AddChildView(home_); 309 AddChildView(home_);
307 AddChildView(browser_actions_); 310 AddChildView(browser_actions_);
308 AddChildView(app_menu_); 311 AddChildView(app_menu_);
309 312
310 location_bar_->Init(popup_parent_view); 313 location_bar_->Init(popup_parent_view);
311 show_home_button_.Init(prefs::kShowHomeButton, 314 show_home_button_.Init(prefs::kShowHomeButton,
312 browser_->profile()->GetPrefs(), this); 315 browser_->profile()->GetPrefs(), this);
316 sideload_wipeout_bubble_shown_.Init(
317 prefs::kExtensionsSideloadWipeoutBubbleShown,
318 browser_->profile()->GetPrefs(), NULL);
319
313 browser_actions_->Init(); 320 browser_actions_->Init();
314 321
315 // Accessibility specific tooltip text. 322 // Accessibility specific tooltip text.
316 if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) { 323 if (BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser()) {
317 back_->SetTooltipText( 324 back_->SetTooltipText(
318 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK)); 325 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_BACK));
319 forward_->SetTooltipText( 326 forward_->SetTooltipText(
320 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD)); 327 l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLTIP_FORWARD));
321 } 328 }
329
330 int bubble_shown_count = sideload_wipeout_bubble_shown_.GetValue();
331 if (bubble_shown_count < kShowSideloadWipeoutBubbleMax &&
332 DisabledExtensionsView::MaybeShow(browser_, app_menu_))
333 sideload_wipeout_bubble_shown_.SetValue(++bubble_shown_count);
322 } 334 }
323 335
324 void ToolbarView::Update(WebContents* tab, bool should_restore_state) { 336 void ToolbarView::Update(WebContents* tab, bool should_restore_state) {
325 if (location_bar_) 337 if (location_bar_)
326 location_bar_->Update(should_restore_state ? tab : NULL); 338 location_bar_->Update(should_restore_state ? tab : NULL);
327 339
328 if (browser_actions_) 340 if (browser_actions_)
329 browser_actions_->RefreshBrowserActionViews(); 341 browser_actions_->RefreshBrowserActionViews();
330 342
331 if (reload_) 343 if (reload_)
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 // LocationBarContainer is not a child of the ToolbarView. 1048 // LocationBarContainer is not a child of the ToolbarView.
1037 gfx::Point origin(bounds.origin()); 1049 gfx::Point origin(bounds.origin());
1038 views::View::ConvertPointToTarget(this, location_bar_container_->parent(), 1050 views::View::ConvertPointToTarget(this, location_bar_container_->parent(),
1039 &origin); 1051 &origin);
1040 gfx::Rect target_bounds(origin, bounds.size()); 1052 gfx::Rect target_bounds(origin, bounds.size());
1041 if (location_bar_container_->GetTargetBounds() != target_bounds) { 1053 if (location_bar_container_->GetTargetBounds() != target_bounds) {
1042 location_bar_container_->SetInToolbar(true); 1054 location_bar_container_->SetInToolbar(true);
1043 location_bar_container_->SetBoundsRect(target_bounds); 1055 location_bar_container_->SetBoundsRect(target_bounds);
1044 } 1056 }
1045 } 1057 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.h ('k') | chrome/browser/ui/webui/extensions/extension_settings_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698