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

Side by Side Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 149046: PageActions can now specify multiple icons and switch between them... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/views/location_bar_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/tab_contents/tab_contents.h" 5 #include "chrome/browser/tab_contents/tab_contents.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/file_version_info.h" 9 #include "base/file_version_info.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 562
563 void TabContents::SetIsCrashed(bool state) { 563 void TabContents::SetIsCrashed(bool state) {
564 if (state == is_crashed_) 564 if (state == is_crashed_)
565 return; 565 return;
566 566
567 is_crashed_ = state; 567 is_crashed_ = state;
568 NotifyNavigationStateChanged(INVALIDATE_TAB); 568 NotifyNavigationStateChanged(INVALIDATE_TAB);
569 } 569 }
570 570
571 void TabContents::SetPageActionEnabled(const PageAction* page_action, 571 void TabContents::SetPageActionEnabled(const PageAction* page_action,
572 bool enable) { 572 bool enable,
573 const std::string& title,
574 int icon_id) {
573 DCHECK(page_action); 575 DCHECK(page_action);
574 576
575 if (enable == IsPageActionEnabled(page_action)) 577 if (!enable &&
576 return; // Don't need to do anything more. 578 enabled_page_actions_.end() == enabled_page_actions_.find(page_action)) {
579 return; // Don't need to disable twice.
580 }
577 581
578 if (enable) 582 if (enable) {
579 enabled_page_actions_.insert(page_action); 583 enabled_page_actions_[page_action].reset(
580 else 584 new PageActionState(title, icon_id));
585 } else {
581 enabled_page_actions_.erase(page_action); 586 enabled_page_actions_.erase(page_action);
587 }
582 } 588 }
583 589
584 bool TabContents::IsPageActionEnabled(const PageAction* page_action) { 590 const PageActionState* TabContents::GetPageActionState(
585 DCHECK(page_action); 591 const PageAction* page_action) {
586 return enabled_page_actions_.end() != enabled_page_actions_.find(page_action); 592 if (enabled_page_actions_.end() == enabled_page_actions_.find(page_action))
593 return NULL;
594
595 return enabled_page_actions_[page_action].get();
587 } 596 }
588 597
589
590 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { 598 void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) {
591 if (delegate_) 599 if (delegate_)
592 delegate_->NavigationStateChanged(this, changed_flags); 600 delegate_->NavigationStateChanged(this, changed_flags);
593 } 601 }
594 602
595 void TabContents::DidBecomeSelected() { 603 void TabContents::DidBecomeSelected() {
596 controller_.SetActive(true); 604 controller_.SetActive(true);
597 605
598 if (render_widget_host_view()) 606 if (render_widget_host_view())
599 render_widget_host_view()->DidBecomeSelected(); 607 render_widget_host_view()->DidBecomeSelected();
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 NavigationController::LoadCommittedDetails& committed_details = 2349 NavigationController::LoadCommittedDetails& committed_details =
2342 *(Details<NavigationController::LoadCommittedDetails>(details).ptr()); 2350 *(Details<NavigationController::LoadCommittedDetails>(details).ptr());
2343 ExpireInfoBars(committed_details); 2351 ExpireInfoBars(committed_details);
2344 break; 2352 break;
2345 } 2353 }
2346 2354
2347 default: 2355 default:
2348 NOTREACHED(); 2356 NOTREACHED();
2349 } 2357 }
2350 } 2358 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/views/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698