#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/instant_service_factory.h"
#include "chrome/browser/search/search.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/translate/translate_service.h"
#import "chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h"
+#import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h"
#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
-#include "chrome/browser/ui/omnibox/location_bar_util.h"
#import "chrome/browser/ui/omnibox/omnibox_popup_model.h"
+#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/toolbar_model.h"
#include "chrome/browser/ui/zoom/zoom_controller.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "components/search_engines/template_url.h"
+#include "components/search_engines/template_url_service.h"
#include "components/translate/core/browser/language_state.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/permissions/permissions_data.h"
+#include "grit/component_scaled_resources.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "net/base/net_util.h"
#include "skia/ext/skia_utils_mac.h"
#import "ui/base/cocoa/cocoa_base_utils.h"
#include "ui/base/l10n/l10n_util_mac.h"
-#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
using content::WebContents;
generated_credit_card_decoration_(
new GeneratedCreditCardDecoration(this)),
search_button_decoration_(new SearchButtonDecoration(this)),
+ manage_passwords_decoration_(
+ new ManagePasswordsDecoration(command_updater)),
browser_(browser),
weak_ptr_factory_(this) {
-
for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
DCHECK_EQ(i, content_setting_decorations_.size());
ContentSettingsType type = static_cast<ContentSettingsType>(i);
}
registrar_.Add(
- this, chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
+ this,
+ extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
content::NotificationService::AllSources());
content::Source<Profile> profile_source = content::Source<Profile>(profile);
- registrar_.Add(
- this, chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, profile_source);
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
+ registrar_.Add(this,
+ extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
+ profile_source);
+ registrar_.Add(this,
+ extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
profile_source);
edit_bookmarks_enabled_.Init(
OnDecorationsChanged();
}
+void LocationBarViewMac::UpdateManagePasswordsIconAndBubble() {
+ WebContents* web_contents = GetWebContents();
+ if (!web_contents)
+ return;
+ ManagePasswordsUIController::FromWebContents(web_contents)
+ ->UpdateIconAndBubbleState(manage_passwords_decoration_->icon());
+}
+
void LocationBarViewMac::UpdatePageActions() {
size_t count_before = page_action_decorations_.size();
RefreshPageActionDecorations();
Layout();
if (page_action_decorations_.size() != count_before) {
content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
+ extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
content::Source<LocationBar>(this),
content::NotificationService::NoDetails());
}
Layout();
if (page_action_decorations_.size() != count_before) {
content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
+ extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
content::Source<LocationBar>(this),
content::NotificationService::NoDetails());
}
}
void LocationBarViewMac::SetStarred(bool starred) {
+ if (star_decoration_->starred() == starred)
+ return;
+
star_decoration_->SetStarred(starred);
UpdateStarDecorationVisibility();
OnDecorationsChanged();
}
void LocationBarViewMac::ZoomChangedForActiveTab(bool can_show_bubble) {
- UpdateZoomDecoration();
- OnDecorationsChanged();
+ bool changed = UpdateZoomDecoration();
+ if (changed)
+ OnDecorationsChanged();
if (can_show_bubble && zoom_decoration_->IsVisible())
zoom_decoration_->ShowBubble(YES);
[cell addRightDecoration:translate_decoration_.get()];
[cell addRightDecoration:zoom_decoration_.get()];
[cell addRightDecoration:generated_credit_card_decoration_.get()];
+ [cell addRightDecoration:manage_passwords_decoration_.get()];
// Note that display order is right to left.
for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
- case chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: {
+ case extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: {
WebContents* contents = GetWebContents();
if (content::Details<WebContents>(contents) != details)
return;
break;
}
- case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED:
- case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED:
+ case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED:
+ case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED:
Update(NULL);
break;
WebContents* web_contents = GetWebContents();
if (!web_contents)
return;
- LanguageState& language_state =
+ translate::LanguageState& language_state =
ChromeTranslateClient::FromWebContents(web_contents)->GetLanguageState();
bool enabled = language_state.translate_enabled();
command_updater()->UpdateCommandEnabled(IDC_TRANSLATE_PAGE, enabled);
translate_decoration_->SetLit(language_state.IsPageTranslated());
}
-void LocationBarViewMac::UpdateZoomDecoration() {
+bool LocationBarViewMac::UpdateZoomDecoration() {
WebContents* web_contents = GetWebContents();
if (!web_contents)
- return;
+ return false;
- zoom_decoration_->Update(ZoomController::FromWebContents(web_contents));
+ return zoom_decoration_->UpdateIfNecessary(
+ ZoomController::FromWebContents(web_contents));
}
void LocationBarViewMac::UpdateStarDecorationVisibility() {