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

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

Issue 8368016: Rebase BookmarkBubble on the new views bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only SelectAll on the title textfield when the buble is first shown. Created 9 years, 1 month 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) 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 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/bookmarks/recently_used_folders_combo_model.h" 10 #include "chrome/browser/bookmarks/recently_used_folders_combo_model.h"
11 #include "chrome/browser/ui/views/bubble/bubble.h"
12 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
13 #include "ui/gfx/rect.h" 12 #include "views/bubble/bubble_delegate.h"
14 #include "views/controls/button/button.h" 13 #include "views/controls/button/button.h"
15 #include "views/controls/combobox/combobox.h" 14 #include "views/controls/combobox/combobox.h"
16 #include "views/controls/link_listener.h" 15 #include "views/controls/link_listener.h"
17 #include "views/view.h"
18 16
19 class Profile; 17 class Profile;
20 18
21 class BookmarkModel;
22 class BookmarkNode;
23
24 namespace views { 19 namespace views {
25 class TextButton; 20 class TextButton;
26 class Textfield; 21 class Textfield;
27 } 22 }
28 23
29 // BookmarkBubbleView is a view intended to be used as the content of an 24 // BookmarkBubbleView is a view intended to be used as the content of an
30 // Bubble. BookmarkBubbleView provides views for unstarring and editing the 25 // Bubble. BookmarkBubbleView provides views for unstarring and editing the
31 // bookmark it is created with. Don't create a BookmarkBubbleView directly, 26 // bookmark it is created with. Don't create a BookmarkBubbleView directly,
32 // instead use the static Show method. 27 // instead use the static Show method.
33 class BookmarkBubbleView : public views::View, 28 class BookmarkBubbleView : public views::BubbleDelegateView,
34 public views::LinkListener, 29 public views::LinkListener,
35 public views::ButtonListener, 30 public views::ButtonListener,
36 public views::Combobox::Listener, 31 public views::Combobox::Listener {
37 public BubbleDelegate {
38 public: 32 public:
39 static void Show(views::Widget* widget, 33 static void ShowBubble(views::View* anchor_view,
40 const gfx::Rect& bounds, 34 Profile* profile,
41 BubbleDelegate* delegate, 35 const GURL& url,
42 Profile* profile, 36 bool newly_bookmarked);
43 const GURL& url,
44 bool newly_bookmarked);
45 37
46 static bool IsShowing(); 38 static bool IsShowing();
47 39
48 static void Hide(); 40 static void Hide();
49 41
50 virtual ~BookmarkBubbleView(); 42 virtual ~BookmarkBubbleView();
51 43
52 void set_bubble(Bubble* bubble) { bubble_ = bubble; } 44 // views::BubbleDelegateView methods.
45 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
46 virtual gfx::Point GetAnchorPoint() OVERRIDE;
53 47
54 // Override to close on return. 48 // views::WidgetDelegate method.
49 virtual void WindowClosing() OVERRIDE;
50
51 // views::View method.
55 virtual bool AcceleratorPressed( 52 virtual bool AcceleratorPressed(
56 const views::Accelerator& accelerator) OVERRIDE; 53 const views::Accelerator& accelerator) OVERRIDE;
57 54
58 virtual void ViewHierarchyChanged( 55 protected:
59 bool is_add, View* parent, View* child) OVERRIDE; 56 // views::BubbleDelegateView method.
57 virtual void Init() OVERRIDE;
60 58
61 private: 59 private:
62 // Creates a BookmarkBubbleView. 60 // Creates a BookmarkBubbleView.
63 // |title| is the title of the page. If newly_bookmarked is false, title is 61 BookmarkBubbleView(views::View* anchor_view,
64 // ignored and the title of the bookmark is fetched from the database.
65 BookmarkBubbleView(BubbleDelegate* delegate,
66 Profile* profile, 62 Profile* profile,
67 const GURL& url, 63 const GURL& url,
68 bool newly_bookmarked); 64 bool newly_bookmarked);
69 // Creates the child views.
70 void Init();
71 65
72 // Returns the title to display. 66 // Returns the title to display.
73 string16 GetTitle(); 67 string16 GetTitle();
74 68
75 // views::LinkListener method, either unstars the item or shows the bookmark 69 // views::LinkListener method, either unstars the item or shows the bookmark
76 // editor (depending upon which link was clicked). 70 // editor (depending upon which link was clicked).
77 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 71 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
78 72
79 // ButtonListener method, closes the bubble or opens the edit dialog. 73 // ButtonListener method, closes the bubble or opens the edit dialog.
80 virtual void ButtonPressed(views::Button* sender, 74 virtual void ButtonPressed(views::Button* sender,
81 const views::Event& event) OVERRIDE; 75 const views::Event& event) OVERRIDE;
82 76
83 // Combobox::Listener method. Changes the parent of the bookmark. 77 // Combobox::Listener method. Changes the parent of the bookmark.
84 virtual void ItemChanged(views::Combobox* combobox, 78 virtual void ItemChanged(views::Combobox* combobox,
85 int prev_index, 79 int prev_index,
86 int new_index) OVERRIDE; 80 int new_index) OVERRIDE;
87 81
88 // BubbleDelegate methods. These forward to the BubbleDelegate supplied in the
89 // constructor as well as sending out the necessary notification.
90 virtual void BubbleShown() OVERRIDE;
91 virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE;
92 virtual bool CloseOnEscape() OVERRIDE;
93 virtual bool FadeInOnShow() OVERRIDE;
94 virtual string16 GetAccessibleName() OVERRIDE;
95
96 // Closes the bubble.
97 void Close();
98
99 // Handle the message when the user presses a button. 82 // Handle the message when the user presses a button.
100 void HandleButtonPressed(views::Button* sender); 83 void HandleButtonPressed(views::Button* sender);
101 84
102 // Shows the BookmarkEditor. 85 // Shows the BookmarkEditor.
103 void ShowEditor(); 86 void ShowEditor();
104 87
105 // Sets the title and parent of the node. 88 // Sets the title and parent of the node.
106 void ApplyEdits(); 89 void ApplyEdits();
107 90
108 // The bookmark bubble, if we're showing one. 91 // The bookmark bubble, if we're showing one.
109 static BookmarkBubbleView* bookmark_bubble_; 92 static BookmarkBubbleView* bookmark_bubble_;
110 93
111 // The Bubble showing us.
112 Bubble* bubble_;
113
114 // Delegate for the bubble, may be null.
115 BubbleDelegate* delegate_;
116
117 // The profile. 94 // The profile.
118 Profile* profile_; 95 Profile* profile_;
119 96
120 // The bookmark URL. 97 // The bookmark URL.
121 const GURL url_; 98 const GURL url_;
122 99
123 // Title of the bookmark. This is initially the title supplied to the 100 // Title of the bookmark. This is initially the title supplied to the
124 // constructor, which is typically the title of the page. 101 // constructor, which is typically the title of the page.
125 std::wstring title_; 102 std::wstring title_;
126 103
(...skipping 21 matching lines...) Expand all
148 // When the destructor is invoked should the bookmark be removed? 125 // When the destructor is invoked should the bookmark be removed?
149 bool remove_bookmark_; 126 bool remove_bookmark_;
150 127
151 // When the destructor is invoked should edits be applied? 128 // When the destructor is invoked should edits be applied?
152 bool apply_edits_; 129 bool apply_edits_;
153 130
154 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView); 131 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView);
155 }; 132 };
156 133
157 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ 134 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/setting_level_bubble.cc ('k') | chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698