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

Side by Side Diff: chrome/browser/extensions/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: Rebase Created 8 years, 9 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/extension_window_controller.h"
6
7 #include "base/values.h"
8 #include "chrome/browser/extensions/extension_tabs_module_constants.h"
9 #include "chrome/browser/extensions/extension_window_list.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sessions/session_id.h"
12 #include "chrome/browser/ui/base_window.h"
13 #include "ui/gfx/rect.h"
14
15 ///////////////////////////////////////////////////////////////////////////////
16 // ExtensionWindowController
17
18 ExtensionWindowController::ExtensionWindowController(BaseWindow* window,
19 Profile* profile) :
20 window_(window),
21 profile_(profile) {
22 ExtensionWindowList::GetInstance()->AddExtensionWindow(this);
23 }
24
25 ExtensionWindowController::~ExtensionWindowController() {
26 ExtensionWindowList::GetInstance()->RemoveExtensionWindow(this);
27 }
28
29 bool ExtensionWindowController::MatchesProfile(
30 Profile* match_profile,
31 ProfileMatchType match_type) const {
32 return ((profile_ == match_profile) ||
33 (match_type == MATCH_INCOGNITO &&
34 (match_profile->HasOffTheRecordProfile() &&
35 match_profile->GetOffTheRecordProfile() == profile_)));
36 }
37
38 namespace keys = extension_tabs_module_constants;
39
40 base::DictionaryValue* ExtensionWindowController::CreateWindowValue() const {
41 DictionaryValue* result = new DictionaryValue();
42
43 result->SetInteger(keys::kIdKey, GetSessionId().id());
44 result->SetBoolean(keys::kFocusedKey, window()->IsActive());
45 result->SetBoolean(keys::kIncognitoKey, profile_->IsOffTheRecord());
46
47 gfx::Rect bounds;
48 if (window()->IsMinimized())
49 bounds = window()->GetRestoredBounds();
50 else
51 bounds = window()->GetBounds();
52 result->SetInteger(keys::kLeftKey, bounds.x());
53 result->SetInteger(keys::kTopKey, bounds.y());
54 result->SetInteger(keys::kWidthKey, bounds.width());
55 result->SetInteger(keys::kHeightKey, bounds.height());
56
57 return result;
58 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_window_controller.h ('k') | chrome/browser/extensions/extension_window_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698