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

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: comments 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;
92 }; 119 };
93 120
94 enum ColorKind { 121 enum ColorKind {
95 BACKGROUND = 0, 122 BACKGROUND = 0,
96 TEXT, 123 TEXT,
97 SELECTED_TEXT, 124 SELECTED_TEXT,
98 DEEMPHASIZED_TEXT, 125 DEEMPHASIZED_TEXT,
99 SECURITY_TEXT, 126 SECURITY_TEXT,
100 }; 127 };
101 128
102 // The modes reflect the different scenarios where a location bar can be used. 129 // 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. 130 // 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 131 // In popup mode, the location bar view is read only and has a slightly
105 // different presentation (font size / color). 132 // different presentation (font size / color).
106 // In app launcher mode, the location bar is empty and no security states or 133 // In app launcher mode, the location bar is empty and no security states or
107 // page/browser actions are displayed. 134 // page/browser actions are displayed.
108 enum Mode { 135 enum Mode {
109 NORMAL = 0, 136 NORMAL = 0,
110 POPUP, 137 POPUP,
111 APP_LAUNCHER 138 APP_LAUNCHER
112 }; 139 };
113 140
114 LocationBarView(Browser* browser, 141 LocationBarView(Profile* profile,
142 CommandUpdater* command_updater,
115 ToolbarModel* model, 143 ToolbarModel* model,
116 Delegate* delegate, 144 Delegate* delegate,
117 Mode mode); 145 Mode mode);
146
118 virtual ~LocationBarView(); 147 virtual ~LocationBarView();
119 148
120 void Init(); 149 void Init();
121 150
122 // True if this instance has been initialized by calling Init, which can only 151 // 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. 152 // be called when the receiving instance is attached to a view container.
124 bool IsInitialized() const; 153 bool IsInitialized() const;
125 154
126 // Returns the appropriate color for the desired kind, based on the user's 155 // Returns the appropriate color for the desired kind, based on the user's
127 // system theme. 156 // system theme.
128 static SkColor GetColor(ToolbarModel::SecurityLevel security_level, 157 static SkColor GetColor(ToolbarModel::SecurityLevel security_level,
129 ColorKind kind); 158 ColorKind kind);
130 159
131 // Updates the location bar. We also reset the bar's permanent text and 160 // 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 161 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore
133 // saved state that the tab holds. 162 // saved state that the tab holds.
134 void Update(const content::WebContents* tab_for_state_restoring); 163 void Update(const content::WebContents* tab_for_state_restoring);
135 164
136 Browser* browser() const { return browser_; } 165 // Returns corresponding profile.
166 Profile* profile() const { return profile_; }
167
168 // Returns the delegate.
169 Delegate* delegate() const { return delegate_; }
137 170
138 // Sets |preview_enabled| for the PageAction View associated with this 171 // Sets |preview_enabled| for the PageAction View associated with this
139 // |page_action|. If |preview_enabled| is true, the view will display the 172 // |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. 173 // PageActions icon even though it has not been activated by the extension.
141 // This is used by the ExtensionInstalledBubble to preview what the icon 174 // This is used by the ExtensionInstalledBubble to preview what the icon
142 // will look like for the user upon installation of the extension. 175 // will look like for the user upon installation of the extension.
143 void SetPreviewEnabledPageAction(ExtensionAction *page_action, 176 void SetPreviewEnabledPageAction(ExtensionAction *page_action,
144 bool preview_enabled); 177 bool preview_enabled);
145 178
146 // Retrieves the PageAction View which is associated with |page_action|. 179 // 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(); 374 OmniboxViewWin* GetOmniboxViewWin();
342 #endif 375 #endif
343 #endif 376 #endif
344 377
345 // Helper to show the first run info bubble. 378 // Helper to show the first run info bubble.
346 void ShowFirstRunBubbleInternal(); 379 void ShowFirstRunBubbleInternal();
347 380
348 // The Autocomplete Edit field. 381 // The Autocomplete Edit field.
349 scoped_ptr<OmniboxView> location_entry_; 382 scoped_ptr<OmniboxView> location_entry_;
350 383
351 // The Browser object that corresponds to this View. 384 // The profile which corresponds to this View.
352 Browser* browser_; 385 Profile* profile_;
386
387 // Command updater which corresponds to this View.
388 CommandUpdater* command_updater_;
353 389
354 // The model. 390 // The model.
355 ToolbarModel* model_; 391 ToolbarModel* model_;
356 392
357 // Our delegate. 393 // Our delegate.
358 Delegate* delegate_; 394 Delegate* delegate_;
359 395
360 // This is the string of text from the autocompletion session that the user 396 // This is the string of text from the autocompletion session that the user
361 // entered or selected. 397 // entered or selected.
362 string16 location_input_; 398 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 462 // 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 463 // 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 464 // the widget so that we can draw the curved edges that attach to the toolbar
429 // in the right location. 465 // in the right location.
430 int animation_offset_; 466 int animation_offset_;
431 467
432 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView); 468 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView);
433 }; 469 };
434 470
435 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ 471 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698