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

Unified Diff: chrome/browser/ui/tabs/tab_discard_state.cc

Issue 1332003002: Add option to disallow the discarding of a tab that was previously discarded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky@ and rkaplow@ comments. Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/tabs/tab_discard_state.h ('k') | chrome/browser/ui/tabs/tab_strip_model.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/tabs/tab_discard_state.cc
diff --git a/chrome/browser/ui/tabs/tab_discard_state.cc b/chrome/browser/ui/tabs/tab_discard_state.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7a7e8f05592e7e53ab1f097f6cbd95f17e81544c
--- /dev/null
+++ b/chrome/browser/ui/tabs/tab_discard_state.cc
@@ -0,0 +1,67 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/tabs/tab_discard_state.h"
+
+#include "content/public/browser/web_contents.h"
+
+using content::WebContents;
+
+namespace {
+
+const char kDiscardStateKey[] = "TabDiscardState";
+
+} // namespace
+
+// static
+TabDiscardState* TabDiscardState::Get(WebContents* web_contents) {
+ TabDiscardState* discard_state = static_cast<TabDiscardState*>(
+ web_contents->GetUserData(&kDiscardStateKey));
+
+ // If this function is called, we probably need to query/change the discard
+ // state. Let's go ahead a add one.
+ if (!discard_state) {
+ discard_state = new TabDiscardState;
+ web_contents->SetUserData(&kDiscardStateKey, discard_state);
+ }
+
+ return discard_state;
+}
+
+// static
+void TabDiscardState::Set(WebContents* web_contents, TabDiscardState* state) {
+ web_contents->SetUserData(&kDiscardStateKey, state);
+}
+
+// static
+bool TabDiscardState::IsDiscarded(WebContents* web_contents) {
+ TabDiscardState* discard_state = TabDiscardState::Get(web_contents);
+ return discard_state->is_discarded_;
+}
+
+// static
+void TabDiscardState::SetDiscardState(WebContents* web_contents, bool state) {
+ TabDiscardState* discard_state = TabDiscardState::Get(web_contents);
+ discard_state->is_discarded_ = state;
+}
+
+// static
+int TabDiscardState::DiscardCount(WebContents* web_contents) {
+ TabDiscardState* discard_state = TabDiscardState::Get(web_contents);
+ return discard_state->discard_count_;
+}
+
+// static
+void TabDiscardState::IncrementDiscardCount(WebContents* web_contents) {
+ TabDiscardState* discard_state = TabDiscardState::Get(web_contents);
+ discard_state->discard_count_++;
+}
+
+// static
+void TabDiscardState::CopyState(content::WebContents* old_contents,
+ content::WebContents* new_contents) {
+ TabDiscardState* old_state = Get(old_contents);
+ TabDiscardState* new_State = Get(new_contents);
+ *new_State = *old_state;
+}
« no previous file with comments | « chrome/browser/ui/tabs/tab_discard_state.h ('k') | chrome/browser/ui/tabs/tab_strip_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698