| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_VIEWS_LOCATION_BAR_VIEW_H__ | 5 #ifndef CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H__ |
| 6 #define CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H__ | 6 #define CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 virtual bool OverrideAccelerator(const views::Accelerator& accelerator); | 113 virtual bool OverrideAccelerator(const views::Accelerator& accelerator); |
| 114 | 114 |
| 115 // Overridden from LocationBar: | 115 // Overridden from LocationBar: |
| 116 virtual void ShowFirstRunBubble(); | 116 virtual void ShowFirstRunBubble(); |
| 117 virtual std::wstring GetInputString() const; | 117 virtual std::wstring GetInputString() const; |
| 118 virtual WindowOpenDisposition GetWindowOpenDisposition() const; | 118 virtual WindowOpenDisposition GetWindowOpenDisposition() const; |
| 119 virtual PageTransition::Type GetPageTransition() const; | 119 virtual PageTransition::Type GetPageTransition() const; |
| 120 virtual void AcceptInput(); | 120 virtual void AcceptInput(); |
| 121 virtual void FocusLocation(); | 121 virtual void FocusLocation(); |
| 122 virtual void FocusSearch(); | 122 virtual void FocusSearch(); |
| 123 virtual void UpdateFeedIcon(); |
| 123 virtual void SaveStateToContents(TabContents* contents); | 124 virtual void SaveStateToContents(TabContents* contents); |
| 124 | 125 |
| 125 static const int kVertMargin; | 126 static const int kVertMargin; |
| 126 static const COLORREF kBackgroundColorByLevel[]; | 127 static const COLORREF kBackgroundColorByLevel[]; |
| 127 | 128 |
| 128 protected: | 129 protected: |
| 129 void Focus(); | 130 void Focus(); |
| 130 | 131 |
| 131 // Overridden from Chrome::View. | 132 // Overridden from Chrome::View. |
| 132 virtual bool ShouldLookupAccelerators(const views::KeyEvent& e); | 133 virtual bool ShouldLookupAccelerators(const views::KeyEvent& e); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 218 |
| 218 Profile* profile_; | 219 Profile* profile_; |
| 219 | 220 |
| 220 DISALLOW_EVIL_CONSTRUCTORS(KeywordHintView); | 221 DISALLOW_EVIL_CONSTRUCTORS(KeywordHintView); |
| 221 }; | 222 }; |
| 222 | 223 |
| 223 | 224 |
| 224 class ShowInfoBubbleTask; | 225 class ShowInfoBubbleTask; |
| 225 class ShowFirstRunBubbleTask; | 226 class ShowFirstRunBubbleTask; |
| 226 | 227 |
| 228 class LocationBarImageView : public views::ImageView, |
| 229 public InfoBubbleDelegate { |
| 230 public: |
| 231 LocationBarImageView(); |
| 232 virtual ~LocationBarImageView(); |
| 233 |
| 234 // Overridden from view for the mouse hovering. |
| 235 virtual void OnMouseMoved(const views::MouseEvent& event); |
| 236 virtual void OnMouseExited(const views::MouseEvent& event); |
| 237 virtual bool OnMousePressed(const views::MouseEvent& event) = 0; |
| 238 |
| 239 // InfoBubbleDelegate |
| 240 void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape); |
| 241 bool CloseOnEscape() { return true; } |
| 242 |
| 243 virtual void ShowInfoBubble() = 0; |
| 244 |
| 245 protected: |
| 246 void ShowInfoBubbleImpl(const std::wstring& text, SkColor text_color); |
| 247 |
| 248 private: |
| 249 friend class ShowInfoBubbleTask; |
| 250 |
| 251 // The currently shown info bubble if any. |
| 252 InfoBubble* info_bubble_; |
| 253 |
| 254 // A task used to display the info bubble when the mouse hovers on the |
| 255 // image. |
| 256 ShowInfoBubbleTask* show_info_bubble_task_; |
| 257 |
| 258 DISALLOW_COPY_AND_ASSIGN(LocationBarImageView); |
| 259 }; |
| 260 |
| 227 // SecurityImageView is used to display the lock or warning icon when the | 261 // SecurityImageView is used to display the lock or warning icon when the |
| 228 // current URL's scheme is https. | 262 // current URL's scheme is https. |
| 229 // | 263 // |
| 230 // If a message has been set with SetInfoBubbleText, it displays an info | 264 // If a message has been set with SetInfoBubbleText, it displays an info |
| 231 // bubble when the mouse hovers on the image. | 265 // bubble when the mouse hovers on the image. |
| 232 class SecurityImageView : public views::ImageView, | 266 class SecurityImageView : public LocationBarImageView { |
| 233 public InfoBubbleDelegate { | |
| 234 public: | 267 public: |
| 235 enum Image { | 268 enum Image { |
| 236 LOCK = 0, | 269 LOCK = 0, |
| 237 WARNING | 270 WARNING |
| 238 }; | 271 }; |
| 239 | 272 |
| 240 SecurityImageView(Profile* profile, ToolbarModel* model_); | 273 SecurityImageView(Profile* profile, ToolbarModel* model_); |
| 241 virtual ~SecurityImageView(); | 274 virtual ~SecurityImageView(); |
| 242 | 275 |
| 243 // Sets the image that should be displayed. | 276 // Sets the image that should be displayed. |
| 244 void SetImageShown(Image image); | 277 void SetImageShown(Image image); |
| 245 | 278 |
| 246 // Overridden from view for the mouse hovering. | 279 // Overridden from view for the mouse hovering. |
| 247 virtual void OnMouseMoved(const views::MouseEvent& event); | |
| 248 virtual void OnMouseExited(const views::MouseEvent& event); | |
| 249 virtual bool OnMousePressed(const views::MouseEvent& event); | 280 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 250 | 281 |
| 251 // InfoBubbleDelegate | |
| 252 void InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape); | |
| 253 bool CloseOnEscape() { return true; } | |
| 254 | |
| 255 void set_profile(Profile* profile) { profile_ = profile; } | 282 void set_profile(Profile* profile) { profile_ = profile; } |
| 256 | 283 |
| 284 virtual void ShowInfoBubble(); |
| 285 |
| 257 private: | 286 private: |
| 258 friend class ShowInfoBubbleTask; | |
| 259 | |
| 260 void ShowInfoBubble(); | |
| 261 | |
| 262 // The lock icon shown when using HTTPS. | 287 // The lock icon shown when using HTTPS. |
| 263 static SkBitmap* lock_icon_; | 288 static SkBitmap* lock_icon_; |
| 264 | 289 |
| 265 // The warning icon shown when HTTPS is broken. | 290 // The warning icon shown when HTTPS is broken. |
| 266 static SkBitmap* warning_icon_; | 291 static SkBitmap* warning_icon_; |
| 267 | 292 |
| 268 // The currently shown info bubble if any. | 293 // The currently shown info bubble if any. |
| 269 InfoBubble* info_bubble_; | 294 InfoBubble* info_bubble_; |
| 270 | 295 |
| 271 // A task used to display the info bubble when the mouse hovers on the | 296 // A task used to display the info bubble when the mouse hovers on the |
| 272 // image. | 297 // image. |
| 273 ShowInfoBubbleTask* show_info_bubble_task_; | 298 ShowInfoBubbleTask* show_info_bubble_task_; |
| 274 | 299 |
| 275 Profile* profile_; | 300 Profile* profile_; |
| 276 | 301 |
| 277 ToolbarModel* model_; | 302 ToolbarModel* model_; |
| 278 | 303 |
| 279 DISALLOW_EVIL_CONSTRUCTORS(SecurityImageView); | 304 DISALLOW_EVIL_CONSTRUCTORS(SecurityImageView); |
| 280 }; | 305 }; |
| 281 | 306 |
| 307 // RssImageView is used to display the RSS icon when the page has a feed that |
| 308 // you can subscribe to. |
| 309 // |
| 310 // If a message has been set with SetInfoBubbleText, it displays an info |
| 311 // bubble when the mouse hovers on the image. |
| 312 class RssImageView : public LocationBarImageView { |
| 313 public: |
| 314 explicit RssImageView(ToolbarModel* model); |
| 315 virtual ~RssImageView(); |
| 316 |
| 317 // Overridden from view for the mouse hovering. |
| 318 virtual bool OnMousePressed(const views::MouseEvent& event); |
| 319 |
| 320 virtual void ShowInfoBubble(); |
| 321 |
| 322 private: |
| 323 // The RSS icon shown when page has a feed. |
| 324 static SkBitmap* rss_icon_; |
| 325 |
| 326 ToolbarModel* model_; |
| 327 |
| 328 DISALLOW_COPY_AND_ASSIGN(RssImageView); |
| 329 }; |
| 330 |
| 282 // Both Layout and OnChanged call into this. This updates the contents | 331 // Both Layout and OnChanged call into this. This updates the contents |
| 283 // of the 3 views: selected_keyword, keyword_hint and type_search_view. If | 332 // of the 3 views: selected_keyword, keyword_hint and type_search_view. If |
| 284 // force_layout is true, or one of these views has changed in such a way as | 333 // force_layout is true, or one of these views has changed in such a way as |
| 285 // to necessitate a layout, layout occurs as well. | 334 // to necessitate a layout, layout occurs as well. |
| 286 void DoLayout(bool force_layout); | 335 void DoLayout(bool force_layout); |
| 287 | 336 |
| 288 // Returns the height in pixels of the margin at the top of the bar. | 337 // Returns the height in pixels of the margin at the top of the bar. |
| 289 int TopMargin() const; | 338 int TopMargin() const; |
| 290 | 339 |
| 291 // Returns the width in pixels of the contents of the edit. | 340 // Returns the width in pixels of the contents of the edit. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 309 | 358 |
| 310 // If View fits in the specified region, it is made visible and the | 359 // If View fits in the specified region, it is made visible and the |
| 311 // bounds are adjusted appropriately. If the View does not fit, it is | 360 // bounds are adjusted appropriately. If the View does not fit, it is |
| 312 // made invisible. | 361 // made invisible. |
| 313 void LayoutView(bool leading, views::View* view, int text_width, | 362 void LayoutView(bool leading, views::View* view, int text_width, |
| 314 int max_width, gfx::Rect* bounds); | 363 int max_width, gfx::Rect* bounds); |
| 315 | 364 |
| 316 // Sets the security icon to display. Note that no repaint is done. | 365 // Sets the security icon to display. Note that no repaint is done. |
| 317 void SetSecurityIcon(ToolbarModel::Icon icon); | 366 void SetSecurityIcon(ToolbarModel::Icon icon); |
| 318 | 367 |
| 368 // Sets the RSS icon visibility. |
| 369 void SetRssIconVisibility(FeedList* feeds); |
| 370 |
| 319 // Sets the text that should be displayed in the info label and its associated | 371 // Sets the text that should be displayed in the info label and its associated |
| 320 // tooltip text. Call with an empty string if the info label should be | 372 // tooltip text. Call with an empty string if the info label should be |
| 321 // hidden. | 373 // hidden. |
| 322 void SetInfoText(const std::wstring& text, | 374 void SetInfoText(const std::wstring& text, |
| 323 SkColor text_color, | 375 SkColor text_color, |
| 324 const std::wstring& tooltip_text); | 376 const std::wstring& tooltip_text); |
| 325 | 377 |
| 326 // Sets the visibility of view to new_vis. Returns whether the visibility | 378 // Sets the visibility of view to new_vis. Returns whether the visibility |
| 327 // changed. | 379 // changed. |
| 328 bool ToggleVisibility(bool new_vis, views::View* view); | 380 bool ToggleVisibility(bool new_vis, views::View* view); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 426 |
| 375 // Shown if the selected url has a corresponding keyword. | 427 // Shown if the selected url has a corresponding keyword. |
| 376 KeywordHintView keyword_hint_view_; | 428 KeywordHintView keyword_hint_view_; |
| 377 | 429 |
| 378 // Shown if the text is not a keyword or url. | 430 // Shown if the text is not a keyword or url. |
| 379 views::Label type_to_search_view_; | 431 views::Label type_to_search_view_; |
| 380 | 432 |
| 381 // The view that shows the lock/warning when in HTTPS mode. | 433 // The view that shows the lock/warning when in HTTPS mode. |
| 382 SecurityImageView security_image_view_; | 434 SecurityImageView security_image_view_; |
| 383 | 435 |
| 436 // The view that shows the RSS icon when the page has an RSS feed. |
| 437 RssImageView rss_image_view_; |
| 438 |
| 384 // A label displayed after the lock icon to show some extra information. | 439 // A label displayed after the lock icon to show some extra information. |
| 385 views::Label info_label_; | 440 views::Label info_label_; |
| 386 | 441 |
| 387 // When true, the location bar view is read only and also is has a slightly | 442 // When true, the location bar view is read only and also is has a slightly |
| 388 // different presentation (font size / color). This is used for popups. | 443 // different presentation (font size / color). This is used for popups. |
| 389 bool popup_window_mode_; | 444 bool popup_window_mode_; |
| 390 | 445 |
| 391 // Used schedule a task for the first run info bubble. | 446 // Used schedule a task for the first run info bubble. |
| 392 ScopedRunnableMethodFactory<LocationBarView> first_run_bubble_; | 447 ScopedRunnableMethodFactory<LocationBarView> first_run_bubble_; |
| 393 }; | 448 }; |
| 394 | 449 |
| 395 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H__ | 450 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H__ |
| OLD | NEW |