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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.h

Issue 9479008: Re-factor location bar/toolbar code to get rid of the browser dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix Created 8 years, 9 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_LOCATION_BAR_LOCATION_BAR_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 15 matching lines...) Expand all
26 26
27 #if defined(USE_AURA) 27 #if defined(USE_AURA)
28 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" 28 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
29 #elif defined(OS_WIN) 29 #elif defined(OS_WIN)
30 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" 30 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
31 #elif defined(TOOLKIT_USES_GTK) 31 #elif defined(TOOLKIT_USES_GTK)
32 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" 32 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h"
33 #endif 33 #endif
34 34
35 class Browser; 35 class Browser;
36 class BrowserShowContentRelated;
37 class BrowserShowPageInfo;
36 class ContentSettingImageView; 38 class ContentSettingImageView;
39 class CommandUpdater;
37 class EVBubbleView; 40 class EVBubbleView;
38 class ExtensionAction; 41 class ExtensionAction;
39 class GURL; 42 class GURL;
40 class InstantController; 43 class InstantController;
41 class KeywordHintView; 44 class KeywordHintView;
42 class LocationIconView; 45 class LocationIconView;
43 class PageActionWithBadgeView; 46 class PageActionWithBadgeView;
47 class PageActionImageView;
48 class Profile;
44 class SelectedKeywordView; 49 class SelectedKeywordView;
45 class StarView; 50 class StarView;
46 class TabContentsWrapper; 51 class TabContentsWrapper;
47 class TemplateURLService; 52 class TemplateURLService;
48 53
54 namespace views {
55 class BubbleDelegateView;
56 class Widget;
57 }
58
49 #if defined(OS_WIN) || defined(USE_AURA) 59 #if defined(OS_WIN) || defined(USE_AURA)
50 class SuggestedTextView; 60 class SuggestedTextView;
51 #endif 61 #endif
52 62
53 ///////////////////////////////////////////////////////////////////////////// 63 /////////////////////////////////////////////////////////////////////////////
54 // 64 //
55 // LocationBarView class 65 // LocationBarView class
56 // 66 //
57 // The LocationBarView class is a View subclass that paints the background 67 // The LocationBarView class is a View subclass that paints the background
58 // of the URL bar strip and contains its content. 68 // of the URL bar strip and contains its content.
(...skipping 19 matching lines...) Expand all
78 int animation_offset() const { return animation_offset_; } 88 int animation_offset() const { return animation_offset_; }
79 89
80 class Delegate { 90 class Delegate {
81 public: 91 public:
82 // Should return the current tab contents. 92 // Should return the current tab contents.
83 virtual TabContentsWrapper* GetTabContentsWrapper() const = 0; 93 virtual TabContentsWrapper* GetTabContentsWrapper() const = 0;
84 94
85 // Returns the InstantController, or NULL if there isn't one. 95 // Returns the InstantController, or NULL if there isn't one.
86 virtual InstantController* GetInstant() = 0; 96 virtual InstantController* GetInstant() = 0;
87 97
98 // Returns BrowserShowContentRelated to be used.
99 virtual BrowserShowContentRelated* GetBrowserShowContentRelated() = 0;
sky 2012/02/29 22:41:10 Do we really need to expose objects for the method
altimofeev 2012/03/01 10:05:39 They could. But why is it better? BrowserShowActio
sky 2012/03/01 16:34:47 I believe you are arguing for a class per method a
altimofeev 2012/03/01 18:01:07 I've gotten rid of "BrowserShow..." classes (one d
100
101 // Returns BrowserShowPageInfo to be used.
102 virtual BrowserShowPageInfo* GetBrowserShowPageInfo() = 0;
103
104 // Creates Widget for the given delegate.
105 virtual views::Widget* CreateViewsBubble(
106 views::BubbleDelegateView* bubble_delegate) = 0;
107
108 // Creates PageActionImageView. Caller gets an ownership.
109 virtual PageActionImageView* CreatePageActionImageView(
110 LocationBarView* owner, ExtensionAction* action) = 0;
sky 2012/02/29 22:41:10 nit: when you wrap, each param on its own line.
altimofeev 2012/03/01 10:05:39 Done.
111
88 // Called by the location bar view when the user starts typing in the edit. 112 // Called by the location bar view when the user starts typing in the edit.
89 // This forces our security style to be UNKNOWN for the duration of the 113 // This forces our security style to be UNKNOWN for the duration of the
90 // editing. 114 // editing.
91 virtual void OnInputInProgress(bool in_progress) = 0; 115 virtual void OnInputInProgress(bool in_progress) = 0;
92 }; 116 };
93 117
94 enum ColorKind { 118 enum ColorKind {
95 BACKGROUND = 0, 119 BACKGROUND = 0,
96 TEXT, 120 TEXT,
97 SELECTED_TEXT, 121 SELECTED_TEXT,
98 DEEMPHASIZED_TEXT, 122 DEEMPHASIZED_TEXT,
99 SECURITY_TEXT, 123 SECURITY_TEXT,
100 }; 124 };
101 125
102 // The modes reflect the different scenarios where a location bar can be used. 126 // The modes reflect the different scenarios where a location bar can be used.
103 // The normal mode is the mode used in a regular browser window. 127 // The normal mode is the mode used in a regular browser window.
104 // In popup mode, the location bar view is read only and has a slightly 128 // In popup mode, the location bar view is read only and has a slightly
105 // different presentation (font size / color). 129 // different presentation (font size / color).
106 // In app launcher mode, the location bar is empty and no security states or 130 // In app launcher mode, the location bar is empty and no security states or
107 // page/browser actions are displayed. 131 // page/browser actions are displayed.
108 enum Mode { 132 enum Mode {
109 NORMAL = 0, 133 NORMAL = 0,
110 POPUP, 134 POPUP,
111 APP_LAUNCHER 135 APP_LAUNCHER
112 }; 136 };
113 137
114 LocationBarView(Browser* browser, 138 LocationBarView(Profile* profile,
139 CommandUpdater* command_updater,
115 ToolbarModel* model, 140 ToolbarModel* model,
116 Delegate* delegate, 141 Delegate* delegate,
117 Mode mode); 142 Mode mode);
143
118 virtual ~LocationBarView(); 144 virtual ~LocationBarView();
119 145
120 void Init(); 146 void Init();
121 147
122 // True if this instance has been initialized by calling Init, which can only 148 // True if this instance has been initialized by calling Init, which can only
123 // be called when the receiving instance is attached to a view container. 149 // be called when the receiving instance is attached to a view container.
124 bool IsInitialized() const; 150 bool IsInitialized() const;
125 151
126 // Returns the appropriate color for the desired kind, based on the user's 152 // Returns the appropriate color for the desired kind, based on the user's
127 // system theme. 153 // system theme.
128 static SkColor GetColor(ToolbarModel::SecurityLevel security_level, 154 static SkColor GetColor(ToolbarModel::SecurityLevel security_level,
129 ColorKind kind); 155 ColorKind kind);
130 156
131 // Updates the location bar. We also reset the bar's permanent text and 157 // Updates the location bar. We also reset the bar's permanent text and
132 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore 158 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore
133 // saved state that the tab holds. 159 // saved state that the tab holds.
134 void Update(const content::WebContents* tab_for_state_restoring); 160 void Update(const content::WebContents* tab_for_state_restoring);
135 161
136 Browser* browser() const { return browser_; } 162 // Returns corresponding profile.
163 Profile* profile() const { return profile_; }
164
165 // Creates Widget for the given delegate.
166 views::Widget* CreateViewsBubble(views::BubbleDelegateView* bubble_delegate);
137 167
138 // Sets |preview_enabled| for the PageAction View associated with this 168 // Sets |preview_enabled| for the PageAction View associated with this
139 // |page_action|. If |preview_enabled| is true, the view will display the 169 // |page_action|. If |preview_enabled| is true, the view will display the
140 // PageActions icon even though it has not been activated by the extension. 170 // PageActions icon even though it has not been activated by the extension.
141 // This is used by the ExtensionInstalledBubble to preview what the icon 171 // This is used by the ExtensionInstalledBubble to preview what the icon
142 // will look like for the user upon installation of the extension. 172 // will look like for the user upon installation of the extension.
143 void SetPreviewEnabledPageAction(ExtensionAction *page_action, 173 void SetPreviewEnabledPageAction(ExtensionAction *page_action,
144 bool preview_enabled); 174 bool preview_enabled);
145 175
146 // Retrieves the PageAction View which is associated with |page_action|. 176 // Retrieves the PageAction View which is associated with |page_action|.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 OmniboxViewWin* GetOmniboxViewWin(); 371 OmniboxViewWin* GetOmniboxViewWin();
342 #endif 372 #endif
343 #endif 373 #endif
344 374
345 // Helper to show the first run info bubble. 375 // Helper to show the first run info bubble.
346 void ShowFirstRunBubbleInternal(); 376 void ShowFirstRunBubbleInternal();
347 377
348 // The Autocomplete Edit field. 378 // The Autocomplete Edit field.
349 scoped_ptr<OmniboxView> location_entry_; 379 scoped_ptr<OmniboxView> location_entry_;
350 380
351 // The Browser object that corresponds to this View. 381 Profile* profile_;
352 Browser* browser_; 382 CommandUpdater* command_updater_;
353 383
354 // The model. 384 // The model.
355 ToolbarModel* model_; 385 ToolbarModel* model_;
356 386
357 // Our delegate. 387 // Our delegate.
358 Delegate* delegate_; 388 Delegate* delegate_;
359 389
360 // This is the string of text from the autocompletion session that the user 390 // This is the string of text from the autocompletion session that the user
361 // entered or selected. 391 // entered or selected.
362 string16 location_input_; 392 string16 location_input_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 // While animating, the host clips the widget and draws only the bottom 456 // While animating, the host clips the widget and draws only the bottom
427 // part of it. The view needs to know the pixel offset at which we are drawing 457 // part of it. The view needs to know the pixel offset at which we are drawing
428 // the widget so that we can draw the curved edges that attach to the toolbar 458 // the widget so that we can draw the curved edges that attach to the toolbar
429 // in the right location. 459 // in the right location.
430 int animation_offset_; 460 int animation_offset_;
431 461
432 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView); 462 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView);
433 }; 463 };
434 464
435 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ 465 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698