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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.h

Issue 12310109: Add a shortcut to open the Apps page from the bookmark bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding the missing test file... Created 7 years, 10 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 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/prefs/public/pref_change_registrar.h"
15 #include "chrome/browser/bookmarks/bookmark_model_observer.h" 16 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
16 #include "chrome/browser/bookmarks/bookmark_node_data.h" 17 #include "chrome/browser/bookmarks/bookmark_node_data.h"
17 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" 18 #include "chrome/browser/ui/bookmarks/bookmark_bar.h"
18 #include "chrome/browser/ui/bookmarks/bookmark_bar_instructions_delegate.h" 19 #include "chrome/browser/ui/bookmarks/bookmark_bar_instructions_delegate.h"
19 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view_observer.h" 20 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view_observer.h"
20 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h" 21 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h"
21 #include "chrome/browser/ui/views/detachable_toolbar_view.h" 22 #include "chrome/browser/ui/views/detachable_toolbar_view.h"
22 #include "ui/base/animation/animation_delegate.h" 23 #include "ui/base/animation/animation_delegate.h"
23 #include "ui/views/context_menu_controller.h" 24 #include "ui/views/context_menu_controller.h"
24 #include "ui/views/controls/button/button.h" 25 #include "ui/views/controls/button/button.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 virtual void ShowContextMenuForView(views::View* source, 243 virtual void ShowContextMenuForView(views::View* source,
243 const gfx::Point& point) OVERRIDE; 244 const gfx::Point& point) OVERRIDE;
244 245
245 private: 246 private:
246 class ButtonSeparatorView; 247 class ButtonSeparatorView;
247 struct DropInfo; 248 struct DropInfo;
248 struct DropLocation; 249 struct DropLocation;
249 250
250 friend class BookmarkBarViewEventTestBase; 251 friend class BookmarkBarViewEventTestBase;
251 FRIEND_TEST_ALL_PREFIXES(BookmarkBarViewTest, SwitchProfile); 252 FRIEND_TEST_ALL_PREFIXES(BookmarkBarViewTest, SwitchProfile);
253 FRIEND_TEST_ALL_PREFIXES(BookmarkBarViewTest,
254 NoAppsShortcutWithoutInstantExtended);
255 FRIEND_TEST_ALL_PREFIXES(BookmarkBarViewInstantExtendedTest,
256 AppsShortcutVisibility);
252 257
253 // Used to identify what the user is dropping onto. 258 // Used to identify what the user is dropping onto.
254 enum DropButtonType { 259 enum DropButtonType {
255 DROP_BOOKMARK, 260 DROP_BOOKMARK,
256 DROP_OTHER_FOLDER, 261 DROP_OTHER_FOLDER,
257 DROP_OVERFLOW 262 DROP_OVERFLOW
258 }; 263 };
259 264
260 // Creates recent bookmark button and when visible button as well as 265 // Creates recent bookmark button and when visible button as well as
261 // calculating the preferred height. 266 // calculating the preferred height.
(...skipping 20 matching lines...) Expand all
282 287
283 // Creates the button showing the other bookmarked items. 288 // Creates the button showing the other bookmarked items.
284 views::MenuButton* CreateOtherBookmarkedButton(); 289 views::MenuButton* CreateOtherBookmarkedButton();
285 290
286 // Creates the button used when not all bookmark buttons fit. 291 // Creates the button used when not all bookmark buttons fit.
287 views::MenuButton* CreateOverflowButton(); 292 views::MenuButton* CreateOverflowButton();
288 293
289 // Creates the button for rendering the specified bookmark node. 294 // Creates the button for rendering the specified bookmark node.
290 views::View* CreateBookmarkButton(const BookmarkNode* node); 295 views::View* CreateBookmarkButton(const BookmarkNode* node);
291 296
297 // Creates the button for rendering the apps page shortcut.
298 views::TextButton* CreateAppsPageShortcutButton();
299
292 // Configures the button from the specified node. This sets the text, 300 // Configures the button from the specified node. This sets the text,
293 // and icon. 301 // and icon.
294 void ConfigureButton(const BookmarkNode* node, views::TextButton* button); 302 void ConfigureButton(const BookmarkNode* node, views::TextButton* button);
295 303
296 // Implementation for BookmarkNodeAddedImpl. 304 // Implementation for BookmarkNodeAddedImpl.
297 void BookmarkNodeAddedImpl(BookmarkModel* model, 305 void BookmarkNodeAddedImpl(BookmarkModel* model,
298 const BookmarkNode* parent, 306 const BookmarkNode* parent,
299 int index); 307 int index);
300 308
301 // Implementation for BookmarkNodeRemoved. 309 // Implementation for BookmarkNodeRemoved.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // Updates the visibility of |other_bookmarked_button_| and 352 // Updates the visibility of |other_bookmarked_button_| and
345 // |bookmarks_separator_view_|. 353 // |bookmarks_separator_view_|.
346 void UpdateOtherBookmarksVisibility(); 354 void UpdateOtherBookmarksVisibility();
347 355
348 // This method computes the bounds for the bookmark bar items. If 356 // This method computes the bounds for the bookmark bar items. If
349 // |compute_bounds_only| = TRUE, the bounds for the items are just computed, 357 // |compute_bounds_only| = TRUE, the bounds for the items are just computed,
350 // but are not set. This mode is used by GetPreferredSize() to obtain the 358 // but are not set. This mode is used by GetPreferredSize() to obtain the
351 // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set. 359 // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set.
352 gfx::Size LayoutItems(bool compute_bounds_only); 360 gfx::Size LayoutItems(bool compute_bounds_only);
353 361
362 // Returns true if we should show the apps shortcut.
363 bool ShouldShowAppsShortcut() const;
364
365 // Updates the visibility of the apps shortcut based on the pref value.
366 void OnAppsPageShortcutVisibilityChanged();
367
368 // Used by tests.
369 bool IsAppsShortcutVisible() const;
Alexei Svitkine (slow) 2013/02/26 19:29:51 Nit: Suffix with "ForTesting".
MAD 2013/02/26 20:55:53 Done.
370
371 // Needed to react to kShowAppsShortcutInBookmarkBar changes.
372 PrefChangeRegistrar profile_pref_registrar_;
373
354 // Used for opening urls. 374 // Used for opening urls.
355 content::PageNavigator* page_navigator_; 375 content::PageNavigator* page_navigator_;
356 376
357 // Model providing details as to the starred entries/folders that should be 377 // Model providing details as to the starred entries/folders that should be
358 // shown. This is owned by the Profile. 378 // shown. This is owned by the Profile.
359 BookmarkModel* model_; 379 BookmarkModel* model_;
360 380
361 // Used to manage showing a Menu, either for the most recently bookmarked 381 // Used to manage showing a Menu, either for the most recently bookmarked
362 // entries, or for the starred folder. 382 // entries, or for the starred folder.
363 BookmarkMenuController* bookmark_menu_; 383 BookmarkMenuController* bookmark_menu_;
364 384
365 // Used when showing a menu for drag and drop. That is, if the user drags 385 // Used when showing a menu for drag and drop. That is, if the user drags
366 // over a folder this becomes non-null and manages the menu showing the 386 // over a folder this becomes non-null and manages the menu showing the
367 // contents of the node. 387 // contents of the node.
368 BookmarkMenuController* bookmark_drop_menu_; 388 BookmarkMenuController* bookmark_drop_menu_;
369 389
370 // If non-NULL we're showing a context menu for one of the items on the 390 // If non-NULL we're showing a context menu for one of the items on the
371 // bookmark bar. 391 // bookmark bar.
372 scoped_ptr<BookmarkContextMenu> context_menu_; 392 scoped_ptr<BookmarkContextMenu> context_menu_;
373 393
374 // Shows the other bookmark entries. 394 // Shows the other bookmark entries.
375 views::MenuButton* other_bookmarked_button_; 395 views::MenuButton* other_bookmarked_button_;
376 396
397 // Shows the Apps page shortcut.
398 views::TextButton* apps_page_shortcut_;
399
377 // Task used to delay showing of the drop menu. 400 // Task used to delay showing of the drop menu.
378 base::WeakPtrFactory<BookmarkBarView> show_folder_method_factory_; 401 base::WeakPtrFactory<BookmarkBarView> show_folder_method_factory_;
379 402
380 // Used to track drops on the bookmark bar view. 403 // Used to track drops on the bookmark bar view.
381 scoped_ptr<DropInfo> drop_info_; 404 scoped_ptr<DropInfo> drop_info_;
382 405
383 // Visible if not all the bookmark buttons fit. 406 // Visible if not all the bookmark buttons fit.
384 views::MenuButton* overflow_button_; 407 views::MenuButton* overflow_button_;
385 408
386 // BookmarkBarInstructionsView that is visible if there are no bookmarks on 409 // BookmarkBarInstructionsView that is visible if there are no bookmarks on
(...skipping 18 matching lines...) Expand all
405 428
406 BookmarkBar::State bookmark_bar_state_; 429 BookmarkBar::State bookmark_bar_state_;
407 430
408 // Are we animating to or from the detached state? 431 // Are we animating to or from the detached state?
409 bool animating_detached_; 432 bool animating_detached_;
410 433
411 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); 434 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView);
412 }; 435 };
413 436
414 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ 437 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698