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

Side by Side Diff: chrome/browser/extensions/browser_extension_window_controller.cc

Issue 9428018: Create BaseWindow and ExtensionWindowWrapper for extension API access to Panels (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments. Created 8 years, 10 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/browser_extension_window_controller.h"
6
7 #include "chrome/browser/extensions/extension_tab_util.h"
8 #include "chrome/browser/extensions/extension_tabs_module_constants.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sessions/session_id.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_window.h"
13
14 BrowserExtensionWindowController::BrowserExtensionWindowController(
15 Browser* browser)
16 : ExtensionWindowController(browser->window(), browser->profile()),
17 browser_(browser) {
18 }
19
20 const SessionID& BrowserExtensionWindowController::GetSessionId() const {
21 return browser_->session_id();
22 }
23
24 namespace keys = extension_tabs_module_constants;
25
26 base::DictionaryValue*
27 BrowserExtensionWindowController::CreateWindowValue() const {
28 DictionaryValue* result = new DictionaryValue();
29 result->SetInteger(keys::kIdKey, browser_->session_id().id());
30 result->SetBoolean(keys::kIncognitoKey,
31 browser_->profile()->IsOffTheRecord());
32 result->SetBoolean(keys::kFocusedKey, window()->IsActive());
33
34 gfx::Rect bounds;
35 if (window()->IsMaximized() || browser_->window()->IsFullscreen())
36 bounds = window()->GetBounds();
37 else
38 bounds = window()->GetRestoredBounds();
39 SetWindowValueBounds(bounds, result);
40
41 result->SetString(keys::kWindowTypeKey,
42 ExtensionTabUtil::GetWindowTypeText(browser_));
43 result->SetString(keys::kShowStateKey,
44 ExtensionTabUtil::GetWindowShowStateText(browser_));
45
46 return result;
47 }
48
49 base::DictionaryValue*
50 BrowserExtensionWindowController::CreateWindowValueWithTabs() const {
51 DictionaryValue* result = CreateWindowValue();
52
53 result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser_));
54
55 return result;
56 }
57
58 bool BrowserExtensionWindowController::CanClose(
59 ExtensionWindowController::Reason* reason) const {
60 // Don't let an extension remove the window if the user is dragging tabs
61 // in that window.
62 if (!browser_->IsTabStripEditable()) {
63 *reason = ExtensionWindowController::REASON_TAB_STRIP_NOT_EDITABLE;
64 return false;
65 }
66 return true;
67 }
68
69 void BrowserExtensionWindowController::SetFullscreenMode(
70 bool is_fullscreen, const GURL& extension_url) const {
sky 2012/02/24 04:38:24 nit: each param on its own line.
stevenjb 2012/02/24 19:25:06 Done.
71 if (browser_->window()->IsFullscreen() != is_fullscreen)
72 browser_->ToggleFullscreenModeWithExtension(extension_url);
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698