OLD | NEW |
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 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/translate/translate_service.h" | 32 #include "chrome/browser/translate/translate_service.h" |
33 #include "chrome/browser/translate/translate_tab_helper.h" | 33 #include "chrome/browser/translate/translate_tab_helper.h" |
34 #include "chrome/browser/ui/browser.h" | 34 #include "chrome/browser/ui/browser.h" |
35 #include "chrome/browser/ui/browser_finder.h" | 35 #include "chrome/browser/ui/browser_finder.h" |
36 #include "chrome/browser/ui/browser_instant_controller.h" | 36 #include "chrome/browser/ui/browser_instant_controller.h" |
37 #include "chrome/browser/ui/browser_window.h" | 37 #include "chrome/browser/ui/browser_window.h" |
38 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 38 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
39 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 39 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
40 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 40 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
41 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" | 41 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
| 42 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" |
42 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 43 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
43 #include "chrome/browser/ui/toolbar/origin_chip_info.h" | 44 #include "chrome/browser/ui/toolbar/origin_chip_info.h" |
44 #include "chrome/browser/ui/view_ids.h" | 45 #include "chrome/browser/ui/view_ids.h" |
45 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" | 46 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" |
46 #include "chrome/browser/ui/views/browser_dialogs.h" | 47 #include "chrome/browser/ui/views/browser_dialogs.h" |
47 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 48 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
48 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 49 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
49 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h" | 50 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h" |
50 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 51 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
51 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" | 52 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 AddChildView(generated_credit_card_view_); | 382 AddChildView(generated_credit_card_view_); |
382 | 383 |
383 zoom_view_ = new ZoomView(delegate_); | 384 zoom_view_ = new ZoomView(delegate_); |
384 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); | 385 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); |
385 AddChildView(zoom_view_); | 386 AddChildView(zoom_view_); |
386 | 387 |
387 open_pdf_in_reader_view_ = new OpenPDFInReaderView(); | 388 open_pdf_in_reader_view_ = new OpenPDFInReaderView(); |
388 AddChildView(open_pdf_in_reader_view_); | 389 AddChildView(open_pdf_in_reader_view_); |
389 | 390 |
390 manage_passwords_icon_view_ = new ManagePasswordsIconView(delegate_); | 391 manage_passwords_icon_view_ = new ManagePasswordsIconView(delegate_); |
391 manage_passwords_icon_view_->set_id(VIEW_ID_MANAGE_PASSWORDS_ICON_BUTTON); | 392 manage_passwords_icon_view_->SetState(ManagePasswordsIcon::INACTIVE_STATE); |
392 AddChildView(manage_passwords_icon_view_); | 393 AddChildView(manage_passwords_icon_view_); |
393 | 394 |
394 translate_icon_view_ = new TranslateIconView(command_updater()); | 395 translate_icon_view_ = new TranslateIconView(command_updater()); |
395 translate_icon_view_->SetVisible(false); | 396 translate_icon_view_->SetVisible(false); |
396 AddChildView(translate_icon_view_); | 397 AddChildView(translate_icon_view_); |
397 | 398 |
398 star_view_ = new StarView(command_updater()); | 399 star_view_ = new StarView(command_updater()); |
399 star_view_->SetVisible(false); | 400 star_view_->SetVisible(false); |
400 AddChildView(star_view_); | 401 AddChildView(star_view_); |
401 | 402 |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 translate_icon_view_->SetVisible(enabled); | 1219 translate_icon_view_->SetVisible(enabled); |
1219 translate_icon_view_->SetToggled(language_state.IsPageTranslated()); | 1220 translate_icon_view_->SetToggled(language_state.IsPageTranslated()); |
1220 } | 1221 } |
1221 | 1222 |
1222 bool LocationBarView::RefreshManagePasswordsIconView() { | 1223 bool LocationBarView::RefreshManagePasswordsIconView() { |
1223 DCHECK(manage_passwords_icon_view_); | 1224 DCHECK(manage_passwords_icon_view_); |
1224 WebContents* web_contents = GetWebContents(); | 1225 WebContents* web_contents = GetWebContents(); |
1225 if (!web_contents) | 1226 if (!web_contents) |
1226 return false; | 1227 return false; |
1227 const bool was_visible = manage_passwords_icon_view_->visible(); | 1228 const bool was_visible = manage_passwords_icon_view_->visible(); |
1228 manage_passwords_icon_view_->Update( | 1229 ManagePasswordsBubbleUIController::FromWebContents( |
1229 ManagePasswordsBubbleUIController::FromWebContents(web_contents)); | 1230 web_contents)->UpdateIconAndBubbleState(manage_passwords_icon_view_); |
1230 return was_visible != manage_passwords_icon_view_->visible(); | 1231 return was_visible != manage_passwords_icon_view_->visible(); |
1231 } | 1232 } |
1232 | 1233 |
1233 void LocationBarView::ShowManagePasswordsBubbleIfNeeded() { | |
1234 DCHECK(manage_passwords_icon_view_); | |
1235 WebContents* web_contents = GetWebContents(); | |
1236 if (!web_contents) | |
1237 return; | |
1238 manage_passwords_icon_view_->ShowBubbleIfNeeded( | |
1239 ManagePasswordsBubbleUIController::FromWebContents(web_contents)); | |
1240 } | |
1241 | |
1242 void LocationBarView::ShowFirstRunBubbleInternal() { | 1234 void LocationBarView::ShowFirstRunBubbleInternal() { |
1243 #if !defined(OS_CHROMEOS) | 1235 #if !defined(OS_CHROMEOS) |
1244 // First run bubble doesn't make sense for Chrome OS. | 1236 // First run bubble doesn't make sense for Chrome OS. |
1245 Browser* browser = GetBrowserFromDelegate(delegate_); | 1237 Browser* browser = GetBrowserFromDelegate(delegate_); |
1246 if (!browser) | 1238 if (!browser) |
1247 return; // Possible when browser is shutting down. | 1239 return; // Possible when browser is shutting down. |
1248 | 1240 |
1249 FirstRunBubble::ShowBubble(browser, GetLocationBarAnchor()); | 1241 FirstRunBubble::ShowBubble(browser, GetLocationBarAnchor()); |
1250 #endif | 1242 #endif |
1251 } | 1243 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 Layout(); | 1313 Layout(); |
1322 SchedulePaint(); | 1314 SchedulePaint(); |
1323 } | 1315 } |
1324 } | 1316 } |
1325 | 1317 |
1326 void LocationBarView::UpdateManagePasswordsIconAndBubble() { | 1318 void LocationBarView::UpdateManagePasswordsIconAndBubble() { |
1327 if (RefreshManagePasswordsIconView()) { | 1319 if (RefreshManagePasswordsIconView()) { |
1328 Layout(); | 1320 Layout(); |
1329 SchedulePaint(); | 1321 SchedulePaint(); |
1330 } | 1322 } |
1331 ShowManagePasswordsBubbleIfNeeded(); | |
1332 } | 1323 } |
1333 | 1324 |
1334 void LocationBarView::UpdatePageActions() { | 1325 void LocationBarView::UpdatePageActions() { |
1335 size_t count_before = page_action_views_.size(); | 1326 size_t count_before = page_action_views_.size(); |
1336 bool changed = RefreshPageActionViews(); | 1327 bool changed = RefreshPageActionViews(); |
1337 if (page_action_views_.size() != count_before) { | 1328 if (page_action_views_.size() != count_before) { |
1338 content::NotificationService::current()->Notify( | 1329 content::NotificationService::current()->Notify( |
1339 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 1330 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
1340 content::Source<LocationBar>(this), | 1331 content::Source<LocationBar>(this), |
1341 content::NotificationService::NoDetails()); | 1332 content::NotificationService::NoDetails()); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1702 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1693 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
1703 const SearchModel::State& new_state) { | 1694 const SearchModel::State& new_state) { |
1704 const bool visible = !GetToolbarModel()->input_in_progress() && | 1695 const bool visible = !GetToolbarModel()->input_in_progress() && |
1705 new_state.voice_search_supported; | 1696 new_state.voice_search_supported; |
1706 if (mic_search_view_->visible() != visible) { | 1697 if (mic_search_view_->visible() != visible) { |
1707 mic_search_view_->SetVisible(visible); | 1698 mic_search_view_->SetVisible(visible); |
1708 Layout(); | 1699 Layout(); |
1709 } | 1700 } |
1710 } | 1701 } |
1711 | 1702 |
OLD | NEW |