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

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: ut 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 14 matching lines...) Expand all
25 #include "ui/views/drag_controller.h" 25 #include "ui/views/drag_controller.h"
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 CommandUpdater;
36 class ContentSettingBubbleModelDelegate;
36 class ContentSettingImageView; 37 class ContentSettingImageView;
37 class EVBubbleView; 38 class EVBubbleView;
38 class ExtensionAction; 39 class ExtensionAction;
39 class GURL; 40 class GURL;
40 class InstantController; 41 class InstantController;
41 class KeywordHintView; 42 class KeywordHintView;
42 class LocationIconView; 43 class LocationIconView;
43 class PageActionWithBadgeView; 44 class PageActionWithBadgeView;
45 class PageActionImageView;
46 class Profile;
44 class SelectedKeywordView; 47 class SelectedKeywordView;
45 class StarView; 48 class StarView;
46 class TabContentsWrapper; 49 class TabContentsWrapper;
47 class TemplateURLService; 50 class TemplateURLService;
48 51
52 namespace views {
53 class BubbleDelegateView;
54 class Widget;
55 }
56
49 #if defined(OS_WIN) || defined(USE_AURA) 57 #if defined(OS_WIN) || defined(USE_AURA)
50 class SuggestedTextView; 58 class SuggestedTextView;
51 #endif 59 #endif
52 60
53 ///////////////////////////////////////////////////////////////////////////// 61 /////////////////////////////////////////////////////////////////////////////
54 // 62 //
55 // LocationBarView class 63 // LocationBarView class
56 // 64 //
57 // The LocationBarView class is a View subclass that paints the background 65 // The LocationBarView class is a View subclass that paints the background
58 // of the URL bar strip and contains its content. 66 // of the URL bar strip and contains its content.
(...skipping 19 matching lines...) Expand all
78 int animation_offset() const { return animation_offset_; } 86 int animation_offset() const { return animation_offset_; }
79 87
80 class Delegate { 88 class Delegate {
81 public: 89 public:
82 // Should return the current tab contents. 90 // Should return the current tab contents.
83 virtual TabContentsWrapper* GetTabContentsWrapper() const = 0; 91 virtual TabContentsWrapper* GetTabContentsWrapper() const = 0;
84 92
85 // Returns the InstantController, or NULL if there isn't one. 93 // Returns the InstantController, or NULL if there isn't one.
86 virtual InstantController* GetInstant() = 0; 94 virtual InstantController* GetInstant() = 0;
87 95
96 // Creates Widget for the given delegate.
97 virtual views::Widget* CreateViewsBubble(
98 views::BubbleDelegateView* bubble_delegate) = 0;
99
100 // Creates PageActionImageView. Caller gets an ownership.
101 virtual PageActionImageView* CreatePageActionImageView(
102 LocationBarView* owner,
103 ExtensionAction* action) = 0;
104
105 // Returns ContentSettingBubbleModelDelegate.
106 virtual ContentSettingBubbleModelDelegate*
107 GetContentSettingBubbleModelDelegate() = 0;
108
109 // Shows page information in the given web contents.
110 virtual void ShowPageInfo(content::WebContents* web_contents,
111 const GURL& url,
112 const content::SSLStatus& ssl,
113 bool show_history) = 0;
114
88 // Called by the location bar view when the user starts typing in the edit. 115 // 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 116 // This forces our security style to be UNKNOWN for the duration of the
90 // editing. 117 // editing.
91 virtual void OnInputInProgress(bool in_progress) = 0; 118 virtual void OnInputInProgress(bool in_progress) = 0;
119
120 protected:
121 virtual ~Delegate() {}
92 }; 122 };
93 123
94 enum ColorKind { 124 enum ColorKind {
95 BACKGROUND = 0, 125 BACKGROUND = 0,
96 TEXT, 126 TEXT,
97 SELECTED_TEXT, 127 SELECTED_TEXT,
98 DEEMPHASIZED_TEXT, 128 DEEMPHASIZED_TEXT,
99 SECURITY_TEXT, 129 SECURITY_TEXT,
100 }; 130 };
101 131
102 // The modes reflect the different scenarios where a location bar can be used. 132 // 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. 133 // 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 134 // In popup mode, the location bar view is read only and has a slightly
105 // different presentation (font size / color). 135 // different presentation (font size / color).
106 // In app launcher mode, the location bar is empty and no security states or 136 // In app launcher mode, the location bar is empty and no security states or
107 // page/browser actions are displayed. 137 // page/browser actions are displayed.
108 enum Mode { 138 enum Mode {
109 NORMAL = 0, 139 NORMAL = 0,
110 POPUP, 140 POPUP,
111 APP_LAUNCHER 141 APP_LAUNCHER
112 }; 142 };
113 143
114 LocationBarView(Browser* browser, 144 LocationBarView(Profile* profile,
145 CommandUpdater* command_updater,
115 ToolbarModel* model, 146 ToolbarModel* model,
116 Delegate* delegate, 147 Delegate* delegate,
117 Mode mode); 148 Mode mode);
149
118 virtual ~LocationBarView(); 150 virtual ~LocationBarView();
119 151
120 void Init(); 152 void Init();
121 153
122 // True if this instance has been initialized by calling Init, which can only 154 // 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. 155 // be called when the receiving instance is attached to a view container.
124 bool IsInitialized() const; 156 bool IsInitialized() const;
125 157
126 // Returns the appropriate color for the desired kind, based on the user's 158 // Returns the appropriate color for the desired kind, based on the user's
127 // system theme. 159 // system theme.
128 static SkColor GetColor(ToolbarModel::SecurityLevel security_level, 160 static SkColor GetColor(ToolbarModel::SecurityLevel security_level,
129 ColorKind kind); 161 ColorKind kind);
130 162
131 // Updates the location bar. We also reset the bar's permanent text and 163 // 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 164 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore
133 // saved state that the tab holds. 165 // saved state that the tab holds.
134 void Update(const content::WebContents* tab_for_state_restoring); 166 void Update(const content::WebContents* tab_for_state_restoring);
135 167
136 Browser* browser() const { return browser_; } 168 // Returns corresponding profile.
169 Profile* profile() const { return profile_; }
170
171 // Returns the delegate.
172 Delegate* delegate() const { return delegate_; }
137 173
138 // Sets |preview_enabled| for the PageAction View associated with this 174 // Sets |preview_enabled| for the PageAction View associated with this
139 // |page_action|. If |preview_enabled| is true, the view will display the 175 // |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. 176 // PageActions icon even though it has not been activated by the extension.
141 // This is used by the ExtensionInstalledBubble to preview what the icon 177 // This is used by the ExtensionInstalledBubble to preview what the icon
142 // will look like for the user upon installation of the extension. 178 // will look like for the user upon installation of the extension.
143 void SetPreviewEnabledPageAction(ExtensionAction *page_action, 179 void SetPreviewEnabledPageAction(ExtensionAction *page_action,
144 bool preview_enabled); 180 bool preview_enabled);
145 181
146 // Retrieves the PageAction View which is associated with |page_action|. 182 // 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(); 377 OmniboxViewWin* GetOmniboxViewWin();
342 #endif 378 #endif
343 #endif 379 #endif
344 380
345 // Helper to show the first run info bubble. 381 // Helper to show the first run info bubble.
346 void ShowFirstRunBubbleInternal(); 382 void ShowFirstRunBubbleInternal();
347 383
348 // The Autocomplete Edit field. 384 // The Autocomplete Edit field.
349 scoped_ptr<OmniboxView> location_entry_; 385 scoped_ptr<OmniboxView> location_entry_;
350 386
351 // The Browser object that corresponds to this View. 387 // The profile which corresponds to this View.
352 Browser* browser_; 388 Profile* profile_;
389
390 // Command updater which corresponds to this View.
391 CommandUpdater* command_updater_;
353 392
354 // The model. 393 // The model.
355 ToolbarModel* model_; 394 ToolbarModel* model_;
356 395
357 // Our delegate. 396 // Our delegate.
358 Delegate* delegate_; 397 Delegate* delegate_;
359 398
360 // This is the string of text from the autocompletion session that the user 399 // This is the string of text from the autocompletion session that the user
361 // entered or selected. 400 // entered or selected.
362 string16 location_input_; 401 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 465 // 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 466 // 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 467 // the widget so that we can draw the curved edges that attach to the toolbar
429 // in the right location. 468 // in the right location.
430 int animation_offset_; 469 int animation_offset_;
431 470
432 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView); 471 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView);
433 }; 472 };
434 473
435 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ 474 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698